@lincyaw/aegis-ui 0.12.1 → 0.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.
Files changed (38) hide show
  1. package/dist/components/ui/CommitGraph.cjs +1 -1
  2. package/dist/components/ui/CommitGraph.cjs.map +1 -1
  3. package/dist/components/ui/CommitGraph.d.ts +23 -5
  4. package/dist/components/ui/CommitGraph.js +236 -200
  5. package/dist/components/ui/CommitGraph.js.map +1 -1
  6. package/dist/components/ui/DataTable.cjs +1 -1
  7. package/dist/components/ui/DataTable.cjs.map +1 -1
  8. package/dist/components/ui/DataTable.js +205 -207
  9. package/dist/components/ui/DataTable.js.map +1 -1
  10. package/dist/components/ui/DetailBeside.cjs +2 -0
  11. package/dist/components/ui/DetailBeside.cjs.map +1 -0
  12. package/dist/components/ui/DetailBeside.d.ts +59 -0
  13. package/dist/components/ui/DetailBeside.js +117 -0
  14. package/dist/components/ui/DetailBeside.js.map +1 -0
  15. package/dist/components/ui/FileTree.cjs +1 -1
  16. package/dist/components/ui/FileTree.cjs.map +1 -1
  17. package/dist/components/ui/FileTree.js +118 -111
  18. package/dist/components/ui/FileTree.js.map +1 -1
  19. package/dist/components/ui/ServiceMap.cjs +1 -1
  20. package/dist/components/ui/ServiceMap.cjs.map +1 -1
  21. package/dist/components/ui/ServiceMap.js +320 -271
  22. package/dist/components/ui/ServiceMap.js.map +1 -1
  23. package/dist/components/ui/TraceTree.cjs +1 -1
  24. package/dist/components/ui/TraceTree.cjs.map +1 -1
  25. package/dist/components/ui/TraceTree.d.ts +2 -1
  26. package/dist/components/ui/TraceTree.js +182 -178
  27. package/dist/components/ui/TraceTree.js.map +1 -1
  28. package/dist/components/ui/index.d.ts +3 -1
  29. package/dist/components/ui/selectedRowDetail.cjs +2 -0
  30. package/dist/components/ui/selectedRowDetail.cjs.map +1 -0
  31. package/dist/components/ui/selectedRowDetail.d.ts +25 -0
  32. package/dist/components/ui/selectedRowDetail.js +8 -0
  33. package/dist/components/ui/selectedRowDetail.js.map +1 -0
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.js +259 -257
  36. package/dist/index.js.map +1 -1
  37. package/dist/style.css +1 -1
  38. package/package.json +1 -1
@@ -1,77 +1,79 @@
1
- import { jsx as u, jsxs as P, Fragment as ne } from "react/jsx-runtime";
2
- import { useId as K, useState as re, useMemo as $, useCallback as I, useEffect as ce } from "react";
3
- import { graphlib as le, layout as de } from "@dagrejs/dagre";
4
- import { ReactFlowProvider as ge, Position as D, useReactFlow as Z, ReactFlow as pe, Background as ue, BackgroundVariant as me, Controls as fe, MiniMap as he, useStoreApi as ve, useStore as be, getViewportForBounds as W, Handle as Y } from "@xyflow/react";
5
- import { useMediaQuery as _e } from "../../hooks/useMediaQuery.js";
1
+ import { jsx as u, jsxs as H, Fragment as me } from "react/jsx-runtime";
2
+ import { useId as ne, useState as Y, useMemo as D, useCallback as z, useContext as fe, useEffect as he } from "react";
3
+ import { graphlib as ve, layout as be } from "@dagrejs/dagre";
4
+ import { ReactFlowProvider as _e, Position as A, useReactFlow as Q, ReactFlow as we, Background as ye, BackgroundVariant as xe, Controls as Se, MiniMap as Ne, useStoreApi as Me, useStore as X, getViewportForBounds as te, Handle as oe, useInternalNode as Ee } from "@xyflow/react";
5
+ import { useIsomorphicLayoutEffect as J } from "../../hooks/useIsomorphicLayoutEffect.js";
6
+ import { useMediaQuery as Re } from "../../hooks/useMediaQuery.js";
6
7
  /* empty css */
