UNPKG

laif-ds

Version:

Design System di Laif con componenti React basati su principi di Atomic Design

128 lines (127 loc) 3.87 kB
"use client"; import * as S from "react"; import { cloneElement as w, createElement as E, isValidElement as N } from "react"; import { clsx as R } from "../../../clsx/dist/clsx.js"; import { Curve as B } from "../shape/Curve.js"; import { Cross as _ } from "../shape/Cross.js"; import { getCursorRectangle as z } from "../util/cursor/getCursorRectangle.js"; import { Rectangle as A } from "../shape/Rectangle.js"; import { getRadialCursorPoints as D } from "../util/cursor/getRadialCursorPoints.js"; import { Sector as I } from "../shape/Sector.js"; import { getCursorPoints as T } from "../util/cursor/getCursorPoints.js"; import { filterProps as k } from "../util/ReactUtils.js"; import { useOffsetInternal as K, useChartLayout as L } from "../context/chartLayoutContext.js"; import { useTooltipAxisBandSize as V } from "../context/useTooltipAxis.js"; import { useChartName as q } from "../state/selectors/selectors.js"; function m() { return m = Object.assign ? Object.assign.bind() : function(r) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var o in t) ({}).hasOwnProperty.call(t, o) && (r[o] = t[o]); } return r; }, m.apply(null, arguments); } function v(r, e) { var t = Object.keys(r); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(r); e && (o = o.filter(function(a) { return Object.getOwnPropertyDescriptor(r, a).enumerable; })), t.push.apply(t, o); } return t; } function u(r) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? v(Object(t), !0).forEach(function(o) { F(r, o, t[o]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : v(Object(t)).forEach(function(o) { Object.defineProperty(r, o, Object.getOwnPropertyDescriptor(t, o)); }); } return r; } function F(r, e, t) { return (e = G(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r; } function G(r) { var e = H(r, "string"); return typeof e == "symbol" ? e : e + ""; } function H(r, e) { if (typeof r != "object" || !r) return r; var t = r[Symbol.toPrimitive]; if (t !== void 0) { var o = t.call(r, e); if (typeof o != "object") return o; throw new TypeError("@@toPrimitive must return a primitive value."); } return (e === "string" ? String : Number)(r); } function J(r) { var { coordinate: e, payload: t, index: o, offset: a, tooltipAxisBandSize: d, layout: l, cursor: n, tooltipEventType: b, chartName: f } = r, i = e, g = t, O = o; if (!n || !i || f !== "ScatterChart" && b !== "axis") return null; var s, c; if (f === "ScatterChart") s = i, c = _; else if (f === "BarChart") s = z(l, i, a, d), c = A; else if (l === "radial") { var { cx: P, cy: j, radius: p, startAngle: h, endAngle: C } = D(i); s = { cx: P, cy: j, startAngle: h, endAngle: C, innerRadius: p, outerRadius: p }, c = I; } else s = { points: T(l, i, a) }, c = B; var x = typeof n == "object" && "className" in n ? n.className : void 0, y = u(u(u(u({ stroke: "#ccc", pointerEvents: "none" }, a), s), k(n, !1)), {}, { payload: g, payloadIndex: O, className: R("recharts-tooltip-cursor", x) }); return /* @__PURE__ */ N(n) ? /* @__PURE__ */ w(n, y) : /* @__PURE__ */ E(c, y); } function nr(r) { var e = V(), t = K(), o = L(), a = q(); return /* @__PURE__ */ S.createElement(J, m({}, r, { coordinate: r.coordinate, index: r.index, payload: r.payload, offset: t, layout: o, tooltipAxisBandSize: e, chartName: a })); } export { nr as Cursor, J as CursorInternal };