mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 07:22:56 +00:00
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
import { useAppDispatch } from '../state/hooks';
|
|
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
|
|
|
|
/**
|
|
* Some graphical items choose to provide more information to the tooltip
|
|
* and some do not.
|
|
*/
|
|
|
|
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
|
|
}));
|
|
};
|
|
}; |