7
- import { StatusDot as we } from "./StatusDot.js";
8
- import { useStrings as ye } from "../../locale/useStrings.js";
9
- const C = 180, V = 64, xe = 320, Q = 28, Se = 64, Ne = {
10
- "--aegis-service-map-node-w": `${String(C)}px`,
11
- "--aegis-service-map-node-h": `${String(V)}px`,
12
- "--aegis-service-map-node-max-w": `${String(xe)}px`,
13
- "--aegis-service-map-group-label-h": `${String(Q)}px`
14
- }, Me = { width: C, height: V };
15
- function Ee(e, i, r, s) {
16
- const n = e.map((o) => o.id), p = new Set(n);
8
+ import { StatusDot as Oe } from "./StatusDot.js";
9
+ import { SelectedRowDetailContext as Le } from "./selectedRowDetail.js";
10
+ import { useStrings as Te } from "../../locale/useStrings.js";
11
+ const q = 180, ee = 64, $e = 320, ae = 28, De = 64, Ae = {
12
+ "--aegis-service-map-node-w": `${String(q)}px`,
13
+ "--aegis-service-map-node-h": `${String(ee)}px`,
14
+ "--aegis-service-map-node-max-w": `${String($e)}px`,
15
+ "--aegis-service-map-group-label-h": `${String(ae)}px`
16
+ }, He = { width: q, height: ee };
17
+ function Ie(e, n, i, a) {
18
+ const r = e.map((o) => o.id), p = new Set(r);
17
19
  return {
18
- direction: s,
19
- ids: n,
20
- links: i.filter((o) => p.has(o.source) && p.has(o.target)).map((o) => [o.source, o.target]),
21
- groups: r
20
+ direction: a,
21
+ ids: r,
22
+ links: n.filter((o) => p.has(o.source) && p.has(o.target)).map((o) => [o.source, o.target]),
23
+ groups: i
22
24
  };
23
25
  }
24
- function Oe(e, i) {
25
- const r = new Set(e), s = /* @__PURE__ */ new Set(), n = i.map((o) => {
26
+ function Pe(e, n) {
27
+ const i = new Set(e), a = /* @__PURE__ */ new Set(), r = n.map((o) => {
26
28
  const l = [...new Set(o.nodeIds)].filter(
27
- (a) => r.has(a) && !s.has(a)
29
+ (s) => i.has(s) && !a.has(s)
28
30
  );
29
- return l.forEach((a) => s.add(a)), { group: o, ids: l };
30
- }), p = e.filter((o) => !s.has(o));
31
- return [...n, { ids: p }].filter((o) => o.ids.length > 0);
31
+ return l.forEach((s) => a.add(s)), { group: o, ids: l };
32
+ }), p = e.filter((o) => !a.has(o));
33
+ return [...r, { ids: p }].filter((o) => o.ids.length > 0);
32
34
  }
33
- function Re(e, i, r, s) {
34
- const n = new le.Graph();
35
- n.setDefaultEdgeLabel(() => ({})), n.setGraph({
36
- rankdir: r,
35
+ function Fe(e, n, i, a) {
36
+ const r = new ve.Graph();
37
+ r.setDefaultEdgeLabel(() => ({})), r.setGraph({
38
+ rankdir: i,
37
39
  nodesep: 40,
38
40
  ranksep: 80,
39
41
  marginx: 16,
40
42
  marginy: 16
41
43
  });
42
- for (const a of e)
43
- n.setNode(a, { ...s(a) });
44
- for (const [a, t] of i)
45
- n.hasNode(a) && n.hasNode(t) && n.setEdge(a, t);
46
- de(n);
44
+ for (const s of e)
45
+ r.setNode(s, { ...a(s) });
46
+ for (const [s, t] of n)
47
+ r.hasNode(s) && r.hasNode(t) && r.setEdge(s, t);
48
+ be(r);
47
49
  const p = new Map(
48
- e.map((a) => {
49
- const { x: t = 0, y: g = 0 } = n.node(a), m = s(a);
50
- return [a, { x: t - m.width / 2, y: g - m.height / 2 }];
50
+ e.map((s) => {
51
+ const { x: t = 0, y: d = 0 } = r.node(s), m = a(s);
52
+ return [s, { x: t - m.width / 2, y: d - m.height / 2 }];
51
53
  })
52
- ), { width: o = 0, height: l = 0 } = n.graph();
54
+ ), { width: o = 0, height: l = 0 } = r.graph();
53
55
  return { positions: p, width: o, height: l };
54
56
  }
55
- function Le(e, i, r) {
56
- const s = (t) => `${r}-group-${String(e.groups.indexOf(t))}`, n = e.direction === "LR", p = Oe(e.ids, e.groups).map((t) => {
57
- const g = Re(t.ids, e.links, e.direction, (v) => i.get(v) ?? Me), m = t.group === void 0 ? 0 : Q;
57
+ function ze(e, n, i) {
58
+ const a = (t) => `${i}-group-${String(e.groups.indexOf(t))}`, r = e.direction === "LR", p = Pe(e.ids, e.groups).map((t) => {
59
+ const d = Fe(t.ids, e.links, e.direction, (f) => n.get(f) ?? He), m = t.group === void 0 ? 0 : ae;
58
60
  return {
59
61
  ...t,
60
- ...g,
62
+ ...d,
61
63
  labelHeight: m,
62
- boxHeight: g.height + m
64
+ boxHeight: d.height + m
63
65
  };
64
66
  }), o = Math.max(
65
67
  0,
66
- ...p.map((t) => n ? t.boxHeight : t.width)
68
+ ...p.map((t) => r ? t.boxHeight : t.width)
67
69
  );
68
70
  let l = 0;
69
- const a = p.map((t) => {
70
- const g = n ? { x: l, y: (o - t.boxHeight) / 2 } : { x: (o - t.width) / 2, y: l };
71
- return l += (n ? t.width : t.boxHeight) + Se, { ...t, origin: g };
71
+ const s = p.map((t) => {
72
+ const d = r ? { x: l, y: (o - t.boxHeight) / 2 } : { x: (o - t.width) / 2, y: l };
73
+ return l += (r ? t.width : t.boxHeight) + De, { ...t, origin: d };
72
74
  });
73
75
  return {
74
- groups: a.flatMap(
76
+ groups: s.flatMap(
75
77
  (t) => t.group === void 0 ? [] : [
76
78
  {
77
79
  // Prefixed, so a group may share an id with a node.
@@ -82,7 +84,7 @@ function Le(e, i, r) {
82
84
  height: t.boxHeight,
83
85
  data: {
84
86
  label: t.group.label,
85
- labelId: s(t.group)
87
+ labelId: a(t.group)
86
88
  },
87
89
  // Not a group for assistive technology: the box contains no
88
90
  // nodes in the DOM, so its label is plain text, which its
@@ -105,9 +107,9 @@ function Le(e, i, r) {
105
107
  ]
106
108
  ),
107
109
  positions: new Map(
108
- a.flatMap(
109
- (t) => [...t.positions].map(([g, m]) => [
110
- g,
110
+ s.flatMap(
111
+ (t) => [...t.positions].map(([d, m]) => [
112
+ d,
111
113
  {
112
114
  x: t.origin.x + m.x,
113
115
  y: t.origin.y + t.labelHeight + m.y
@@ -116,71 +118,71 @@ function Le(e, i, r) {
116
118
  )
117
119
  ),
118
120
  groupLabels: new Map(
119
- a.flatMap((t) => {
120
- const { group: g } = t;
121
- return g === void 0 ? [] : t.ids.map((m) => [m, s(g)]);
121
+ s.flatMap((t) => {
122
+ const { group: d } = t;
123
+ return d === void 0 ? [] : t.ids.map((m) => [m, a(d)]);
122
124
  })
123
125
  )
124
126
  };
125
127
  }
126
- function $e({
128
+ function Be({
127
129
  data: e
128
130
  }) {
129
131
  return /* @__PURE__ */ u("div", { className: "aegis-service-map__group", children: /* @__PURE__ */ u("span", { id: e.labelId, className: "aegis-service-map__group-label", children: e.label }) });
130
132
  }
131
- const De = {
133
+ const Ge = {
132
134
  ok: "ink",
133
135
  active: "ink",
134
136
  warn: "caution",
135
137
  error: "warning",
136
138
  muted: "muted"
137
139
  };
138
- function Te({
140
+ function ke({
139
141
  data: e
140
142
  }) {
141
- const { node: i, selected: r } = e, s = i.status ?? "ok", n = De[s];
142
- return /* @__PURE__ */ P(
143
+ const { node: n, selected: i } = e, a = n.status ?? "ok", r = Ge[a];
144
+ return /* @__PURE__ */ H(
143
145
  "div",
144
146
  {
145
147
  className: [
146
148
  "aegis-service-map__node",
147
- `aegis-service-map__node--${s}`,
148
- r ? "aegis-service-map__node--selected" : ""
149
+ `aegis-service-map__node--${a}`,
150
+ i ? "aegis-service-map__node--selected" : ""
149
151
  ].filter(Boolean).join(" "),
150
152
  children: [
151
153
  /* @__PURE__ */ u(
152
- Y,
154
+ oe,
153
155
  {
154
156
  type: "target",
155
- position: D.Left,
157
+ position: A.Left,
156
158
  className: "aegis-service-map__handle"
157
159
  }
158
160
  ),
159
- /* @__PURE__ */ P("div", { className: "aegis-service-map__node-body", children: [
160
- /* @__PURE__ */ P("div", { className: "aegis-service-map__node-label", children: [
161
+ /* @__PURE__ */ H("div", { className: "aegis-service-map__node-body", children: [
162
+ /* @__PURE__ */ H("div", { className: "aegis-service-map__node-label", children: [
161
163
  /* @__PURE__ */ u(
162
- we,
164
+ Oe,
163
165
  {
164
- pulse: s === "active",
165
- tone: r && n === "ink" ? "inverted" : n
166
+ pulse: a === "active",
167
+ tone: i && r === "ink" ? "inverted" : r
166
168
  }
167
169
  ),
168
- /* @__PURE__ */ u("span", { className: "aegis-service-map__node-label-text", children: i.label })
170
+ /* @__PURE__ */ u("span", { className: "aegis-service-map__node-label-text", children: n.label })
169
171
  ] }),
170
- i.sublabel !== void 0 && /* @__PURE__ */ u("div", { className: "aegis-service-map__node-sublabel", children: i.sublabel })
172
+ n.sublabel !== void 0 && /* @__PURE__ */ u("div", { className: "aegis-service-map__node-sublabel", children: n.sublabel })
171
173
  ] }),
172
- i.badge !== void 0 && i.badge !== "" && /* @__PURE__ */ u(
174
+ n.badge !== void 0 && n.badge !== "" && /* @__PURE__ */ u(
173
175
  "span",
174
176
  {
175
- className: `aegis-service-map__node-badge aegis-service-map__node-badge--${s}`,
176
- children: i.badge
177
+ className: `aegis-service-map__node-badge aegis-service-map__node-badge--${a}`,
178
+ children: n.badge
177
179
  }
178
180
  ),
179
181
  /* @__PURE__ */ u(
180
- Y,
182
+ oe,
181
183
  {
182
184
  type: "source",
183
- position: D.Right,
185
+ position: A.Right,
184
186
  className: "aegis-service-map__handle"
185
187
  }
186
188
  )
@@ -188,324 +190,371 @@ function Te({
188
190
  }
189
191
  );
190
192
  }
191
- function Ae(e) {
192
- const { sourceX: i, sourceY: r, targetX: s, targetY: n, label: p, markerEnd: o, style: l } = e, a = K(), t = (i + s) / 2, g = `M${i},${r} C${t},${r} ${t},${n} ${s},${n}`;
193
- return /* @__PURE__ */ P(ne, { children: [
194
- /* @__PURE__ */ u("path", { d: g, className: "aegis-service-map__edge-focus", fill: "none" }),
193
+ function Ce(e) {
194
+ const { sourceX: n, sourceY: i, targetX: a, targetY: r, label: p, markerEnd: o, style: l } = e, s = ne(), t = (n + a) / 2, d = `M${n},${i} C${t},${i} ${t},${r} ${a},${r}`;
195
+ return /* @__PURE__ */ H(me, { children: [
196
+ /* @__PURE__ */ u("path", { d, className: "aegis-service-map__edge-focus", fill: "none" }),
195
197
  /* @__PURE__ */ u(
196
198
  "path",
197
199
  {
198
- id: a,
199
- d: g,
200
+ id: s,
201
+ d,
200
202
  className: "aegis-service-map__edge-path",
201
203
  markerEnd: o,
202
204
  style: l,
203
205
  fill: "none"
204
206
  }
205
207
  ),
206
- p !== void 0 && p !== "" && /* @__PURE__ */ u("text", { className: "aegis-service-map__edge-label", children: /* @__PURE__ */ u("textPath", { href: `#${a}`, startOffset: "50%", textAnchor: "middle", children: p }) })
208
+ p !== void 0 && p !== "" && /* @__PURE__ */ u("text", { className: "aegis-service-map__edge-label", children: /* @__PURE__ */ u("textPath", { href: `#${s}`, startOffset: "50%", textAnchor: "middle", children: p }) })
207
209
  ] });
208
210
  }
209
- const He = { service: Te, serviceGroup: $e }, Ie = { service: Ae }, Pe = "(max-width: 768px)", O = 24, k = 0.1, F = 1, X = 11 / 13, z = 15, J = 28, q = 200, B = (e) => `${e}px`;
210
- function Fe(e, i) {
211
+ const Ze = { service: ke, serviceGroup: Be }, Ve = { service: Ce }, je = "(max-width: 768px)", E = 24, K = 0.1, Z = 1, ie = 11 / 13, W = 15, se = 28, re = 200, V = (e) => `${e}px`;
212
+ function Ue(e, n) {
211
213
  return [
212
214
  .../* @__PURE__ */ new Set([
213
215
  e,
214
- ...i.filter(([r]) => r === e).map(([, r]) => r),
215
- ...i.filter(([, r]) => r === e).map(([r]) => r)
216
+ ...n.filter(([i]) => i === e).map(([, i]) => i),
217
+ ...n.filter(([, i]) => i === e).map(([i]) => i)
216
218
  ])
217
219
  ];
218
220
  }
219
- function Be(e) {
221
+ function We(e) {
220
222
  return e.type === "serviceGroup" ? "aegis-service-map__minimap-group" : "";
221
223
  }
222
- function Ge(e, i, r, s, n, p) {
223
- const { fitView: o, getNodes: l, getNodesBounds: a, setViewport: t } = Z(), g = ve(), m = be((f) => f.width > 0 && f.height > 0), v = $(
224
- () => s !== void 0 && e.ids.includes(s) ? { id: s, near: Fe(s, e.links) } : void 0,
225
- [s, e]
226
- );
227
- ce(() => {
228
- if (m && r) {
229
- const f = {
230
- top: B(O),
231
- bottom: B(O),
232
- left: B(z + J + O),
233
- right: B(
234
- n ? z + q + O : O
224
+ function Ye(e, n, i, a, r, p) {
225
+ const { fitView: o, getNodes: l, getNodesBounds: s, setViewport: t } = Q(), d = Me(), m = X((b) => b.width > 0 && b.height > 0), f = D(
226
+ () => a !== void 0 && e.ids.includes(a) ? { id: a, near: Ue(a, e.links) } : void 0,
227
+ [a, e]
228
+ ), [x, I] = Y();
229
+ return he(() => {
230
+ if (m && i) {
231
+ const b = () => {
232
+ I(f?.id ?? null);
233
+ }, _ = {
234
+ top: V(E),
235
+ bottom: V(E),
236
+ left: V(W + se + E),
237
+ right: V(
238
+ r ? W + re + E : E
235
239
  )
236
- }, { width: N, height: M } = g.getState();
237
- if (v === void 0) {
238
- const b = l(), _ = a(b), E = W(
239
- _,
240
+ }, { width: S, height: y } = d.getState();
241
+ if (f === void 0) {
242
+ const R = l(), N = s(R), O = te(
240
243
  N,
241
- M,
242
- k,
244
+ S,
245
+ y,
246
+ K,
243
247
  1,
244
- f
248
+ _
245
249
  );
246
- if (p && E.zoom < X) {
247
- const x = X, T = e.direction === "LR", R = (y) => T ? y.position.x : y.position.y, w = b.filter((y) => y.type === "service").reduce((y, H) => R(H) < R(y) ? H : y), { width: A = C, height: G = V } = w.measured ?? {};
250
+ if (p && O.zoom < ie) {
251
+ const v = ie, L = e.direction === "LR", B = (w) => L ? w.position.x : w.position.y, P = R.filter((w) => w.type === "service").reduce((w, F) => B(F) < B(w) ? F : w), { width: G = q, height: j = ee } = P.measured ?? {};
248
252
  t(
249
- T ? {
250
- x: z + J + O - _.x * x,
251
- y: M / 2 - (w.position.y + G / 2) * x,
252
- zoom: x
253
+ L ? {
254
+ x: W + se + E - N.x * v,
255
+ y: y / 2 - (P.position.y + j / 2) * v,
256
+ zoom: v
253
257
  } : {
254
- x: N / 2 - (w.position.x + A / 2) * x,
255
- y: O - _.y * x,
256
- zoom: x
258
+ x: S / 2 - (P.position.x + G / 2) * v,
259
+ y: E - N.y * v,
260
+ zoom: v
257
261
  }
258
- );
262
+ ).then(b);
259
263
  } else
260
- o({ maxZoom: 1, padding: f });
264
+ o({ maxZoom: 1, padding: _ }).then(b);
261
265
  } else {
262
- const b = W(
263
- a(v.near),
264
- N,
265
- M,
266
- k,
267
- F,
268
- f
269
- ).zoom >= F;
266
+ const R = te(
267
+ s(f.near),
268
+ S,
269
+ y,
270
+ K,
271
+ Z,
272
+ _
273
+ ).zoom >= Z;
270
274
  o({
271
- nodes: (b ? v.near : [v.id]).map((_) => ({ id: _ })),
272
- minZoom: F,
273
- maxZoom: F,
274
- padding: f
275
- });
275
+ nodes: (R ? f.near : [f.id]).map((N) => ({ id: N })),
276
+ minZoom: Z,
277
+ maxZoom: Z,
278
+ padding: _
279
+ }).then(b);
276
280
  }
277
281
  }
278
282
  }, [
279
283
  m,
280
- r,
281
284
  i,
282
- v,
283
285
  n,
286
+ f,
287
+ r,
284
288
  p,
285
289
  e.direction,
286
- g,
290
+ d,
287
291
  o,
288
292
  l,
289
- a,
293
+ s,
290
294
  t
291
- ]);
295
+ ]), x === (f?.id ?? null);
296
+ }
297
+ function Xe({
298
+ nodeId: e,
299
+ fitted: n,
300
+ selection: i
301
+ }) {
302
+ const a = X((d) => d.transform), r = X((d) => d.domNode), p = Ee(e);
303
+ J(
304
+ () => () => {
305
+ i.placeRow(null);
306
+ },
307
+ [i]
308
+ ), J(() => {
309
+ const d = r?.querySelector(
310
+ `.react-flow__node[data-id="${CSS.escape(e)}"]`
311
+ );
312
+ n && d instanceof HTMLElement && i.placeRow(d);
313
+ }, [i, r, e, a, n]);
314
+ const o = p?.measured.height;
315
+ if (i.inline === null || p === void 0 || o === void 0)
316
+ return null;
317
+ const [, l, s] = a, t = (p.internals.positionAbsolute.y + o) * s + l;
318
+ return /* @__PURE__ */ u(
319
+ "div",
320
+ {
321
+ className: "aegis-service-map__detail",
322
+ style: { marginTop: Math.max(t, 0) },
323
+ children: i.inline
324
+ }
325
+ );
292
326
  }
293
- function ze() {
294
- const { getViewport: e, setViewport: i } = Z();
295
- return I(
296
- (r) => {
297
- const s = r.target;
298
- if (!(s instanceof Element) || !s.matches(
327
+ function Je() {
328
+ const { getViewport: e, setViewport: n } = Q();
329
+ return z(
330
+ (i) => {
331
+ const a = i.target;
332
+ if (!(a instanceof Element) || !a.matches(
299
333
  ".react-flow__node:focus-visible, .react-flow__edge:focus-visible"
300
334
  ))
301
335
  return;
302
- const { scrollLeft: n, scrollTop: p } = r.currentTarget, o = r.currentTarget.getBoundingClientRect(), l = s.getBoundingClientRect(), a = l.left - o.left + n, t = l.top - o.top + p;
303
- if (a >= 0 && t >= 0 && a + l.width <= o.width && t + l.height <= o.height)
336
+ const { scrollLeft: r, scrollTop: p } = i.currentTarget, o = i.currentTarget.getBoundingClientRect(), l = a.getBoundingClientRect(), s = l.left - o.left + r, t = l.top - o.top + p;
337
+ if (s >= 0 && t >= 0 && s + l.width <= o.width && t + l.height <= o.height)
304
338
  return;
305
- const { x: g, y: m, zoom: v } = e();
306
- i({
307
- x: g + o.width / 2 - (a + l.width / 2),
339
+ const { x: d, y: m, zoom: f } = e();
340
+ n({
341
+ x: d + o.width / 2 - (s + l.width / 2),
308
342
  y: m + o.height / 2 - (t + l.height / 2),
309
- zoom: v
343
+ zoom: f
310
344
  });
311
345
  },
312
- [e, i]
346
+ [e, n]
313
347
  );
314
348
  }
315
- function ke({
349
+ function Ke({
316
350
  nodes: e,
317
- edges: i,
318
- groups: r = [],
319
- direction: s = "LR",
320
- height: n,
351
+ edges: n,
352
+ groups: i = [],
353
+ direction: a = "LR",
354
+ height: r,
321
355
  fillViewport: p = !1,
322
356
  onNodeClick: o,
323
357
  onEdgeClick: l,
324
- selectedNodeId: a,
358
+ selectedNodeId: s,
325
359
  focusNodeId: t,
326
- minimap: g = t === void 0,
360
+ minimap: d = t === void 0,
327
361
  ariaLabel: m,
328
- className: v
362
+ className: f
329
363
  }) {
330
- const f = ye(), N = K(), M = `aegis-service-map${N.replace(/:/g, "-")}`, b = o !== void 0, _ = l !== void 0, [E, x] = re(
364
+ const x = Te(), I = ne(), b = `aegis-service-map${I.replace(/:/g, "-")}`, _ = o !== void 0, S = l !== void 0, [y, R] = Y(
331
365
  () => /* @__PURE__ */ new Map()
332
- ), T = $(
333
- () => JSON.stringify(Ee(e, i, r, s)),
334
- [e, i, r, s]
335
- ), R = $(() => JSON.parse(T), [T]), w = $(
336
- () => Le(R, E, N),
337
- [R, E, N]
338
- ), A = s === "LR", G = $(
366
+ ), N = D(
367
+ () => JSON.stringify(Ie(e, n, i, a)),
368
+ [e, n, i, a]
369
+ ), O = D(() => JSON.parse(N), [N]), v = D(
370
+ () => ze(O, y, I),
371
+ [O, y, I]
372
+ ), L = a === "LR", B = D(
339
373
  () => [
340
- ...w.groups,
341
- ...e.map((d) => {
374
+ ...v.groups,
375
+ ...e.map((g) => {
342
376
  const c = [
343
- w.groupLabels.get(d.id),
344
- b ? `react-flow__node-desc-${M}` : void 0
377
+ v.groupLabels.get(g.id),
378
+ _ ? `react-flow__node-desc-${b}` : void 0
345
379
  ].filter(Boolean).join(" ");
346
380
  return {
347
- id: d.id,
381
+ id: g.id,
348
382
  type: "service",
349
- position: w.positions.get(d.id) ?? { x: 0, y: 0 },
383
+ position: v.positions.get(g.id) ?? { x: 0, y: 0 },
350
384
  // Handed back as applyNodeChanges would, so React Flow keeps the
351
385
  // size it measured instead of measuring the node again.
352
- measured: E.get(d.id),
353
- ariaLabel: d.label,
386
+ measured: y.get(g.id),
387
+ ariaLabel: g.label,
354
388
  // React Flow gives only a focusable node a role, and the role
355
389
  // description below needs one.
356
390
  ariaRole: "group",
357
391
  domAttributes: {
358
- "aria-roledescription": f.serviceMapNodeRole,
392
+ "aria-roledescription": x.serviceMapNodeRole,
359
393
  // A group takes no aria-selected.
360
- "aria-current": a === d.id ? !0 : void 0,
394
+ "aria-current": s === g.id ? !0 : void 0,
361
395
  "aria-describedby": c === "" ? void 0 : c
362
396
  },
363
- data: { node: d, selected: a === d.id },
364
- sourcePosition: A ? D.Right : D.Bottom,
365
- targetPosition: A ? D.Left : D.Top,
397
+ data: { node: g, selected: s === g.id },
398
+ sourcePosition: L ? A.Right : A.Bottom,
399
+ targetPosition: L ? A.Left : A.Top,
366
400
  draggable: !1,
367
401
  connectable: !1,
368
- selectable: b,
369
- focusable: b
402
+ selectable: _,
403
+ focusable: _
370
404
  };
371
405
  })
372
406
  ],
373
407
  [
374
- w,
408
+ v,
375
409
  e,
376
- E,
377
- a,
378
- A,
410
+ y,
411
+ s,
412
+ L,
413
+ _,
379
414
  b,
380
- M,
381
- f
415
+ x
382
416
  ]
383
- ), y = $(() => {
384
- const d = new Map(e.map((c) => [c.id, c.label]));
385
- return i.map((c) => ({
417
+ ), P = D(() => {
418
+ const g = new Map(e.map((c) => [c.id, c.label]));
419
+ return n.map((c) => ({
386
420
  id: c.id,
387
421
  source: c.source,
388
422
  target: c.target,
389
- ariaLabel: f.serviceMapEdgeName(
390
- d.get(c.source) ?? c.source,
391
- d.get(c.target) ?? c.target
423
+ ariaLabel: x.serviceMapEdgeName(
424
+ g.get(c.source) ?? c.source,
425
+ g.get(c.target) ?? c.target
392
426
  ),
393
427
  // React Flow makes an unfocusable edge an img; aria-roledescription needs a group.
394
428
  ariaRole: "group",
395
- domAttributes: { "aria-roledescription": f.serviceMapEdgeRole },
429
+ domAttributes: { "aria-roledescription": x.serviceMapEdgeRole },
396
430
  type: "service",
397
431
  data: { edge: c },
398
432
  label: c.label,
399
- selectable: _,
400
- focusable: _,
433
+ selectable: S,
434
+ focusable: S,
401
435
  className: `aegis-service-map__edge aegis-service-map__edge--${c.status ?? "ok"}`
402
436
  }));
403
- }, [e, i, _, f]), { getNode: H } = Z(), ee = I(
404
- (d) => {
405
- const c = d.flatMap(
406
- (h) => h.type === "dimensions" && h.dimensions !== void 0 && H(h.id)?.type === "service" ? [[h.id, h.dimensions]] : []
437
+ }, [e, n, S, x]), { getNode: G } = Q(), j = z(
438
+ (g) => {
439
+ const c = g.flatMap(
440
+ (h) => h.type === "dimensions" && h.dimensions !== void 0 && G(h.id)?.type === "service" ? [[h.id, h.dimensions]] : []
407
441
  );
408
- x(
442
+ R(
409
443
  (h) => c.every(
410
- ([S, L]) => h.get(S)?.width === L.width && h.get(S)?.height === L.height
444
+ ([M, $]) => h.get(M)?.width === $.width && h.get(M)?.height === $.height
411
445
  ) ? h : new Map([...h, ...c])
412
446
  );
413
447
  },
414
- [H]
415
- ), j = _e(Pe), U = g && !j;
416
- Ge(
417
- R,
418
- w,
419
- e.every((d) => E.has(d.id)),
448
+ [G]
449
+ ), w = Re(je), F = d && !w, T = fe(Le), k = Ye(
450
+ O,
451
+ v,
452
+ e.every((g) => y.has(g.id)),
420
453
  t,
421
- U,
422
- j
423
- );
424
- const te = ze(), oe = I(
425
- (d, c) => {
454
+ F,
455
+ w
456
+ ), C = s !== void 0 && O.ids.includes(s) ? s : void 0, [U, ce] = Y();
457
+ k && U !== C && ce(C), J(() => {
458
+ if (!(T === null || C === void 0 || k))
459
+ return T.awaitRow(), () => {
460
+ T.placeRow(null);
461
+ };
462
+ }, [T, C, k]);
463
+ const le = Je(), de = z(
464
+ (g, c) => {
426
465
  c.type === "service" && o?.(c.data.node);
427
466
  },
428
467
  [o]
429
- ), ie = I(
430
- (d, c) => {
468
+ ), pe = z(
469
+ (g, c) => {
431
470
  c.data && l?.(c.data.edge);
432
471
  },
433
472
  [l]
434
- ), se = I(
435
- (d) => {
436
- if (d.key !== "Enter" && d.key !== " " || d.repeat)
473
+ ), ge = z(
474
+ (g) => {
475
+ if (g.key !== "Enter" && g.key !== " " || g.repeat)
437
476
  return;
438
- const c = d.target;
477
+ const c = g.target;
439
478
  if (!(c instanceof Element))
440
479
  return;
441
480
  const h = c.getAttribute("data-id");
442
481
  if (c.classList.contains("react-flow__node")) {
443
- const S = e.find((L) => L.id === h);
444
- S && o && (d.preventDefault(), o(S));
482
+ const M = e.find(($) => $.id === h);
483
+ M && o && (g.preventDefault(), o(M));
445
484
  } else if (c.classList.contains("react-flow__edge")) {
446
- const S = i.find((L) => L.id === h);
447
- S && l && (d.preventDefault(), l(S));
485
+ const M = n.find(($) => $.id === h);
486
+ M && l && (g.preventDefault(), l(M));
448
487
  }
449
488
  },
450
- [e, i, o, l]
451
- ), ae = {
452
- ...Ne,
453
- height: n === void 0 ? void 0 : `${String(n)}px`
489
+ [e, n, o, l]
490
+ ), ue = {
491
+ ...Ae,
492
+ height: r === void 0 ? void 0 : `${String(r)}px`
454
493
  };
455
- return /* @__PURE__ */ u(
494
+ return /* @__PURE__ */ H(
456
495
  "div",
457
496
  {
458
497
  className: [
459
498
  "aegis-service-map",
460
499
  p ? "aegis-service-map--fill-viewport" : "",
461
- v
500
+ f
462
501
  ].filter(Boolean).join(" "),
463
- style: ae,
464
- children: /* @__PURE__ */ u("div", { className: "aegis-service-map__pane", children: /* @__PURE__ */ P(
465
- pe,
466
- {
467
- id: M,
468
- "aria-label": m,
469
- nodes: G,
470
- edges: y,
471
- nodeTypes: He,
472
- edgeTypes: Ie,
473
- minZoom: k,
474
- nodesDraggable: !1,
475
- nodesConnectable: !1,
476
- autoPanOnNodeFocus: !1,
477
- panOnDrag: !0,
478
- zoomOnScroll: !0,
479
- proOptions: { hideAttribution: !0 },
480
- ariaLabelConfig: f.serviceMapAriaLabels,
481
- onNodesChange: ee,
482
- onNodeClick: b ? oe : void 0,
483
- onEdgeClick: _ ? ie : void 0,
484
- onKeyDown: se,
485
- onFocus: te,
486
- children: [
487
- /* @__PURE__ */ u(ue, { variant: me.Dots, gap: 16, size: 1 }),
488
- /* @__PURE__ */ u(fe, { showInteractive: !1, position: "top-left" }),
489
- U && /* @__PURE__ */ u(
490
- he,
491
- {
492
- pannable: !0,
493
- zoomable: !0,
494
- position: "bottom-right",
495
- style: { width: q },
496
- nodeClassName: Be
497
- }
498
- )
499
- ]
500
- }
501
- ) })
502
+ style: ue,
503
+ children: [
504
+ /* @__PURE__ */ u("div", { className: "aegis-service-map__pane", children: /* @__PURE__ */ H(
505
+ we,
506
+ {
507
+ id: b,
508
+ "aria-label": m,
509
+ nodes: B,
510
+ edges: P,
511
+ nodeTypes: Ze,
512
+ edgeTypes: Ve,
513
+ minZoom: K,
514
+ nodesDraggable: !1,
515
+ nodesConnectable: !1,
516
+ autoPanOnNodeFocus: !1,
517
+ panOnDrag: !0,
518
+ zoomOnScroll: !0,
519
+ proOptions: { hideAttribution: !0 },
520
+ ariaLabelConfig: x.serviceMapAriaLabels,
521
+ onNodesChange: j,
522
+ onNodeClick: _ ? de : void 0,
523
+ onEdgeClick: S ? pe : void 0,
524
+ onKeyDown: ge,
525
+ onFocus: le,
526
+ children: [
527
+ /* @__PURE__ */ u(ye, { variant: xe.Dots, gap: 16, size: 1 }),
528
+ /* @__PURE__ */ u(Se, { showInteractive: !1, position: "top-left" }),
529
+ F && /* @__PURE__ */ u(
530
+ Ne,
531
+ {
532
+ pannable: !0,
533
+ zoomable: !0,
534
+ position: "bottom-right",
535
+ style: { width: re },
536
+ nodeClassName: We
537
+ }
538
+ )
539
+ ]
540
+ }
541
+ ) }),
542
+ T !== null && U !== void 0 && /* @__PURE__ */ u(
543
+ Xe,
544
+ {
545
+ nodeId: U,
546
+ fitted: k,
547
+ selection: T
548
+ }
549
+ )
550
+ ]
502
551
  }
503
552
  );
504
553
  }
505
- function Je(e) {
506
- return /* @__PURE__ */ u(ge, { children: /* @__PURE__ */ u(ke, { ...e }) });
554
+ function ct(e) {
555
+ return /* @__PURE__ */ u(_e, { children: /* @__PURE__ */ u(Ke, { ...e }) });
507
556
  }
508
557
  export {
509
- Je as ServiceMap
558
+ ct as ServiceMap
510
559
  };
511
560
  //# sourceMappingURL=ServiceMap.js.map