import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["seriesId", "onItemClick"]; import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { useRadarSeriesData } from "./useRadarSeriesData.js"; import { getAreaPath } from "./getAreaPath.js"; import { useUtilityClasses } from "./radarSeriesPlotClasses.js"; import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.js"; import { useInteractionAllItemProps } from "../../hooks/useInteractionItemProps.js"; import { useRadarRotationIndex } from "./useRadarRotationIndex.js"; import { jsx as _jsx } from "react/jsx-runtime"; export function getPathProps(params) { const { isHighlighted, isFaded, seriesId, classes, points, fillArea, color } = params; const isItemHighlighted = isHighlighted({ seriesId }); const isItemFaded = !isItemHighlighted && isFaded({ seriesId }); return { d: getAreaPath(points), fill: fillArea ? color : 'transparent', stroke: color, className: clsx(classes.area, isItemHighlighted && classes.highlighted || isItemFaded && classes.faded), strokeOpacity: isItemFaded ? 0.5 : 1, fillOpacity: isItemHighlighted && 0.4 || isItemFaded && 0.1 || 0.2, strokeWidth: !fillArea && isItemHighlighted ? 2 : 1 }; } function RadarSeriesArea(props) { const { seriesId, onItemClick } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const seriesCoordinates = useRadarSeriesData(seriesId); const getRotationIndex = useRadarRotationIndex(); const interactionProps = useInteractionAllItemProps(seriesCoordinates); const { isFaded, isHighlighted } = useItemHighlightedGetter(); const classes = useUtilityClasses(props.classes); return /*#__PURE__*/_jsx(React.Fragment, { children: seriesCoordinates?.map(({ seriesId: id, points, color, fillArea }, seriesIndex) => { return /*#__PURE__*/_jsx("path", _extends({}, getPathProps({ seriesId: id, points, color, fillArea, isFaded, isHighlighted, classes }), { onClick: event => onItemClick?.(event, { type: 'radar', seriesId: id, dataIndex: getRotationIndex(event) }), cursor: onItemClick ? 'pointer' : 'unset' }, interactionProps[seriesIndex], other), id); }) }); } process.env.NODE_ENV !== "production" ? RadarSeriesArea.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- /** * Override or extend the styles applied to the component. */ classes: PropTypes.object, /** * Callback fired when an area is clicked. * @param {React.MouseEvent} event The event source of the callback. * @param {RadarItemIdentifier} radarItemIdentifier The radar item identifier. */ onItemClick: PropTypes.func, /** * The id of the series to display. * If undefined all series are displayed. */ seriesId: PropTypes.string } : void 0; export { RadarSeriesArea };