33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
import { useAppDispatch } from '../state/hooks';
|
|
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
|
|
export var useMouseEnterItemDispatch = (onMouseEnterFromProps, dataKey, graphicalItemId) => {
|
|
var dispatch = useAppDispatch();
|
|
return (data, index) => event => {
|
|
onMouseEnterFromProps === null || onMouseEnterFromProps === void 0 || onMouseEnterFromProps(data, index, event);
|
|
dispatch(setActiveMouseOverItemIndex({
|
|
activeIndex: String(index),
|
|
activeDataKey: dataKey,
|
|
activeCoordinate: data.tooltipPosition,
|
|
activeGraphicalItemId: graphicalItemId
|
|
}));
|
|
};
|
|
};
|
|
export var useMouseLeaveItemDispatch = onMouseLeaveFromProps => {
|
|
var dispatch = useAppDispatch();
|
|
return (data, index) => event => {
|
|
onMouseLeaveFromProps === null || onMouseLeaveFromProps === void 0 || onMouseLeaveFromProps(data, index, event);
|
|
dispatch(mouseLeaveItem());
|
|
};
|
|
};
|
|
export var useMouseClickItemDispatch = (onMouseClickFromProps, dataKey, graphicalItemId) => {
|
|
var dispatch = useAppDispatch();
|
|
return (data, index) => event => {
|
|
onMouseClickFromProps === null || onMouseClickFromProps === void 0 || onMouseClickFromProps(data, index, event);
|
|
dispatch(setActiveClickItemIndex({
|
|
activeIndex: String(index),
|
|
activeDataKey: dataKey,
|
|
activeCoordinate: data.tooltipPosition,
|
|
activeGraphicalItemId: graphicalItemId
|
|
}));
|
|
};
|
|
}; |