@dou-ui/flow 0.1.0-alpha.2 → 0.1.0-alpha.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.
@@ -136,6 +136,10 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
136
136
  portTypes: {},
137
137
  acyclic: { type: Boolean },
138
138
  canConnect: {},
139
+ bordered: {
140
+ type: Boolean,
141
+ default: true
142
+ },
139
143
  ariaLabel: {},
140
144
  messages: {}
141
145
  }, {
@@ -515,9 +519,14 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
515
519
  const out = [];
516
520
  const edges = doc.value.edges;
517
521
  edges.length;
518
- for (const edge of toRaw(edges)) {
522
+ const tweening = tween.value !== null;
523
+ for (let edge of toRaw(edges)) {
519
524
  const from = edgeEnd(edge.source);
520
525
  const to = edgeEnd(edge.target);
526
+ if (edge.points && (tweening || from !== edge.source || to !== edge.target)) edge = {
527
+ ...edge,
528
+ points: void 0
529
+ };
521
530
  if (from.node === to.node && (from !== edge.source || to !== edge.target)) continue;
522
531
  const source = nodeById.value.get(from.node);
523
532
  const target = nodeById.value.get(to.node);
@@ -525,14 +534,22 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
525
534
  const a = anchor(source, from.port, "source");
526
535
  const b = anchor(target, to.port, "target");
527
536
  if (!a || !b) continue;
537
+ const xs = [a.x, b.x];
538
+ const ys = [a.y, b.y];
539
+ for (const p of edge.points ?? []) {
540
+ xs.push(p.x);
541
+ ys.push(p.y);
542
+ }
543
+ const x = Math.min(...xs);
544
+ const y = Math.min(...ys);
528
545
  out.push({
529
546
  edge,
530
547
  route: edgeTypeOf(edge.type).route(a, b, edge),
531
548
  box: {
532
- x: Math.min(a.x, b.x) - EDGE_REACH,
533
- y: Math.min(a.y, b.y) - EDGE_REACH,
534
- width: Math.abs(a.x - b.x) + 160,
535
- height: Math.abs(a.y - b.y) + 160
549
+ x: x - EDGE_REACH,
550
+ y: y - EDGE_REACH,
551
+ width: Math.max(...xs) - x + 160,
552
+ height: Math.max(...ys) - y + 160
536
553
  },
537
554
  style: edgeStyle(edge)
538
555
  });
@@ -890,7 +907,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
890
907
  rankGap: gap.rank,
891
908
  laneGap: gap.row,
892
909
  equalWidth: false,
893
- grid: props.grid || 8
910
+ grid: props.grid || 8,
911
+ straightChains: true
894
912
  });
895
913
  const snap = (v) => props.grid ? Math.round(v / props.grid) * props.grid : Math.round(v);
896
914
  const origin = {
@@ -911,7 +929,31 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
911
929
  };
912
930
  if (to.x !== node.x || to.y !== node.y) moved.set(node.id, to);
913
931
  }
914
- if (!moved.size) return;
932
+ const through = new Map(layout.edges.map((e) => [`${e.from}\u0000${e.to}`, e.points]));
933
+ const locked = new Set(nodes.filter((node) => node.locked).map((node) => node.id));
934
+ const routes = /* @__PURE__ */ new Map();
935
+ const pairs = /* @__PURE__ */ new Map();
936
+ for (const edge of doc.value.edges) {
937
+ const a = edge.source.node;
938
+ const b = edge.target.node;
939
+ if (!blocks.has(a) || !blocks.has(b)) continue;
940
+ const key = `${a}\u0000${b}`;
941
+ pairs.set(key, [...pairs.get(key) ?? [], edge]);
942
+ }
943
+ for (const [key, group] of pairs) {
944
+ const [a, b] = key.split("\0");
945
+ const points = locked.has(a) || locked.has(b) ? void 0 : through.get(key);
946
+ group.forEach((edge, i) => {
947
+ const off = (i - (group.length - 1) / 2) * (props.grid || 8);
948
+ const next = points?.length ? points.map((p) => ({
949
+ x: origin.x + snap(p.x) + (vertical ? off : 0),
950
+ y: origin.y + snap(p.y) + (vertical ? 0 : off)
951
+ })) : void 0;
952
+ routes.set(edge.id, next);
953
+ });
954
+ }
955
+ const rerouted = doc.value.edges.some((edge) => routes.has(edge.id) && JSON.stringify(routes.get(edge.id)) !== JSON.stringify(edge.points));
956
+ if (!moved.size && !rerouted) return;
915
957
  const count = moved.size;
916
958
  for (const { id } of nodes) {
917
959
  const to = moved.get(id);
@@ -932,6 +974,7 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
932
974
  }
933
975
  transact((tr) => {
934
976
  for (const [id, to] of moved) tr.moveNode(id, to.x, to.y);
977
+ for (const [id, points] of routes) if (JSON.stringify(points) !== JSON.stringify(tr.getEdge(id)?.points)) tr.updateEdge(id, { points });
935
978
  });
936
979
  announce(format(messages.value.tidied, { count }));
937
980
  animateTidy(from, moved);
@@ -1957,6 +2000,10 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
1957
2000
  if (!source || !target) continue;
1958
2001
  tr.addEdge({
1959
2002
  ...edge,
2003
+ points: edge.points?.map((p) => ({
2004
+ x: p.x + shift.x,
2005
+ y: p.y + shift.y
2006
+ })),
1960
2007
  id: createId("e"),
1961
2008
  source: {
1962
2009
  ...edge.source,
@@ -3157,7 +3204,8 @@ var flow_editor_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
3157
3204
  "is-space": spaceHeld.value,
3158
3205
  "is-dragging": !!dragging.value,
3159
3206
  "is-connecting": !!connecting.value,
3160
- "is-refused": !!connecting.value?.refused
3207
+ "is-refused": !!connecting.value?.refused,
3208
+ "is-bordered": props.bordered
3161
3209
  }));
3162
3210
  const context = {
3163
3211
  exportSVG,