23 lines
941 B
JavaScript
23 lines
941 B
JavaScript
'use client';
|
|
|
|
import { useStore } from "../internals/store/useStore.js";
|
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
import { selectorChartsIsFaded, selectorChartsIsHighlighted } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
/**
|
|
* A hook to check the highlighted state of the item.
|
|
* This function already calculates that an item is not faded if it is highlighted.
|
|
*
|
|
* If you need fine control over the state, use the `useItemHighlightedGetter` hook instead.
|
|
*
|
|
* @param {HighlightItemData | null} item is the item to check
|
|
* @returns {UseItemHighlightedReturnType} the state of the item
|
|
*/
|
|
export function useItemHighlighted(item) {
|
|
const store = useStore();
|
|
const isHighlighted = useSelector(store, selectorChartsIsHighlighted, [item]);
|
|
const isFaded = useSelector(store, selectorChartsIsFaded, [item]);
|
|
return {
|
|
isHighlighted,
|
|
isFaded: !isHighlighted && isFaded
|
|
};
|
|
} |