| 1 | function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|---|
| 2 | function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|---|
| 3 | function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|---|
| 4 | function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|---|
| 5 | function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|---|
| 6 | import * as React from 'react';
|
|---|
| 7 | import { cloneElement, isValidElement } from 'react';
|
|---|
| 8 | import { adaptEventHandlers } from '../util/types';
|
|---|
| 9 | import { Dot } from '../shape/Dot';
|
|---|
| 10 | import { Layer } from '../container/Layer';
|
|---|
| 11 | import { useAppSelector } from '../state/hooks';
|
|---|
| 12 | import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
|
|---|
| 13 | import { useActiveTooltipDataPoints } from '../hooks';
|
|---|
| 14 | import { isNullish } from '../util/DataUtils';
|
|---|
| 15 | import { svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
|
|---|
| 16 | import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
|---|
| 17 | import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
|---|
| 18 | var ActivePoint = _ref => {
|
|---|
| 19 | var {
|
|---|
| 20 | point,
|
|---|
| 21 | childIndex,
|
|---|
| 22 | mainColor,
|
|---|
| 23 | activeDot,
|
|---|
| 24 | dataKey,
|
|---|
| 25 | clipPath
|
|---|
| 26 | } = _ref;
|
|---|
| 27 | if (activeDot === false || point.x == null || point.y == null) {
|
|---|
| 28 | return null;
|
|---|
| 29 | }
|
|---|
| 30 | var dotPropsTyped = {
|
|---|
| 31 | index: childIndex,
|
|---|
| 32 | dataKey,
|
|---|
| 33 | cx: point.x,
|
|---|
| 34 | cy: point.y,
|
|---|
| 35 | r: 4,
|
|---|
| 36 | fill: mainColor !== null && mainColor !== void 0 ? mainColor : 'none',
|
|---|
| 37 | strokeWidth: 2,
|
|---|
| 38 | stroke: '#fff',
|
|---|
| 39 | payload: point.payload,
|
|---|
| 40 | value: point.value
|
|---|
| 41 | };
|
|---|
| 42 |
|
|---|
| 43 | // @ts-expect-error svgPropertiesNoEventsFromUnknown(activeDot) is contributing unknown props
|
|---|
| 44 | var dotProps = _objectSpread(_objectSpread(_objectSpread({}, dotPropsTyped), svgPropertiesNoEventsFromUnknown(activeDot)), adaptEventHandlers(activeDot));
|
|---|
| 45 | var dot;
|
|---|
| 46 | if (/*#__PURE__*/isValidElement(activeDot)) {
|
|---|
| 47 | // @ts-expect-error we're improperly typing events
|
|---|
| 48 | dot = /*#__PURE__*/cloneElement(activeDot, dotProps);
|
|---|
| 49 | } else if (typeof activeDot === 'function') {
|
|---|
| 50 | dot = activeDot(dotProps);
|
|---|
| 51 | } else {
|
|---|
| 52 | dot = /*#__PURE__*/React.createElement(Dot, dotProps);
|
|---|
| 53 | }
|
|---|
| 54 | return /*#__PURE__*/React.createElement(Layer, {
|
|---|
| 55 | className: "recharts-active-dot",
|
|---|
| 56 | clipPath: clipPath
|
|---|
| 57 | }, dot);
|
|---|
| 58 | };
|
|---|
| 59 | export function ActivePoints(_ref2) {
|
|---|
| 60 | var {
|
|---|
| 61 | points,
|
|---|
| 62 | mainColor,
|
|---|
| 63 | activeDot,
|
|---|
| 64 | itemDataKey,
|
|---|
| 65 | clipPath,
|
|---|
| 66 | zIndex = DefaultZIndexes.activeDot
|
|---|
| 67 | } = _ref2;
|
|---|
| 68 | var activeTooltipIndex = useAppSelector(selectActiveTooltipIndex);
|
|---|
| 69 | var activeDataPoints = useActiveTooltipDataPoints();
|
|---|
| 70 | if (points == null || activeDataPoints == null) {
|
|---|
| 71 | return null;
|
|---|
| 72 | }
|
|---|
| 73 | var activePoint = points.find(p => activeDataPoints.includes(p.payload));
|
|---|
| 74 | if (isNullish(activePoint)) {
|
|---|
| 75 | return null;
|
|---|
| 76 | }
|
|---|
| 77 | return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
|---|
| 78 | zIndex: zIndex
|
|---|
| 79 | }, /*#__PURE__*/React.createElement(ActivePoint, {
|
|---|
| 80 | point: activePoint,
|
|---|
| 81 | childIndex: Number(activeTooltipIndex),
|
|---|
| 82 | mainColor: mainColor,
|
|---|
| 83 | dataKey: itemDataKey,
|
|---|
| 84 | activeDot: activeDot,
|
|---|
| 85 | clipPath: clipPath
|
|---|
| 86 | }));
|
|---|
| 87 | } |
|---|