@floegence/floe-webapp-core 0.101.23 → 0.101.29

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,88 @@
1
+ const u = (a, i, p) => a + (i - a) * p, l = (a, i, p) => ({
2
+ x: u(a.x, i.x, p),
3
+ y: u(a.y, i.y, p)
4
+ });
5
+ function v(a) {
6
+ const i = a.map(
7
+ (e, c) => c ? Math.hypot(e.x - a[c - 1].x, e.y - a[c - 1].y) : 0
8
+ );
9
+ let p = 0;
10
+ const g = i.map((e) => p += e);
11
+ return {
12
+ stops: g.map((e) => p ? e / p : 0),
13
+ at(e) {
14
+ const c = e * p, x = g.findIndex((M) => M >= c);
15
+ if (x <= 0) return a[0];
16
+ const b = g[x - 1];
17
+ return l(
18
+ a[x - 1],
19
+ a[x],
20
+ i[x] ? (c - b) / i[x] : 0
21
+ );
22
+ }
23
+ };
24
+ }
25
+ function q(a, i) {
26
+ const p = new Map(a.nodes.map((t) => [t.id, t])), g = new Map(i.nodes.map((t) => [t.id, t])), e = i.nodes.map((t) => {
27
+ const n = p.get(t.id), r = t.parentId ? p.get(t.parentId) : void 0, s = t.parentId ? g.get(t.parentId) : void 0, m = n ?? {
28
+ ...t,
29
+ x: r && s ? t.x + r.x - s.x : t.x,
30
+ y: r && s ? t.y + r.y - s.y + 12 : t.y + 12,
31
+ opacity: 0
32
+ };
33
+ return { node: t, start: m };
34
+ }), c = new Map(e.map(({ node: t, start: n }) => [t.id, n])), x = a.nodes.filter((t) => !g.has(t.id)), b = new Map(a.edges.map((t) => [t.id, t])), M = i.edges.map((t) => {
35
+ const n = b.get(t.id), r = t.sections.map((s, m) => {
36
+ let I = n?.source === t.source && n.target === t.target ? n.sections[m] : void 0;
37
+ if (!s.length) return () => s;
38
+ if (!I?.length) {
39
+ const h = g.get(t.source), y = g.get(t.target), d = c.get(t.source), E = c.get(t.target);
40
+ if (!h || !y || !d || !E) return () => s;
41
+ const G = (w, o, f) => ({
42
+ x: f.x - o.x + (w.x - o.x) / o.width * (f.width - o.width),
43
+ y: f.y - o.y + (w.y - o.y) / o.height * (f.height - o.height)
44
+ }), L = G(s[0], h, d), P = G(s[s.length - 1], y, E), T = v(s).stops;
45
+ I = s.map((w, o) => ({
46
+ x: w.x + u(L.x, P.x, T[o]),
47
+ y: w.y + u(L.y, P.y, T[o])
48
+ }));
49
+ }
50
+ const S = v(I), z = v(s), j = [.../* @__PURE__ */ new Set([...S.stops, ...z.stops, 1])].sort((h, y) => h - y).map((h) => [S.at(h), z.at(h)]);
51
+ return (h) => j.map(([y, d]) => l(y, d, h));
52
+ });
53
+ return { edge: t, sections: r };
54
+ });
55
+ return (t) => {
56
+ if (t >= 1) return i;
57
+ const n = Math.max(0, t);
58
+ return {
59
+ bounds: {
60
+ ...l(a.bounds, i.bounds, n),
61
+ width: u(a.bounds.width, i.bounds.width, n),
62
+ height: u(a.bounds.height, i.bounds.height, n)
63
+ },
64
+ nodes: [
65
+ ...e.map(({ node: r, start: s }) => ({
66
+ ...r,
67
+ ...l(s, r, n),
68
+ width: u(s.width, r.width, n),
69
+ height: u(s.height, r.height, n),
70
+ opacity: u(s.opacity ?? 1, 1, n),
71
+ exiting: !1
72
+ })),
73
+ ...x.map((r) => ({
74
+ ...r,
75
+ exiting: !0,
76
+ opacity: (r.opacity ?? 1) * Math.max(0, 1 - n * 2.5)
77
+ }))
78
+ ],
79
+ edges: M.map(({ edge: r, sections: s }) => ({
80
+ ...r,
81
+ sections: s.map((m) => m(n))
82
+ }))
83
+ };
84
+ };
85
+ }
86
+ export {
87
+ q as createGraphLayoutTransition
88
+ };
@@ -1,3 +1,3 @@
1
1
  import type { GraphLayout, GraphLayoutOptions } from './types';
2
2
  /** Joint orthogonal routing through the final rectangular geometry. */
3
- export declare function routeGraphGeometry(layout: GraphLayout, options?: Pick<GraphLayoutOptions, 'edgeClearance' | 'routing'>): Promise<GraphLayout>;
3
+ export declare function routeGraphGeometry(layout: GraphLayout, options?: Pick<GraphLayoutOptions, 'edgeClearance' | 'edgeAnchorInset' | 'routing'>): Promise<GraphLayout>;
@@ -52,6 +52,8 @@ export interface GraphLayoutOptions {
52
52
  groupLayouts?: Readonly<Record<string, GraphGroupLayout>>;
53
53
  /** Clearance around routing obstacles in world units. Defaults to 4; never changes node geometry. */
54
54
  edgeClearance?: number;
55
+ /** Automatic border-anchor distance from corners. Defaults to 8, capped at one quarter of the side. Named ports stay exact. */
56
+ edgeAnchorInset?: number;
55
57
  /** Desired width/height when packing disconnected objects, including group members. */
56
58
  aspectRatio?: number;
57
59
  /** Absolute world positions. Descendants move with their group. Invalid positions always fail. */
@@ -76,7 +78,7 @@ export interface GraphLayoutOptions {
76
78
  position: GraphPoint;
77
79
  };
78
80
  }
79
- export type GraphRoutingOptions = Pick<GraphLayoutOptions, 'edgeClearance'>;
81
+ export type GraphRoutingOptions = Pick<GraphLayoutOptions, 'edgeClearance' | 'edgeAnchorInset'>;
80
82
  export interface GraphGroupLayout {
81
83
  /** Row fills left to right; column fills top to bottom. Omitted rules retain automatic layout. */
82
84
  flow: 'row' | 'column';
package/dist/graph.css CHANGED
@@ -184,3 +184,21 @@
184
184
  .floe-graph__edges [data-selected='true'] .floe-graph__edge-label {
185
185
  opacity: 1;
186
186
  }
187
+
188
+ /* New routes arrive quietly; keyed paths retain their identity while geometry moves. */
189
+ .floe-graph[data-animate-layout='true'] .floe-graph__edges > g {
190
+ animation: floe-graph-route-enter 160ms ease-out;
191
+ }
192
+ @keyframes floe-graph-route-enter {
193
+ from {
194
+ opacity: 0;
195
+ }
196
+ to {
197
+ opacity: 1;
198
+ }
199
+ }
200
+ @media (prefers-reduced-motion: reduce) {
201
+ .floe-graph[data-animate-layout='true'] .floe-graph__edges > g {
202
+ animation: none;
203
+ }
204
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.23",
3
+ "version": "0.101.29",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",