UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

22 lines (21 loc) 854 B
'use client'; import { useStore } from "../internals/store/useStore.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 = store.use(selectorChartsIsHighlighted, item); const isFaded = store.use(selectorChartsIsFaded, item); return { isHighlighted, isFaded: !isHighlighted && isFaded }; }