stickyflow 0.11.1 → 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/CHANGELOG.md +16 -0
- package/dist/binding/index.cjs +8 -8
- package/dist/binding/index.js +2 -2
- package/dist/{chunk-TQIYK5OA.js → chunk-EBHO2FJ5.js} +4 -3
- package/dist/chunk-EBHO2FJ5.js.map +1 -0
- package/dist/{chunk-4KBU4CFU.cjs → chunk-GQRJSA73.cjs} +7 -7
- package/dist/{chunk-4KBU4CFU.cjs.map → chunk-GQRJSA73.cjs.map} +1 -1
- package/dist/{chunk-DGAVCN4D.js → chunk-IQQ5KBL6.js} +3 -3
- package/dist/{chunk-DGAVCN4D.js.map → chunk-IQQ5KBL6.js.map} +1 -1
- package/dist/{chunk-EHH6ZDK6.cjs → chunk-K5PGMZAD.cjs} +4 -3
- package/dist/chunk-K5PGMZAD.cjs.map +1 -0
- package/dist/{chunk-VYQ6N5SI.cjs → chunk-V22J7Z4H.cjs} +4 -4
- package/dist/{chunk-VYQ6N5SI.cjs.map → chunk-V22J7Z4H.cjs.map} +1 -1
- package/dist/{chunk-UD6IG2PG.js → chunk-W25SXORW.js} +3 -3
- package/dist/{chunk-UD6IG2PG.js.map → chunk-W25SXORW.js.map} +1 -1
- package/dist/index.cjs +14 -14
- package/dist/index.js +3 -3
- package/dist/interaction/index.cjs +105 -24
- package/dist/interaction/index.cjs.map +1 -1
- package/dist/interaction/index.js +105 -24
- package/dist/interaction/index.js.map +1 -1
- package/dist/stickyflow-diagram.global.js +1 -1
- package/dist/stickyflow-diagram.global.js.map +1 -1
- package/dist/viewer/index.cjs +7 -7
- package/dist/viewer/index.js +2 -2
- package/dist/web-component/index.cjs +4 -4
- package/dist/web-component/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-EHH6ZDK6.cjs.map +0 -1
- package/dist/chunk-TQIYK5OA.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
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 =
|
|
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
|
|
110
|
+
get: function () { return chunkGQRJSA73_cjs.buildBindingGraph; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "createBindingRuntime", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkGQRJSA73_cjs.createBindingRuntime; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "createDataSource", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkGQRJSA73_cjs.createDataSource; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "interactiveElements", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkGQRJSA73_cjs.interactiveElements; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "renderBound", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkGQRJSA73_cjs.renderBound; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "decodeColor", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkK5PGMZAD_cjs.decodeColor; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "decodeShadow", {
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
134
|
+
get: function () { return chunkK5PGMZAD_cjs.decodeShadow; }
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "defineComponent", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunkK5PGMZAD_cjs.defineComponent; }
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "render", {
|
|
141
141
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunkK5PGMZAD_cjs.render; }
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "renderCanvas", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunkK5PGMZAD_cjs.renderCanvas; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "sflToRenderInput", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
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-
|
|
2
|
-
import { collectCanvasObjects } from './chunk-
|
|
3
|
-
export { decodeColor, decodeShadow, defineComponent, render, renderCanvas, sflToRenderInput } from './chunk-
|
|
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((
|
|
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((
|
|
3133
|
-
const start = { x:
|
|
3134
|
-
const end = { x:
|
|
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:
|
|
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:
|
|
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
|
|
3168
|
+
const segment2 = segments[index];
|
|
3169
3169
|
const point = chunkWZA3DJJH_cjs.pointerUserPoint(this.#svg, event);
|
|
3170
|
-
if (!path || !owner || !
|
|
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" ?
|
|
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" ?
|
|
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
|
|
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((
|
|
3282
|
-
drag.handle.setAttribute("y", String((
|
|
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
|
|
3622
|
+
threshold,
|
|
3562
3623
|
activeX: MOVE_ACTIVE_POINTS,
|
|
3563
3624
|
activeY: MOVE_ACTIVE_POINTS,
|
|
3564
3625
|
guideOverhang: GUIDE_OVERHANG2
|
|
3565
3626
|
});
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
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
|
|
6533
|
-
const block = parseBlockSegment(
|
|
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(
|
|
6542
|
-
const match =
|
|
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(
|
|
6549
|
-
const match =
|
|
6614
|
+
function parsePropertySegment(segment2) {
|
|
6615
|
+
const match = segment2.match(PROPERTY_SEGMENT);
|
|
6550
6616
|
if (!match) {
|
|
6551
6617
|
return null;
|
|
6552
6618
|
}
|
|
@@ -7246,7 +7312,22 @@ function movePathPoints(lines, range, dx, dy) {
|
|
|
7246
7312
|
function applyMoveChanges(sfl, events) {
|
|
7247
7313
|
const state = chunkUHKFJBY5_cjs.sflToCanvasState(sfl);
|
|
7248
7314
|
const lines = sfl.split("\n");
|
|
7315
|
+
const parents = new Map(state.canvasObjects.map((candidate) => [candidate.id, candidate.parentFrameId]));
|
|
7316
|
+
const moving = new Set(events.map((event) => event.owner.id));
|
|
7317
|
+
const hasMovingAncestor = (id) => {
|
|
7318
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7319
|
+
for (let parent = parents.get(id); parent && !seen.has(parent); parent = parents.get(parent)) {
|
|
7320
|
+
if (moving.has(parent)) {
|
|
7321
|
+
return true;
|
|
7322
|
+
}
|
|
7323
|
+
seen.add(parent);
|
|
7324
|
+
}
|
|
7325
|
+
return false;
|
|
7326
|
+
};
|
|
7249
7327
|
for (const event of events) {
|
|
7328
|
+
if (hasMovingAncestor(event.owner.id)) {
|
|
7329
|
+
continue;
|
|
7330
|
+
}
|
|
7250
7331
|
const canvasObject = state.canvasObjects.find((candidate) => candidate.id === event.owner.id);
|
|
7251
7332
|
const range = canvasObject ? findOwnerBlock(lines, event.owner.id) : null;
|
|
7252
7333
|
if (!canvasObject || !range) {
|