UNPKG

@glodon-aiot/react-components

Version:

aiot react components

87 lines (86 loc) 3.11 kB
var D = Object.defineProperty, I = Object.defineProperties; var j = Object.getOwnPropertyDescriptors; var s = Object.getOwnPropertySymbols; var m = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable; var h = (o, n, e) => n in o ? D(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e, c = (o, n) => { for (var e in n || (n = {})) m.call(n, e) && h(o, e, n[e]); if (s) for (var e of s(n)) C.call(n, e) && h(o, e, n[e]); return o; }, S = (o, n) => I(o, j(n)); var x = (o, n) => { var e = {}; for (var t in o) m.call(o, t) && n.indexOf(t) < 0 && (e[t] = o[t]); if (o != null && s) for (var t of s(o)) n.indexOf(t) < 0 && C.call(o, t) && (e[t] = o[t]); return e; }; import { jsx as R } from "react/jsx-runtime"; import { useState as W, useRef as z, useEffect as T } from "react"; import A from "antd/es/tooltip"; const E = (o) => { var a, g, O, v; const f = o, { children: n, open: e, point: t, key: b, style: k } = f, w = x(f, [ "children", "open", "point", "key", "style" ]), [P, u] = W(e && t.tooltipOpen !== void 0 ? t.tooltipOpen : void 0), i = z(null); return T(() => { var p, d; if (!t.tooltipRender || !i.current) return; const l = t.tooltipRender(t); if (typeof l == "string" || typeof l == "number") { i.current.innerText = l.toString(); return; } const r = (p = i.current) == null ? void 0 : p.firstChild; r ? r.replaceWith(l) : (d = i.current) == null || d.appendChild(l), console.log("tooltip inner text", t.id), console.log((/* @__PURE__ */ new Date()).valueOf()); }, [t.tooltipRender, P]), T(() => { u(t.tooltipOpen !== void 0 ? t.tooltipOpen && e : void 0); }, [t.tooltipOpen !== void 0 ? t.tooltipOpen && e : void 0]), console.log("render PointTooltip", t.id), console.log((/* @__PURE__ */ new Date()).valueOf()), /* @__PURE__ */ R(A, S(c({}, w), { autoAdjustOverflow: !1, placement: "top", open: t.tooltipOpen !== void 0 ? t.tooltipOpen && e : void 0, onOpenChange: (l) => { var d, y; if (t.tooltipOpen || u(l), console.log("tooltip inner text", t.id), console.log((/* @__PURE__ */ new Date()).valueOf()), !t.tooltipRender || !i.current) return; const r = t.tooltipRender(t); if (typeof r == "string" || typeof r == "number") { i.current.innerText = r.toString(); return; } const p = (d = i.current) == null ? void 0 : d.firstChild; p ? p.replaceWith(r) : (y = i.current) == null || y.appendChild(r); }, color: ((a = t.tooltipStyle) == null ? void 0 : a.backgroundColor) || ((g = t.tooltipStyle) == null ? void 0 : g.backgroundImage) || ((v = (O = t.tooltipStyle) == null ? void 0 : O.background) == null ? void 0 : v.toString()), title: /* @__PURE__ */ R("div", { ref: i }, b), overlayInnerStyle: t.tooltipStyle, destroyTooltipOnHide: !0, style: c({ zIndex: 9 }, k), motion: { forceRender: !0 }, children: n })); }, F = E; export { F as default };