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