@graphysdk/react-renderer 0.0.1-plugins.10 → 0.0.1-plugins.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,153 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useRef as d, useState as p, useCallback as l, useLayoutEffect as m, useMemo as v } from "react";
3
+ import { createPortal as w } from "react-dom";
4
+ import { a as h } from "./tooltip-body-Cp_va3oW.js";
5
+ import { w as M, P as $, S as k, T as K, x as U, y as X, z as Y, f as j, t as q, l as F, k as Z, A as J, v as Q } from "./tooltip-body-Cp_va3oW.js";
6
+ import { DEFAULT_COLOR_PALETTE as g, RESTING_HOVER_STATE as b } from "@graphysdk/viz-engine";
7
+ function C(e, t) {
8
+ return {
9
+ type: e.type,
10
+ zOrder: t.zOrder,
11
+ draw: t.draw
12
+ };
13
+ }
14
+ const R = 2147483646;
15
+ function z() {
16
+ const e = d(null), [t, r] = p(null), n = l(() => {
17
+ const o = e.current;
18
+ if (!o) return;
19
+ const s = o.getBoundingClientRect(), u = {
20
+ left: s.left,
21
+ top: s.top,
22
+ width: s.width,
23
+ height: s.height
24
+ };
25
+ r((c) => c && E(c, u) ? c : u);
26
+ }, []), i = l(
27
+ (o) => {
28
+ e.current = o;
29
+ },
30
+ []
31
+ // stable, so attaching the ref never re-triggers the effect
32
+ );
33
+ return m(() => {
34
+ if (!e.current) return;
35
+ n();
36
+ const o = new ResizeObserver(n);
37
+ return o.observe(e.current), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
38
+ o.disconnect(), window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
39
+ };
40
+ }, [n]), { ref: i, rect: t };
41
+ }
42
+ function A({ rect: e, children: t }) {
43
+ return w(
44
+ /* @__PURE__ */ f(
45
+ "div",
46
+ {
47
+ style: {
48
+ position: "fixed",
49
+ left: e.left,
50
+ top: e.top,
51
+ width: e.width,
52
+ height: e.height,
53
+ pointerEvents: "none",
54
+ zIndex: R,
55
+ overflow: "visible"
56
+ },
57
+ children: t
58
+ }
59
+ ),
60
+ document.body
61
+ );
62
+ }
63
+ function E(e, t) {
64
+ return e.left === t.left && e.top === t.top && e.width === t.width && e.height === t.height;
65
+ }
66
+ function* O(e, t) {
67
+ for (const r of e)
68
+ yield { kind: r[t], observation: r };
69
+ }
70
+ function B(e, t, r, n) {
71
+ return e >= r && t >= n;
72
+ }
73
+ const _ = ({ children: e, style: t, ...r }) => /* @__PURE__ */ f(
74
+ "svg",
75
+ {
76
+ width: "100%",
77
+ height: "100%",
78
+ viewBox: "0 0 1 1",
79
+ preserveAspectRatio: "none",
80
+ ...r,
81
+ style: { overflow: "visible", ...t },
82
+ children: e
83
+ }
84
+ );
85
+ function H() {
86
+ return v(() => {
87
+ const e = g;
88
+ return (t) => e[t % e.length] ?? e[0] ?? "#000000";
89
+ }, []);
90
+ }
91
+ function N(e, t) {
92
+ const { hitTesterRegistry: r } = h(), n = d(t);
93
+ n.current = t, m(() => {
94
+ const i = (o) => n.current(o);
95
+ return r.set(e, i), () => {
96
+ r.delete(e);
97
+ };
98
+ }, [r, e]);
99
+ }
100
+ function G(e) {
101
+ const { engine: t, store: r, setCursor: n } = h();
102
+ return l(
103
+ (i, o) => {
104
+ if (i === null) {
105
+ r.getState().setHoverState(b), n(null);
106
+ return;
107
+ }
108
+ r.getState().setHoverState(t.hoverByKey(e, i)), o && n(o);
109
+ },
110
+ [t, r, n, e]
111
+ );
112
+ }
113
+ function x(e, t, r) {
114
+ const n = a(e), i = a(t), o = (s, u) => Math.round(s + (u - s) * r);
115
+ return `rgb(${o(n.red, i.red)}, ${o(n.green, i.green)}, ${o(n.blue, i.blue)})`;
116
+ }
117
+ function V(e, t) {
118
+ return x(e, "#ffffff", t);
119
+ }
120
+ function a(e) {
121
+ const t = e.replace("#", "");
122
+ return {
123
+ red: Number.parseInt(t.slice(0, 2), 16),
124
+ green: Number.parseInt(t.slice(2, 4), 16),
125
+ blue: Number.parseInt(t.slice(4, 6), 16)
126
+ };
127
+ }
128
+ export {
129
+ M as CompanionDot,
130
+ A as PanelOverlayPortal,
131
+ $ as PrimaryDot,
132
+ k as Swatch,
133
+ K as TooltipBody,
134
+ U as TooltipRowView,
135
+ _ as UnitSpaceSvg,
136
+ C as defineAnnotationRenderer,
137
+ X as defineGeomPlugin,
138
+ Y as defineGeomRenderer,
139
+ j as emToPx,
140
+ B as fitsLabel,
141
+ V as lighten,
142
+ x as mixColor,
143
+ O as partitionByKind,
144
+ q as toPercent,
145
+ F as toViewBoxX,
146
+ Z as toViewBoxY,
147
+ H as useCategoricalColor,
148
+ N as useGeomHitTest,
149
+ G as useGeomHover,
150
+ z as usePanelScreenRect,
151
+ J as useSvgPathMorph,
152
+ Q as vars
153
+ };