(props)
| 38 | }; |
| 39 | |
| 40 | function Button(props) { |
| 41 | const onClick = useCallback( |
| 42 | (e) => { |
| 43 | if (props.disabled) { |
| 44 | e.preventDefault(); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | if (props.onClick) { |
| 49 | return props.onClick(e); |
| 50 | } |
| 51 | }, |
| 52 | [props.onClick, props.disabled], |
| 53 | ); |
| 54 | |
| 55 | let { |
| 56 | active, |
| 57 | 'aria-label': ariaLabel, |
| 58 | block, |
| 59 | className, |
| 60 | close, |
| 61 | cssModule, |
| 62 | color = 'secondary', |
| 63 | outline, |
| 64 | size, |
| 65 | tag: Tag = 'button', |
| 66 | innerRef, |
| 67 | ...attributes |
| 68 | } = props; |
| 69 | |
| 70 | if (close) { |
| 71 | return <CloseButton {...attributes} />; |
| 72 | } |
| 73 | |
| 74 | const btnOutlineColor = `btn${outline ? '-outline' : ''}-${color}`; |
| 75 | |
| 76 | const classes = mapToCssModules( |
| 77 | classNames( |
| 78 | className, |
| 79 | 'btn', |
| 80 | btnOutlineColor, |
| 81 | size ? `btn-${size}` : false, |
| 82 | block ? 'd-block w-100' : false, |
| 83 | { active, disabled: props.disabled }, |
| 84 | ), |
| 85 | cssModule, |
| 86 | ); |
| 87 | |
| 88 | if (attributes.href && Tag === 'button') { |
| 89 | Tag = 'a'; |
| 90 | } |
| 91 | |
| 92 | return ( |
| 93 | <Tag |
| 94 | type={Tag === 'button' && attributes.onClick ? 'button' : undefined} |
| 95 | {...attributes} |
| 96 | className={classes} |
| 97 | ref={innerRef} |
nothing calls this directly
no test coverage detected
searching dependent graphs…