| 1 | var _excluded = ["points"];
|
|---|
| 2 | 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; }
|
|---|
| 3 | 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; }
|
|---|
| 4 | 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; }
|
|---|
| 5 | function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|---|
| 6 | 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); }
|
|---|
| 7 | function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|---|
| 8 | function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|---|
| 9 | function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|---|
| 10 | import * as React from 'react';
|
|---|
| 11 | import { cloneElement, isValidElement } from 'react';
|
|---|
| 12 | import { clsx } from 'clsx';
|
|---|
| 13 | import { Dot } from '../shape/Dot';
|
|---|
| 14 | import { Layer } from '../container/Layer';
|
|---|
| 15 | import { isClipDot } from '../util/ReactUtils';
|
|---|
| 16 | import { svgPropertiesAndEventsFromUnknown } from '../util/svgPropertiesAndEvents';
|
|---|
| 17 | import { ZIndexLayer } from '../zIndex/ZIndexLayer';
|
|---|
| 18 | import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
|
|---|
| 19 | function DotItem(_ref) {
|
|---|
| 20 | var {
|
|---|
| 21 | option,
|
|---|
| 22 | dotProps,
|
|---|
| 23 | className
|
|---|
| 24 | } = _ref;
|
|---|
| 25 | if (/*#__PURE__*/isValidElement(option)) {
|
|---|
| 26 | // @ts-expect-error we can't type check element cloning properly
|
|---|
| 27 | return /*#__PURE__*/cloneElement(option, dotProps);
|
|---|
| 28 | }
|
|---|
| 29 | if (typeof option === 'function') {
|
|---|
| 30 | return option(dotProps);
|
|---|
| 31 | }
|
|---|
| 32 | var finalClassName = clsx(className, typeof option !== 'boolean' ? option.className : '');
|
|---|
| 33 | var _ref2 = dotProps !== null && dotProps !== void 0 ? dotProps : {},
|
|---|
| 34 | {
|
|---|
| 35 | points
|
|---|
| 36 | } = _ref2,
|
|---|
| 37 | props = _objectWithoutProperties(_ref2, _excluded);
|
|---|
| 38 | return /*#__PURE__*/React.createElement(Dot, _extends({}, props, {
|
|---|
| 39 | className: finalClassName
|
|---|
| 40 | }));
|
|---|
| 41 | }
|
|---|
| 42 | function shouldRenderDots(points, dot) {
|
|---|
| 43 | if (points == null) {
|
|---|
| 44 | return false;
|
|---|
| 45 | }
|
|---|
| 46 | if (dot) {
|
|---|
| 47 | return true;
|
|---|
| 48 | }
|
|---|
| 49 | return points.length === 1;
|
|---|
| 50 | }
|
|---|
| 51 | export function Dots(_ref3) {
|
|---|
| 52 | var {
|
|---|
| 53 | points,
|
|---|
| 54 | dot,
|
|---|
| 55 | className,
|
|---|
| 56 | dotClassName,
|
|---|
| 57 | dataKey,
|
|---|
| 58 | baseProps,
|
|---|
| 59 | needClip,
|
|---|
| 60 | clipPathId,
|
|---|
| 61 | zIndex = DefaultZIndexes.scatter
|
|---|
| 62 | } = _ref3;
|
|---|
| 63 | if (!shouldRenderDots(points, dot)) {
|
|---|
| 64 | return null;
|
|---|
| 65 | }
|
|---|
| 66 | var clipDot = isClipDot(dot);
|
|---|
| 67 | var customDotProps = svgPropertiesAndEventsFromUnknown(dot);
|
|---|
| 68 | var dots = points.map((entry, i) => {
|
|---|
| 69 | var _entry$x, _entry$y;
|
|---|
| 70 | var dotProps = _objectSpread(_objectSpread(_objectSpread({
|
|---|
| 71 | r: 3
|
|---|
| 72 | }, baseProps), customDotProps), {}, {
|
|---|
| 73 | index: i,
|
|---|
| 74 | cx: (_entry$x = entry.x) !== null && _entry$x !== void 0 ? _entry$x : undefined,
|
|---|
| 75 | cy: (_entry$y = entry.y) !== null && _entry$y !== void 0 ? _entry$y : undefined,
|
|---|
| 76 | dataKey,
|
|---|
| 77 | value: entry.value,
|
|---|
| 78 | payload: entry.payload,
|
|---|
| 79 | points
|
|---|
| 80 | });
|
|---|
| 81 | return /*#__PURE__*/React.createElement(DotItem, {
|
|---|
| 82 | key: "dot-".concat(i),
|
|---|
| 83 | option: dot,
|
|---|
| 84 | dotProps: dotProps,
|
|---|
| 85 | className: dotClassName
|
|---|
| 86 | });
|
|---|
| 87 | });
|
|---|
| 88 | var layerProps = {};
|
|---|
| 89 | if (needClip && clipPathId != null) {
|
|---|
| 90 | layerProps.clipPath = "url(#clipPath-".concat(clipDot ? '' : 'dots-').concat(clipPathId, ")");
|
|---|
| 91 | }
|
|---|
| 92 | return /*#__PURE__*/React.createElement(ZIndexLayer, {
|
|---|
| 93 | zIndex: zIndex
|
|---|
| 94 | }, /*#__PURE__*/React.createElement(Layer, _extends({
|
|---|
| 95 | className: className
|
|---|
| 96 | }, layerProps), dots));
|
|---|
| 97 | } |
|---|