import * as React from 'react';
import { observer } from 'mobx-react';
type HitZoneProps = {
x: number;
y: number;
width: number;
height: number;
cursor?: string;
onMouseOver?: () => void;
onClick?: () => void;
onMouseOut?: () => void;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
};
export type HitZoneConfig = {
hitRect: { x: number; y: number; width: number; height: number };
content?: JSX.Element;
mirrorHitRect?: { x: number; y: number; width: number; height: number }; // mirror lollipop component location and dimensions
mirrorContent?: JSX.Element; // mirror lollipop component tooltip contents
tooltipPlacement?: string;
cursor?: string;
onMouseOver?: () => void;
onClick?: () => void;
onMouseOut?: () => void;
};
export function defaultHitzoneConfig(): HitZoneConfig {
return {
hitRect: {
x: 0,
y: 0,
width: 0,
height: 0,
},
content: ,
mirrorHitRect: undefined,
mirrorContent: undefined,
tooltipPlacement: 'top',
cursor: 'pointer',
onMouseOver: () => 0,
onClick: () => 0,
onMouseOut: () => 0,
};
}
export function initHitZoneFromConfig(config: HitZoneConfig) {
return (
);
}
//@observer
export class HitZone extends React.Component {
private handlers: any;
constructor(props: HitZoneProps) {
super(props);
this.handlers = {
onMouseOver: () => {
this.props.onMouseOver && this.props.onMouseOver();
this.props.onMouseEnter && this.props.onMouseEnter();
},
onMouseOut: () => {
this.props.onMouseOut && this.props.onMouseOut();
this.props.onMouseLeave && this.props.onMouseLeave();
},
};
}
render() {
return (
);
}
}
export default HitZone;