stickyflow 0.11.2 → 0.11.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.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk4KBU4CFU_cjs = require('./chunk-4KBU4CFU.cjs');
4
- var chunkEHH6ZDK6_cjs = require('./chunk-EHH6ZDK6.cjs');
3
+ var chunkGQRJSA73_cjs = require('./chunk-GQRJSA73.cjs');
4
+ var chunkK5PGMZAD_cjs = require('./chunk-K5PGMZAD.cjs');
5
5
  var chunkUHKFJBY5_cjs = require('./chunk-UHKFJBY5.cjs');
6
6
 
7
7
  // src/model/shape/supportedTypes.ts
@@ -76,7 +76,7 @@ function flattenGroups(groups, buckets) {
76
76
  // src/adapters/importJson/assembly.ts
77
77
  function sflToImportJson(sfl) {
78
78
  const state = chunkUHKFJBY5_cjs.sflToCanvasState(sfl);
79
- const collected = chunkEHH6ZDK6_cjs.collectCanvasObjects(state);
79
+ const collected = chunkK5PGMZAD_cjs.collectCanvasObjects(state);
80
80
  const canvas = emptyBuckets();
81
81
  const { groupBuckets, bucketFor } = createBucketResolver(indexGroupMembership(state.groups), canvas);
82
82
  for (const shape of collected.shapes) {
@@ -107,47 +107,47 @@ function sflToImportJson(sfl) {
107
107
 
108
108
  Object.defineProperty(exports, "buildBindingGraph", {
109
109
  enumerable: true,
110
- get: function () { return chunk4KBU4CFU_cjs.buildBindingGraph; }
110
+ get: function () { return chunkGQRJSA73_cjs.buildBindingGraph; }
111
111
  });
112
112
  Object.defineProperty(exports, "createBindingRuntime", {
113
113
  enumerable: true,
114
- get: function () { return chunk4KBU4CFU_cjs.createBindingRuntime; }
114
+ get: function () { return chunkGQRJSA73_cjs.createBindingRuntime; }
115
115
  });
116
116
  Object.defineProperty(exports, "createDataSource", {
117
117
  enumerable: true,
118
- get: function () { return chunk4KBU4CFU_cjs.createDataSource; }
118
+ get: function () { return chunkGQRJSA73_cjs.createDataSource; }
119
119
  });
120
120
  Object.defineProperty(exports, "interactiveElements", {
121
121
  enumerable: true,
122
- get: function () { return chunk4KBU4CFU_cjs.interactiveElements; }
122
+ get: function () { return chunkGQRJSA73_cjs.interactiveElements; }
123
123
  });
124
124
  Object.defineProperty(exports, "renderBound", {
125
125
  enumerable: true,
126
- get: function () { return chunk4KBU4CFU_cjs.renderBound; }
126
+ get: function () { return chunkGQRJSA73_cjs.renderBound; }
127
127
  });
128
128
  Object.defineProperty(exports, "decodeColor", {
129
129
  enumerable: true,
130
- get: function () { return chunkEHH6ZDK6_cjs.decodeColor; }
130
+ get: function () { return chunkK5PGMZAD_cjs.decodeColor; }
131
131
  });
132
132
  Object.defineProperty(exports, "decodeShadow", {
133
133
  enumerable: true,
134
- get: function () { return chunkEHH6ZDK6_cjs.decodeShadow; }
134
+ get: function () { return chunkK5PGMZAD_cjs.decodeShadow; }
135
135
  });
136
136
  Object.defineProperty(exports, "defineComponent", {
137
137
  enumerable: true,
138
- get: function () { return chunkEHH6ZDK6_cjs.defineComponent; }
138
+ get: function () { return chunkK5PGMZAD_cjs.defineComponent; }
139
139
  });
140
140
  Object.defineProperty(exports, "render", {
141
141
  enumerable: true,
142
- get: function () { return chunkEHH6ZDK6_cjs.render; }
142
+ get: function () { return chunkK5PGMZAD_cjs.render; }
143
143
  });
144
144
  Object.defineProperty(exports, "renderCanvas", {
145
145
  enumerable: true,
146
- get: function () { return chunkEHH6ZDK6_cjs.renderCanvas; }
146
+ get: function () { return chunkK5PGMZAD_cjs.renderCanvas; }
147
147
  });
148
148
  Object.defineProperty(exports, "sflToRenderInput", {
149
149
  enumerable: true,
150
- get: function () { return chunkEHH6ZDK6_cjs.sflToRenderInput; }
150
+ get: function () { return chunkK5PGMZAD_cjs.sflToRenderInput; }
151
151
  });
152
152
  Object.defineProperty(exports, "AXIS_COS", {
153
153
  enumerable: true,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { buildBindingGraph, createBindingRuntime, createDataSource, interactiveElements, renderBound } from './chunk-UD6IG2PG.js';
2
- import { collectCanvasObjects } from './chunk-TQIYK5OA.js';
3
- export { decodeColor, decodeShadow, defineComponent, render, renderCanvas, sflToRenderInput } from './chunk-TQIYK5OA.js';
1
+ export { buildBindingGraph, createBindingRuntime, createDataSource, interactiveElements, renderBound } from './chunk-W25SXORW.js';
2
+ import { collectCanvasObjects } from './chunk-EBHO2FJ5.js';
3
+ export { decodeColor, decodeShadow, defineComponent, render, renderCanvas, sflToRenderInput } from './chunk-EBHO2FJ5.js';
4
4
  import { sflToCanvasState } from './chunk-G6IW2IX3.js';
5
5
  export { AXIS_COS, AXIS_SIN, CHART_TYPES, COMPONENT_CATEGORIES, DOM_CONTRACT_VERSION, canonicalizeSource as canonicalize, componentTypes, flattenPath, getComponentDescriptor, isChartObject, isDimensionObject, isGenericComponent, isIsometricObject, isPathObject, isSwimlaneObject, parseSource as parse, pathBounds, pathToSymbol, sflToCanvasState, symbolToPath } from './chunk-G6IW2IX3.js';
6
6
 
@@ -3103,7 +3103,7 @@ function snapCandidates(svg, axis, excludeIds) {
3103
3103
  return values;
3104
3104
  }
3105
3105
  function movedSegments(drag, value) {
3106
- const next = drag.segments.map((segment) => ({ ...segment }));
3106
+ const next = drag.segments.map((segment2) => ({ ...segment2 }));
3107
3107
  const target = next[drag.index];
3108
3108
  const before = next[drag.index - 1];
3109
3109
  const after = next[drag.index + 1];
@@ -3129,16 +3129,16 @@ function movedSegments(drag, value) {
3129
3129
  return next;
3130
3130
  }
3131
3131
  function pathSegments(segments) {
3132
- return segments.map((segment) => {
3133
- const start = { x: segment.ax, y: segment.ay };
3134
- const end = { x: segment.bx, y: segment.by };
3132
+ return segments.map((segment2) => {
3133
+ const start = { x: segment2.ax, y: segment2.ay };
3134
+ const end = { x: segment2.bx, y: segment2.by };
3135
3135
  return {
3136
3136
  start,
3137
3137
  end,
3138
3138
  midpoint: { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 },
3139
- originalMidpoint: { x: segment.ox, y: segment.oy },
3139
+ originalMidpoint: { x: segment2.ox, y: segment2.oy },
3140
3140
  isHorizontal: Math.abs(end.x - start.x) > Math.abs(end.y - start.y),
3141
- canMove: segment.movable
3141
+ canMove: segment2.movable
3142
3142
  };
3143
3143
  });
3144
3144
  }
@@ -3165,9 +3165,9 @@ var LinkSegmentSession = class {
3165
3165
  const owner = path && chunkWZA3DJJH_cjs.resolveOwner(path);
3166
3166
  const index = Number(handle.getAttribute("data-sf-link-segment"));
3167
3167
  const segments = path ? parseSegments(path) : [];
3168
- const segment = segments[index];
3168
+ const segment2 = segments[index];
3169
3169
  const point = chunkWZA3DJJH_cjs.pointerUserPoint(this.#svg, event);
3170
- if (!path || !owner || !segment || !point) {
3170
+ if (!path || !owner || !segment2 || !point) {
3171
3171
  return;
3172
3172
  }
3173
3173
  const axis = handle.getAttribute("data-sf-link-segment-axis") === "x" ? "x" : "y";
@@ -3178,7 +3178,7 @@ var LinkSegmentSession = class {
3178
3178
  guide.setAttribute("visibility", "hidden");
3179
3179
  overlay.appendChild(guide);
3180
3180
  handle.setPointerCapture?.(event.pointerId);
3181
- const current = axis === "y" ? segment.ay : segment.ax;
3181
+ const current = axis === "y" ? segment2.ay : segment2.ax;
3182
3182
  this.#drag = {
3183
3183
  owner,
3184
3184
  path,
@@ -3187,7 +3187,7 @@ var LinkSegmentSession = class {
3187
3187
  segments,
3188
3188
  index,
3189
3189
  axis,
3190
- base: axis === "y" ? segment.oy : segment.ox,
3190
+ base: axis === "y" ? segment2.oy : segment2.ox,
3191
3191
  start: axis === "y" ? point.y : point.x,
3192
3192
  origin: current,
3193
3193
  originalD: path.getAttribute("d") ?? "",
@@ -3275,11 +3275,11 @@ var LinkSegmentSession = class {
3275
3275
  const data = chunkUHKFJBY5_cjs.roundedOrthogonalPathData(pathSegments(next), Math.max(16, strokeWidth * 4));
3276
3276
  drag.path.setAttribute("d", data);
3277
3277
  drag.overlay.querySelector("path")?.setAttribute("d", data);
3278
- const segment = next[drag.index];
3278
+ const segment2 = next[drag.index];
3279
3279
  const width = Number(drag.handle.getAttribute("width"));
3280
3280
  const height = Number(drag.handle.getAttribute("height"));
3281
- drag.handle.setAttribute("x", String((segment.ax + segment.bx) / 2 - width / 2));
3282
- drag.handle.setAttribute("y", String((segment.ay + segment.by) / 2 - height / 2));
3281
+ drag.handle.setAttribute("x", String((segment2.ax + segment2.bx) / 2 - width / 2));
3282
+ drag.handle.setAttribute("y", String((segment2.ay + segment2.by) / 2 - height / 2));
3283
3283
  const view = this.#svg.viewBox.baseVal;
3284
3284
  if (snapped === null) {
3285
3285
  drag.guide.setAttribute("visibility", "hidden");
@@ -3444,6 +3444,66 @@ function nearestCandidates(bounds, candidates, limit = 50) {
3444
3444
  return [...candidates].sort((first, second) => centerDistance(bounds, first) - centerDistance(bounds, second)).slice(0, limit);
3445
3445
  }
3446
3446
 
3447
+ // src/runtime/interaction/snapping/gaps.ts
3448
+ function rowOf(bounds, candidates, axis) {
3449
+ const [crossStart, crossSize] = axis === "x" ? ["y", "height"] : ["x", "width"];
3450
+ const [start, size] = axis === "x" ? ["x", "width"] : ["y", "height"];
3451
+ return candidates.filter(
3452
+ (candidate) => candidate[crossStart] < bounds[crossStart] + bounds[crossSize] && bounds[crossStart] < candidate[crossStart] + candidate[crossSize]
3453
+ ).map((candidate) => ({
3454
+ start: candidate[start],
3455
+ end: candidate[start] + candidate[size],
3456
+ cross: candidate[crossStart] + candidate[crossSize] / 2
3457
+ })).sort((first, second) => first.start - second.start);
3458
+ }
3459
+ function segment(axis, from, to, cross) {
3460
+ return axis === "x" ? { orientation: "segment", x1: from, y1: cross, x2: to, y2: cross } : { orientation: "segment", x1: cross, y1: from, x2: cross, y2: to };
3461
+ }
3462
+ function axisGapSnap(bounds, candidates, axis, threshold) {
3463
+ const row = rowOf(bounds, candidates, axis);
3464
+ const start = axis === "x" ? bounds.x : bounds.y;
3465
+ const size = axis === "x" ? bounds.width : bounds.height;
3466
+ const center = start + size / 2;
3467
+ const before = row.filter((span) => (span.start + span.end) / 2 < center).at(-1);
3468
+ const after = row.find((span) => (span.start + span.end) / 2 >= center);
3469
+ const pairs = row.slice(1).map((span, index) => ({ first: row[index], second: span, gap: span.start - row[index].end }));
3470
+ let best = null;
3471
+ const consider = (target, guides) => {
3472
+ const delta = target - start;
3473
+ if (Math.abs(delta) < threshold && (!best || Math.abs(delta) < Math.abs(best.delta))) {
3474
+ best = { delta, guides };
3475
+ }
3476
+ };
3477
+ if (before && after) {
3478
+ const target = (before.end + after.start - size) / 2;
3479
+ if (target >= before.end) {
3480
+ consider(target, [
3481
+ segment(axis, before.end, target, before.cross),
3482
+ segment(axis, target + size, after.start, after.cross)
3483
+ ]);
3484
+ }
3485
+ }
3486
+ for (const { first, second, gap } of pairs) {
3487
+ if (gap <= 0) {
3488
+ continue;
3489
+ }
3490
+ const existing = segment(axis, first.end, second.start, first.cross);
3491
+ if (before) {
3492
+ consider(before.end + gap, [existing, segment(axis, before.end, before.end + gap, before.cross)]);
3493
+ }
3494
+ if (after) {
3495
+ consider(after.start - gap - size, [existing, segment(axis, after.start - gap, after.start, after.cross)]);
3496
+ }
3497
+ }
3498
+ return best;
3499
+ }
3500
+ function computeGapSnap(bounds, candidates, threshold) {
3501
+ return {
3502
+ x: axisGapSnap(bounds, candidates, "x", threshold),
3503
+ y: axisGapSnap(bounds, candidates, "y", threshold)
3504
+ };
3505
+ }
3506
+
3447
3507
  // src/runtime/interaction/snapping/isometricDiagonal.ts
3448
3508
  var AXES2 = [
3449
3509
  { x: chunkUHKFJBY5_cjs.AXIS_COS, y: chunkUHKFJBY5_cjs.AXIS_SIN },
@@ -3557,17 +3617,23 @@ function snapMove(svg, drag, rawDx, rawDy) {
3557
3617
  const leadBounds = offsetBounds(drag.canvasObjects[0].draggedBounds, rawDx, rawDy);
3558
3618
  const excludedIds = new Set(drag.canvasObjects.map((canvasObject) => canvasObject.owner.id));
3559
3619
  const candidates = nearestCandidates(leadBounds, chunkWZA3DJJH_cjs.findSnapCandidateBounds(svg, excludedIds));
3620
+ const threshold = snapDistancePx(svg) / chunkWZA3DJJH_cjs.pxPerUnit(svg);
3560
3621
  const snap = computeSnap(leadBounds, candidates, {
3561
- threshold: snapDistancePx(svg) / chunkWZA3DJJH_cjs.pxPerUnit(svg),
3622
+ threshold,
3562
3623
  activeX: MOVE_ACTIVE_POINTS,
3563
3624
  activeY: MOVE_ACTIVE_POINTS,
3564
3625
  guideOverhang: GUIDE_OVERHANG2
3565
3626
  });
3566
- return {
3567
- dx: rawDx + snap.x.delta,
3568
- dy: rawDy + snap.y.delta,
3569
- guides: [snap.x.guide, snap.y.guide].filter((guide) => guide !== null)
3627
+ const gaps = computeGapSnap(leadBounds, candidates, threshold);
3628
+ const pick = (align, gap) => {
3629
+ if (gap && (!align.guide || Math.abs(gap.delta) < Math.abs(align.delta))) {
3630
+ return gap;
3631
+ }
3632
+ return { delta: align.delta, guides: align.guide ? [align.guide] : [] };
3570
3633
  };
3634
+ const x = pick(snap.x, gaps.x);
3635
+ const y = pick(snap.y, gaps.y);
3636
+ return { dx: rawDx + x.delta, dy: rawDy + y.delta, guides: [...x.guides, ...y.guides] };
3571
3637
  }
3572
3638
 
3573
3639
  // src/runtime/interaction/move/completion.ts
@@ -6529,8 +6595,8 @@ function parsePropertyPath(path) {
6529
6595
  return null;
6530
6596
  }
6531
6597
  const blocks = [];
6532
- for (const segment of segments.slice(0, -1)) {
6533
- const block = parseBlockSegment(segment);
6598
+ for (const segment2 of segments.slice(0, -1)) {
6599
+ const block = parseBlockSegment(segment2);
6534
6600
  if (block === null) {
6535
6601
  return null;
6536
6602
  }
@@ -6538,15 +6604,15 @@ function parsePropertyPath(path) {
6538
6604
  }
6539
6605
  return { blocks, property };
6540
6606
  }
6541
- function parseBlockSegment(segment) {
6542
- const match = segment.match(BLOCK_SEGMENT);
6607
+ function parseBlockSegment(segment2) {
6608
+ const match = segment2.match(BLOCK_SEGMENT);
6543
6609
  if (!match) {
6544
6610
  return null;
6545
6611
  }
6546
6612
  return match[2] === void 0 ? { name: match[1] } : { name: match[1], id: match[2] };
6547
6613
  }
6548
- function parsePropertySegment(segment) {
6549
- const match = segment.match(PROPERTY_SEGMENT);
6614
+ function parsePropertySegment(segment2) {
6615
+ const match = segment2.match(PROPERTY_SEGMENT);
6550
6616
  if (!match) {
6551
6617
  return null;
6552
6618
  }