@green-on-grey/ui-kit 1.13.0 → 1.14.0

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.
package/dist/index.js CHANGED
@@ -1,30 +1,30 @@
1
1
  import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./ui-BrAaLui6.js";
2
2
  import { n as f, t as p } from "./i18n-BJ8rsBp6.js";
3
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
4
- import { useCallback as g, useEffect as _, useId as v, useMemo as y, useRef as b, useState as x } from "react";
5
- import { forceCenter as S, forceCollide as C, forceLink as w, forceManyBody as T, forceSimulation as E } from "d3-force";
3
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
4
+ import { useCallback as _, useEffect as v, useId as y, useMemo as b, useRef as x, useState as S } from "react";
5
+ import { forceCenter as C, forceCollide as w, forceLink as T, forceManyBody as E, forceSimulation as D } from "d3-force";
6
6
  //#region src/components/Button.tsx
7
- function D({ variant: e, size: t, className: n, type: r = "button", ...i }) {
7
+ function O({ variant: e, size: t, className: n, type: r = "button", ...i }) {
8
8
  let a = [
9
9
  "btn",
10
10
  e,
11
11
  t,
12
12
  n
13
13
  ].filter(Boolean).join(" ");
14
- return /* @__PURE__ */ m("button", {
14
+ return /* @__PURE__ */ h("button", {
15
15
  type: r,
16
16
  className: a,
17
17
  ...i
18
18
  });
19
19
  }
20
- function O({ label: e, fill: t, on: n, className: r, type: i = "button", ...a }) {
20
+ function k({ label: e, fill: t, on: n, className: r, type: i = "button", ...a }) {
21
21
  let o = [
22
22
  "iconbtn",
23
23
  t && "fill",
24
24
  n && "on",
25
25
  r
26
26
  ].filter(Boolean).join(" ");
27
- return /* @__PURE__ */ m("button", {
27
+ return /* @__PURE__ */ h("button", {
28
28
  type: i,
29
29
  className: o,
30
30
  "aria-label": e,
@@ -33,12 +33,12 @@ function O({ label: e, fill: t, on: n, className: r, type: i = "button", ...a })
33
33
  }
34
34
  //#endregion
35
35
  //#region src/components/Menu.tsx
36
- function k({ onClose: e, label: t, className: n, children: r }) {
36
+ function A({ onClose: e, label: t, className: n, children: r }) {
37
37
  let i = l(!0, e);
38
- return _(() => {
38
+ return v(() => {
39
39
  let e = document.activeElement;
40
40
  return () => e?.focus?.();
41
- }, []), /* @__PURE__ */ m("div", {
41
+ }, []), /* @__PURE__ */ h("div", {
42
42
  className: `menu${n ? ` ${n}` : ""}`,
43
43
  role: "dialog",
44
44
  "aria-label": t,
@@ -48,52 +48,52 @@ function k({ onClose: e, label: t, className: n, children: r }) {
48
48
  }
49
49
  //#endregion
50
50
  //#region src/components/TopBar.tsx
51
- function A({ logo: e, name: t, home: n = "/", sections: i, Link: a, center: o, actions: s, avatar: c, profileMenu: u, menu: d }) {
52
- let p = f(), [_, v] = x(!1), [y, b] = x(!1), S = g(() => b(!1), []), C = g(() => v(!1), []), w = l(y, S), T = i.map((e) => /* @__PURE__ */ m(a, {
51
+ function j({ logo: e, name: t, home: n = "/", sections: i, Link: a, center: o, actions: s, avatar: c, profileMenu: u, menu: d }) {
52
+ let p = f(), [m, v] = S(!1), [y, b] = S(!1), x = _(() => b(!1), []), C = _(() => v(!1), []), w = l(y, x), T = i.map((e) => /* @__PURE__ */ h(a, {
53
53
  href: e.href,
54
54
  className: e.active ? "on" : void 0,
55
55
  "aria-current": e.active ? "page" : void 0,
56
- onClick: S,
56
+ onClick: x,
57
57
  children: e.label
58
58
  }, e.key));
59
- return /* @__PURE__ */ h("div", {
59
+ return /* @__PURE__ */ g("div", {
60
60
  className: "topbar",
61
61
  children: [
62
- /* @__PURE__ */ h(a, {
62
+ /* @__PURE__ */ g(a, {
63
63
  href: n,
64
64
  className: "brand",
65
- children: [/* @__PURE__ */ m("img", {
65
+ children: [/* @__PURE__ */ h("img", {
66
66
  src: e,
67
67
  alt: ""
68
- }), /* @__PURE__ */ m("span", {
68
+ }), /* @__PURE__ */ h("span", {
69
69
  className: "hide-m",
70
70
  children: t
71
71
  })]
72
72
  }),
73
- /* @__PURE__ */ m("nav", {
73
+ /* @__PURE__ */ h("nav", {
74
74
  className: "nav hide-m",
75
75
  "aria-label": p("topbar.sections"),
76
76
  children: T
77
77
  }),
78
78
  o,
79
- /* @__PURE__ */ h("div", {
79
+ /* @__PURE__ */ g("div", {
80
80
  className: "top-actions",
81
81
  children: [
82
82
  s,
83
- /* @__PURE__ */ m("button", {
83
+ /* @__PURE__ */ h("button", {
84
84
  className: "avatar",
85
- style: _ ? { boxShadow: "0 0 0 2px var(--violet)" } : void 0,
85
+ style: m ? { boxShadow: "0 0 0 2px var(--violet)" } : void 0,
86
86
  onClick: () => {
87
87
  b(!1), v((e) => !e);
88
88
  },
89
89
  "aria-label": p("topbar.profile"),
90
- "aria-expanded": _,
90
+ "aria-expanded": m,
91
91
  children: c
92
92
  }),
93
- /* @__PURE__ */ h("div", {
93
+ /* @__PURE__ */ g("div", {
94
94
  className: "burger",
95
95
  ref: w,
96
- children: [/* @__PURE__ */ m("button", {
96
+ children: [/* @__PURE__ */ h("button", {
97
97
  className: `iconbtn${y ? " on" : ""}`,
98
98
  onClick: () => {
99
99
  v(!1), b((e) => !e);
@@ -101,12 +101,12 @@ function A({ logo: e, name: t, home: n = "/", sections: i, Link: a, center: o, a
101
101
  "aria-label": d?.label ?? p("topbar.sections"),
102
102
  "aria-expanded": y,
103
103
  "aria-controls": "nav-sections",
104
- children: /* @__PURE__ */ m(r, { name: y ? "x" : "menu" })
105
- }), y && (d ? /* @__PURE__ */ m("div", {
104
+ children: /* @__PURE__ */ h(r, { name: y ? "x" : "menu" })
105
+ }), y && (d ? /* @__PURE__ */ h("div", {
106
106
  id: "nav-sections",
107
107
  className: "navmenu",
108
- children: d.render(S)
109
- }) : /* @__PURE__ */ m("nav", {
108
+ children: d.render(x)
109
+ }) : /* @__PURE__ */ h("nav", {
110
110
  id: "nav-sections",
111
111
  className: "navmenu",
112
112
  "aria-label": p("topbar.sections"),
@@ -115,21 +115,21 @@ function A({ logo: e, name: t, home: n = "/", sections: i, Link: a, center: o, a
115
115
  })
116
116
  ]
117
117
  }),
118
- _ && u(C)
118
+ m && u(C)
119
119
  ]
120
120
  });
121
121
  }
122
122
  //#endregion
123
123
  //#region src/components/Graph.tsx
124
- var j = 760, M = 500, N = (e = 1) => 7 + Math.sqrt(e) * 3.2, P = (e, t) => {
125
- let n = Math.max(.5, Math.min(4, e.k * t));
124
+ var M = 760, N = 500, P = (e = 1) => 7 + Math.sqrt(e) * 3.2, F = (e, t, n) => {
125
+ let r = Math.max(.5, Math.min(4, e.k * t));
126
126
  return {
127
- k: n,
128
- x: j / 2 - (j / 2 - e.x) / e.k * n,
129
- y: M / 2 - (M / 2 - e.y) / e.k * n
127
+ k: r,
128
+ x: n.w / 2 - (n.w / 2 - e.x) / e.k * r,
129
+ y: n.h / 2 - (n.h / 2 - e.y) / e.k * r
130
130
  };
131
131
  };
132
- function F(e, t, n) {
132
+ function I(e, t, n) {
133
133
  let r = /* @__PURE__ */ new Set([t]), i = [t];
134
134
  for (let t = 0; t < n; t++) {
135
135
  let t = [];
@@ -141,194 +141,333 @@ function F(e, t, n) {
141
141
  }
142
142
  return r;
143
143
  }
144
- function I(e, t) {
144
+ function L(e, t) {
145
145
  let n = e.map((e) => ({
146
146
  ...e,
147
- r: N(e.size)
147
+ r: P(e.size)
148
148
  })), r = new Set(n.map((e) => e.id)), i = t.filter((e) => r.has(e.source) && r.has(e.target)).map((e) => ({
149
149
  source: e.source,
150
150
  target: e.target,
151
151
  weight: e.weight ?? 1
152
- })), a = E(n).force("link", w(i).id((e) => e.id).distance(90).strength((e) => Math.min(1, .2 + e.weight * .08))).force("charge", T().strength(-260)).force("center", S(j / 2, M / 2)).force("collide", C().radius((e) => e.r + 14)).stop();
152
+ })), a = D(n).force("link", T(i).id((e) => e.id).distance(90).strength((e) => Math.min(1, .2 + e.weight * .08))).force("charge", E().strength(-260)).force("center", C(M / 2, N / 2)).force("collide", w().radius((e) => e.r + 14)).stop();
153
153
  for (let e = 0; e < 260; e++) a.tick();
154
- for (let e of n) e.x = Math.max(e.r + 30, Math.min(j - e.r - 30, e.x ?? j / 2)), e.y = Math.max(e.r + 10, Math.min(M - e.r - 24, e.y ?? M / 2));
154
+ for (let e of n) e.x = Math.max(e.r + 30, Math.min(M - e.r - 30, e.x ?? M / 2)), e.y = Math.max(e.r + 10, Math.min(N - e.r - 24, e.y ?? N / 2));
155
155
  return n;
156
156
  }
157
- function L({ nodes: e, edges: t, ariaLabel: n, selected: r, onSelect: i, focus: a, depth: o = 1, onOpen: s, legend: c, nodeLabel: l }) {
158
- let u = f(), d = `g-arrow-${v().replace(/:/g, "")}`, [p, g] = x(null), [S, C] = x({
157
+ var R = 130, z = 104, B = 76;
158
+ function V(e, t) {
159
+ let n = new Map(t.map((e, t) => [e.id, t])), r = /* @__PURE__ */ new Map(), i = e.map((e) => ({
160
+ ...e,
161
+ r: P(e.size)
162
+ }));
163
+ for (let e of i) {
164
+ let i = n.get(e.row ?? "") ?? t.length;
165
+ r.set(i, [...r.get(i) ?? [], e]);
166
+ }
167
+ let a = [...r.keys()].toSorted((e, t) => e - t), o = R + Math.max(1, ...a.map((e) => r.get(e).length)) * z, s = a.length * B, c = {
168
+ w: Math.max(M, o + 40),
169
+ h: Math.max(N, s + 40)
170
+ }, l = (c.w - o) / 2, u = (c.h - s) / 2;
171
+ return {
172
+ placed: i,
173
+ field: c,
174
+ rows: a.map((e, n) => {
175
+ let i = u + B * (n + .5) - 8;
176
+ return r.get(e).toSorted((e, t) => (e.order ?? Infinity) - (t.order ?? Infinity) || (e.id < t.id ? -1 : +(e.id > t.id))).forEach((e, t) => {
177
+ e.x = l + R + z * (t + .5), e.y = i;
178
+ }), {
179
+ id: t[e]?.id ?? "",
180
+ label: t[e]?.label ?? "",
181
+ y: i,
182
+ x: l + 8,
183
+ x2: l + o
184
+ };
185
+ })
186
+ };
187
+ }
188
+ function H(e, t, n, r) {
189
+ let i = e.x ?? 0, a = e.y ?? 0, o = t.x ?? 0, s = t.y ?? 0, c = o, l = s, u = r && Math.abs(l - a) < 1 && i !== c, d = (i + c) / 2, f = a - Math.sign(c - i) * Math.min(B * .8, 14 + Math.abs(c - i) * .25);
190
+ if (n) {
191
+ let e = u ? d : i, n = u ? f : a, r = c - e, o = l - n, s = Math.hypot(r, o) || 1;
192
+ c -= r / s * (t.r + 2), l -= o / s * (t.r + 2);
193
+ }
194
+ return u ? {
195
+ d: `M${i},${a} Q${d},${f} ${c},${l}`,
196
+ hit: `M${i},${a} Q${d},${f} ${o},${s}`,
197
+ x1: i,
198
+ y1: a,
199
+ x2: c,
200
+ y2: l
201
+ } : {
202
+ x1: i,
203
+ y1: a,
204
+ x2: c,
205
+ y2: l
206
+ };
207
+ }
208
+ function U({ nodes: e, edges: t, ariaLabel: n, selected: i, onSelect: a, focus: o, depth: s = 1, onOpen: c, legend: l, nodeLabel: u, rows: d, draggable: p }) {
209
+ let _ = f(), C = `g-arrow-${y().replace(/:/g, "")}`, [w, T] = S(null), [E, D] = S({
159
210
  k: 1,
160
211
  x: 0,
161
212
  y: 0
162
- }), w = b(null), T = b(null), { placed: E, byId: D } = y(() => {
163
- let n = I(e, t);
213
+ }), O = x(null), k = x(null), A = x(-Infinity), j = x(null), P = d ? void 0 : t, R = b(() => d ? V(e, d) : {
214
+ placed: L(e, P ?? []),
215
+ field: {
216
+ w: M,
217
+ h: N
218
+ }
219
+ }, [
220
+ e,
221
+ P,
222
+ d
223
+ ]), { field: z } = R, [U, W] = S(null), G = U?.of === R ? U.at : void 0, { placed: K, byId: q } = b(() => {
224
+ let e = G ? R.placed.map((e) => G.has(e.id) ? {
225
+ ...e,
226
+ ...G.get(e.id)
227
+ } : e) : R.placed;
164
228
  return {
165
- placed: n,
166
- byId: new Map(n.map((e) => [e.id, e]))
229
+ placed: e,
230
+ byId: new Map(e.map((e) => [e.id, e]))
167
231
  };
168
- }, [e, t]), O = a !== void 0 && D.has(a) ? a : void 0, k = p ?? (r?.kind === "node" ? r.id : null), A = y(() => r?.kind === "edge" && !p ? /* @__PURE__ */ new Set([r.source, r.target]) : k ? F(t, k, 1) : O ? F(t, O, o) : /* @__PURE__ */ new Set(), [
169
- k,
170
- r,
171
- p,
172
- O,
173
- o,
232
+ }, [R, G]), J = o !== void 0 && q.has(o) ? o : void 0, Y = w ?? (i?.kind === "node" ? i.id : null), X = b(() => i?.kind === "edge" && !w ? /* @__PURE__ */ new Set([i.source, i.target]) : Y ? I(t, Y, 1) : J ? I(t, J, s) : /* @__PURE__ */ new Set(), [
233
+ Y,
234
+ i,
235
+ w,
236
+ J,
237
+ s,
174
238
  t
175
- ]), N = A.size > 0, L = (e) => r?.kind === "edge" && !p ? r.source === e.source && r.target === e.target : k ? e.source === k || e.target === k : O !== void 0 && A.has(e.source) && A.has(e.target), R = (e) => C((t) => P(t, e)), z = (e, t) => i(t ? null : {
239
+ ]), ee = X.size > 0, te = (e) => i?.kind === "edge" && !w ? i.source === e.source && i.target === e.target : Y ? e.source === Y || e.target === Y : J !== void 0 && X.has(e.source) && X.has(e.target), Z = (e) => D((t) => F(t, e, z)), Q = (e, t) => a(t ? null : {
176
240
  kind: "node",
177
241
  id: e
178
- });
179
- return _(() => {
180
- let e = T.current;
242
+ }), $ = (e) => {
243
+ let t = e.getBoundingClientRect();
244
+ return 1 / (Math.min(t.width / z.w, t.height / z.h) || 1);
245
+ };
246
+ return v(() => {
247
+ let e = j.current;
181
248
  if (!e) return;
182
249
  let t = (e) => {
183
- e.preventDefault(), C((t) => P(t, e.deltaY < 0 ? 1.15 : 1 / 1.15));
250
+ e.preventDefault(), D((t) => F(t, e.deltaY < 0 ? 1.15 : 1 / 1.15, z));
184
251
  };
185
252
  return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
186
- }, []), /* @__PURE__ */ h("div", {
253
+ }, [z]), /* @__PURE__ */ g("div", {
187
254
  className: "gwrap",
188
255
  children: [
189
- /* @__PURE__ */ h("svg", {
190
- ref: T,
191
- viewBox: `0 0 ${j} ${M}`,
256
+ /* @__PURE__ */ g("svg", {
257
+ ref: j,
258
+ viewBox: `0 0 ${z.w} ${z.h}`,
192
259
  role: "group",
193
260
  "aria-label": n,
194
- className: N ? "dimmed" : void 0,
261
+ className: ee ? "dimmed" : void 0,
195
262
  onPointerDown: (e) => {
196
- e.target === e.currentTarget && (w.current = {
263
+ e.target === e.currentTarget && (O.current = {
197
264
  x: e.clientX,
198
265
  y: e.clientY,
199
266
  moved: !1
200
267
  }, e.currentTarget.setPointerCapture(e.pointerId));
201
268
  },
202
269
  onPointerMove: (e) => {
203
- if (!w.current) return;
204
- let t = e.currentTarget.getBoundingClientRect(), n = (e.clientX - w.current.x) / t.width * j, r = (e.clientY - w.current.y) / t.height * M;
205
- w.current = {
270
+ if (!O.current) return;
271
+ let t = $(e.currentTarget), n = (e.clientX - O.current.x) * t, r = (e.clientY - O.current.y) * t;
272
+ O.current = {
206
273
  x: e.clientX,
207
274
  y: e.clientY,
208
- moved: w.current.moved || n !== 0 || r !== 0
209
- }, C((e) => ({
275
+ moved: O.current.moved || n !== 0 || r !== 0
276
+ }, D((e) => ({
210
277
  ...e,
211
278
  x: e.x + n,
212
279
  y: e.y + r
213
280
  }));
214
281
  },
215
282
  onPointerUp: () => {
216
- w.current?.moved || (w.current = null);
283
+ O.current?.moved || (O.current = null);
217
284
  },
218
285
  onClick: (e) => {
219
- let t = w.current?.moved;
220
- w.current = null, !t && e.target === e.currentTarget && i(null);
286
+ let t = O.current?.moved;
287
+ O.current = null, !t && e.target === e.currentTarget && a(null);
221
288
  },
222
- children: [t.some((e) => e.directed) && /* @__PURE__ */ m("defs", { children: /* @__PURE__ */ m("marker", {
223
- id: d,
289
+ children: [t.some((e) => e.directed) && /* @__PURE__ */ h("defs", { children: /* @__PURE__ */ h("marker", {
290
+ id: C,
224
291
  viewBox: "0 0 10 10",
225
292
  refX: "10",
226
293
  refY: "5",
227
294
  markerWidth: "7",
228
295
  markerHeight: "7",
229
296
  orient: "auto-start-reverse",
230
- children: /* @__PURE__ */ m("path", { d: "M0,0 L10,5 L0,10 z" })
231
- }) }), /* @__PURE__ */ h("g", {
232
- transform: `translate(${S.x} ${S.y}) scale(${S.k})`,
233
- children: [t.map((e, t) => {
234
- let n = D.get(e.source), r = D.get(e.target);
235
- if (!n || !r) return null;
236
- let a = r.x ?? 0, o = r.y ?? 0;
237
- if (e.directed) {
238
- let e = a - (n.x ?? 0), t = o - (n.y ?? 0), i = Math.hypot(e, t) || 1;
239
- a -= e / i * (r.r + 2), o -= t / i * (r.r + 2);
240
- }
241
- return /* @__PURE__ */ h("g", {
242
- className: `g-e${e.dashed ? " dashed" : ""}${L(e) ? " hl" : ""}`,
243
- onClick: () => i({
244
- kind: "edge",
245
- source: e.source,
246
- target: e.target
247
- }),
248
- children: [
249
- /* @__PURE__ */ m("line", {
250
- x1: n.x,
251
- y1: n.y,
252
- x2: a,
253
- y2: o,
254
- strokeWidth: 1 + (e.weight ?? 1) * .5,
255
- markerEnd: e.directed ? `url(#${d})` : void 0
297
+ children: /* @__PURE__ */ h("path", { d: "M0,0 L10,5 L0,10 z" })
298
+ }) }), /* @__PURE__ */ g("g", {
299
+ transform: `translate(${E.x} ${E.y}) scale(${E.k})`,
300
+ children: [
301
+ R.rows?.map((e, t) => /* @__PURE__ */ g("g", {
302
+ className: "g-row",
303
+ children: [t > 0 && /* @__PURE__ */ h("line", {
304
+ x1: e.x,
305
+ x2: e.x2,
306
+ y1: e.y - B / 2 + 8,
307
+ y2: e.y - B / 2 + 8
308
+ }), /* @__PURE__ */ h("text", {
309
+ x: e.x,
310
+ y: e.y,
311
+ children: e.label
312
+ })]
313
+ }, `${e.id}\u0000${t}`)),
314
+ t.map((e, t) => {
315
+ let n = q.get(e.source), r = q.get(e.target);
316
+ if (!n || !r) return null;
317
+ let i = H(n, r, !!e.directed, !!d), o = e.directed ? `url(#${C})` : void 0;
318
+ return /* @__PURE__ */ g("g", {
319
+ className: `g-e${e.dashed ? " dashed" : ""}${te(e) ? " hl" : ""}`,
320
+ onClick: () => a({
321
+ kind: "edge",
322
+ source: e.source,
323
+ target: e.target
256
324
  }),
257
- /* @__PURE__ */ m("line", {
325
+ children: [i.d ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("path", {
326
+ d: i.d,
327
+ strokeWidth: 1 + (e.weight ?? 1) * .5,
328
+ markerEnd: o
329
+ }), /* @__PURE__ */ h("path", {
330
+ className: "hit",
331
+ d: i.hit
332
+ })] }) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("line", {
333
+ x1: i.x1,
334
+ y1: i.y1,
335
+ x2: i.x2,
336
+ y2: i.y2,
337
+ strokeWidth: 1 + (e.weight ?? 1) * .5,
338
+ markerEnd: o
339
+ }), /* @__PURE__ */ h("line", {
258
340
  className: "hit",
259
341
  x1: n.x,
260
342
  y1: n.y,
261
343
  x2: r.x,
262
344
  y2: r.y
263
- }),
264
- e.title && /* @__PURE__ */ m("title", { children: e.title })
265
- ]
266
- }, `${e.source}\u0000${e.target}\u0000${t}`);
267
- }), E.map((e) => {
268
- let t = r?.kind === "node" && r.id === e.id, n = [
269
- "g-n",
270
- `g-c${e.group ?? 1}`,
271
- e.hideLabel && "small",
272
- e.dashed && "dashed",
273
- e.muted && "muted",
274
- A.has(e.id) && "hl",
275
- t && "pin",
276
- O === e.id && "focus"
277
- ].filter(Boolean).join(" ");
278
- return /* @__PURE__ */ h("g", {
279
- className: n,
280
- tabIndex: 0,
281
- role: "button",
282
- "aria-pressed": t,
283
- "aria-label": l ? l(e) : e.label,
284
- onMouseEnter: () => g(e.id),
285
- onMouseLeave: () => g(null),
286
- onFocus: () => g(e.id),
287
- onBlur: () => g(null),
288
- onClick: () => z(e.id, t),
289
- onDoubleClick: () => s?.(e.id),
290
- onKeyDown: (n) => {
291
- n.key === "Enter" && s ? (n.preventDefault(), s(e.id)) : (n.key === "Enter" || n.key === " ") && (n.preventDefault(), z(e.id, t));
292
- },
293
- children: [
294
- /* @__PURE__ */ m("circle", {
295
- cx: e.x,
296
- cy: e.y,
297
- r: e.r
298
- }),
299
- /* @__PURE__ */ m("text", {
300
- x: e.x,
301
- y: (e.y ?? 0) + e.r + 14,
302
- children: e.label
303
- }),
304
- e.title && /* @__PURE__ */ m("title", { children: e.title })
305
- ]
306
- }, e.id);
307
- })]
345
+ })] }), e.title && /* @__PURE__ */ h("title", { children: e.title })]
346
+ }, `${e.source}\u0000${e.target}\u0000${t}`);
347
+ }),
348
+ K.map((e) => {
349
+ let t = i?.kind === "node" && i.id === e.id, n = [
350
+ "g-n",
351
+ `g-c${e.group ?? 1}`,
352
+ e.hideLabel && "small",
353
+ e.dashed && "dashed",
354
+ e.muted && "muted",
355
+ X.has(e.id) && "hl",
356
+ t && "pin",
357
+ J === e.id && "focus"
358
+ ].filter(Boolean).join(" ");
359
+ return /* @__PURE__ */ g("g", {
360
+ className: n,
361
+ tabIndex: 0,
362
+ role: "button",
363
+ "aria-pressed": t,
364
+ "aria-label": u ? u(e) : e.label,
365
+ onMouseEnter: () => T(e.id),
366
+ onMouseLeave: () => T(null),
367
+ onFocus: () => T(e.id),
368
+ onBlur: () => T(null),
369
+ onPointerDown: p ? (t) => {
370
+ t.button === 0 && (k.current = {
371
+ id: e.id,
372
+ x: t.clientX,
373
+ y: t.clientY,
374
+ moved: !1
375
+ }, t.currentTarget.setPointerCapture(t.pointerId));
376
+ } : void 0,
377
+ onPointerMove: p ? (t) => {
378
+ let n = k.current;
379
+ if (!n || n.id !== e.id || !n.moved && Math.hypot(t.clientX - n.x, t.clientY - n.y) < 4) return;
380
+ let r = j.current ? $(j.current) / E.k : 1, i = (t.clientX - n.x) * r, a = (t.clientY - n.y) * r;
381
+ k.current = {
382
+ id: e.id,
383
+ x: t.clientX,
384
+ y: t.clientY,
385
+ moved: !0
386
+ }, W((t) => {
387
+ let n = new Map(t?.of === R ? t.at : []), r = n.get(e.id) ?? {
388
+ x: e.x ?? 0,
389
+ y: e.y ?? 0
390
+ };
391
+ return n.set(e.id, {
392
+ x: r.x + i,
393
+ y: r.y + a
394
+ }), {
395
+ of: R,
396
+ at: n
397
+ };
398
+ });
399
+ } : void 0,
400
+ onPointerUp: p ? (e) => {
401
+ k.current?.moved && (A.current = e.timeStamp, setTimeout(() => {
402
+ k.current = null;
403
+ }, 0));
404
+ } : void 0,
405
+ onPointerCancel: p ? () => {
406
+ k.current = null;
407
+ } : void 0,
408
+ onClick: () => {
409
+ let n = k.current?.moved;
410
+ k.current = null, n || Q(e.id, t);
411
+ },
412
+ onDoubleClick: (t) => {
413
+ t.timeStamp - A.current > 600 && c?.(e.id);
414
+ },
415
+ onKeyDown: (n) => {
416
+ n.key === "Enter" && c ? (n.preventDefault(), c(e.id)) : (n.key === "Enter" || n.key === " ") && (n.preventDefault(), Q(e.id, t));
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ h("circle", {
420
+ cx: e.x,
421
+ cy: e.y,
422
+ r: e.r
423
+ }),
424
+ /* @__PURE__ */ h("text", {
425
+ x: e.x,
426
+ y: (e.y ?? 0) + e.r + 14,
427
+ children: e.label
428
+ }),
429
+ e.title && /* @__PURE__ */ h("title", { children: e.title })
430
+ ]
431
+ }, e.id);
432
+ })
433
+ ]
308
434
  })]
309
435
  }),
310
- c && c.length > 0 && /* @__PURE__ */ m("div", {
436
+ l && l.length > 0 && /* @__PURE__ */ h("div", {
311
437
  className: "gleg",
312
- children: c.map((e) => /* @__PURE__ */ h("span", { children: [/* @__PURE__ */ m("i", { className: `g-c${e.group}` }), e.label] }, e.group))
438
+ children: l.map((e) => /* @__PURE__ */ g("span", { children: [/* @__PURE__ */ h("i", { className: `g-c${e.group}` }), e.label] }, e.group))
313
439
  }),
314
- /* @__PURE__ */ h("div", {
440
+ /* @__PURE__ */ g("div", {
315
441
  className: "gzoom",
316
- children: [/* @__PURE__ */ m("button", {
317
- type: "button",
318
- onClick: () => R(1.3),
319
- "aria-label": u("graph.zoomIn"),
320
- children: "+"
321
- }), /* @__PURE__ */ m("button", {
322
- type: "button",
323
- onClick: () => R(1 / 1.3),
324
- "aria-label": u("graph.zoomOut"),
325
- children: "−"
326
- })]
442
+ children: [
443
+ /* @__PURE__ */ h("button", {
444
+ type: "button",
445
+ onClick: () => Z(1.3),
446
+ "aria-label": _("graph.zoomIn"),
447
+ children: "+"
448
+ }),
449
+ /* @__PURE__ */ h("button", {
450
+ type: "button",
451
+ onClick: () => Z(1 / 1.3),
452
+ "aria-label": _("graph.zoomOut"),
453
+ children: "−"
454
+ }),
455
+ G && G.size > 0 && /* @__PURE__ */ h("button", {
456
+ type: "button",
457
+ onClick: () => W(null),
458
+ "aria-label": _("graph.resetLayout"),
459
+ title: _("graph.resetLayout"),
460
+ children: /* @__PURE__ */ h(r, {
461
+ name: "reset",
462
+ size: 14
463
+ })
464
+ })
465
+ ]
327
466
  })
328
467
  ]
329
468
  });
330
469
  }
331
470
  //#endregion
332
- export { u as Avatar, D as Button, o as Empty, n as GitHubIcon, L as Graph, r as Icon, O as IconButton, c as Loading, d as Markdown, k as Menu, i as Modal, e as Switch, a as Tabs, s as ToastProvider, A as TopBar, p as UIKIT_NS, F as neighbours, l as useOutside, t as useToast };
471
+ export { u as Avatar, O as Button, o as Empty, n as GitHubIcon, U as Graph, r as Icon, k as IconButton, c as Loading, d as Markdown, A as Menu, i as Modal, e as Switch, a as Tabs, s as ToastProvider, j as TopBar, p as UIKIT_NS, I as neighbours, l as useOutside, t as useToast };
333
472
 
334
473
  //# sourceMappingURL=index.js.map