@@ -27,9 +27,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
28
28
var react_1 = __importDefault ( require ( "react" ) ) ;
29
29
var material_1 = require ( "@mui/material" ) ;
30
+ var react_router_dom_1 = require ( "react-router-dom" ) ;
30
31
var Image = function ( _a ) {
31
- var alt = _a . alt , src = _a . src , _b = _a . boxProps , boxProps = _b === void 0 ? { } : _b ;
32
- var sx = boxProps . sx , otherProps = __rest ( boxProps , [ "sx" ] ) ;
33
- return ( react_1 . default . createElement ( material_1 . Box , __assign ( { component : 'img' , alt : alt , src : src , sx : __assign ( { width : '100%' } , sx ) } , otherProps ) ) ) ;
32
+ var alt = _a . alt , src = _a . src , href = _a . href , _b = _a . boxProps , boxProps = _b === void 0 ? { } : _b ;
33
+ var sx = boxProps . sx , onClick = boxProps . onClick , _c = boxProps . style , style = _c === void 0 ? { } : _c , otherProps = __rest ( boxProps , [ "sx" , "onClick" , "style" ] ) ;
34
+ // Override onClick if href provided.
35
+ if ( href !== undefined ) {
36
+ var navigate_1 = ( 0 , react_router_dom_1 . useNavigate ) ( ) ;
37
+ onClick = function ( ) { navigate_1 ( href ) ; } ;
38
+ style . cursor = 'pointer' ;
39
+ }
40
+ return ( react_1 . default . createElement ( material_1 . Box , __assign ( { component : 'img' , alt : alt , src : src , onClick : onClick , style : style , sx : __assign ( { width : '100%' } , sx ) } , otherProps ) ) ) ;
34
41
} ;
35
42
exports . default = Image ;
0 commit comments