orcasvn-react-diagrams 0.2.10 → 0.2.12
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 +24 -0
- package/README.md +11 -8
- package/ai/api-contract.json +44 -1
- package/ai/manifest.json +1 -1
- package/dist/cjs/examples.js +621 -349
- package/dist/cjs/index.js +222 -74
- package/dist/cjs/types/api/createDiagramEditor.d.ts +2 -1
- package/dist/cjs/types/api/types.d.ts +15 -0
- package/dist/cjs/types/displaybox/demos/LinkPortCreationDemoTab.d.ts +3 -0
- package/dist/cjs/types/displaybox/demos/linkColorPoolDemo.d.ts +2 -0
- package/dist/cjs/types/displaybox/demos/linkLabelsDemo.d.ts +4 -0
- package/dist/cjs/types/displaybox/types.d.ts +3 -0
- package/dist/cjs/types/displaybox/useDemoEditor.d.ts +3 -2
- package/dist/cjs/types/engine/DiagramEngine.d.ts +5 -1
- package/dist/cjs/types/engine/TextLayoutService.d.ts +1 -0
- package/dist/cjs/types/examples/index.d.ts +1 -1
- package/dist/cjs/types/renderer/konva/KonvaInteraction.d.ts +10 -1
- package/dist/esm/examples.js +621 -349
- package/dist/esm/examples.js.map +1 -1
- package/dist/esm/index.js +222 -74
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api/createDiagramEditor.d.ts +2 -1
- package/dist/esm/types/api/types.d.ts +15 -0
- package/dist/esm/types/displaybox/demos/LinkPortCreationDemoTab.d.ts +3 -0
- package/dist/esm/types/displaybox/demos/linkColorPoolDemo.d.ts +2 -0
- package/dist/esm/types/displaybox/demos/linkLabelsDemo.d.ts +4 -0
- package/dist/esm/types/displaybox/types.d.ts +3 -0
- package/dist/esm/types/displaybox/useDemoEditor.d.ts +3 -2
- package/dist/esm/types/engine/DiagramEngine.d.ts +5 -1
- package/dist/esm/types/engine/TextLayoutService.d.ts +1 -0
- package/dist/esm/types/examples/index.d.ts +1 -1
- package/dist/esm/types/renderer/konva/KonvaInteraction.d.ts +10 -1
- package/dist/examples.d.ts +5 -1
- package/dist/index.d.ts +17 -1
- package/docs/API_CONTRACT.md +44 -1
- package/docs/CAPABILITIES.md +3 -1
- package/docs/COMMANDS_EVENTS.md +1 -0
- package/docs/DOCUMENTATION_WORKFLOW.md +5 -1
- package/docs/INTEGRATION_PLAYBOOK.md +5 -0
- package/docs/STATE_INVARIANTS.md +3 -0
- package/package.json +1 -1
- package/src/displaybox/demos/LinkColorPoolDemoTab.tsx +10 -5
- package/src/displaybox/demos/LinkPortCreationDemoTab.tsx +98 -0
- package/src/displaybox/demos/index.tsx +122 -221
- package/src/displaybox/demos/linkColorPoolDemo.ts +84 -49
- package/src/displaybox/demos/linkLabelsDemo.ts +164 -0
- package/src/displaybox/demos/linkPortCreationDemo.ts +7 -7
- package/src/displaybox/types.ts +21 -11
- package/src/examples/index.ts +1 -0
package/dist/cjs/examples.js
CHANGED
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
-
var fallbackId = function () {
|
|
6
|
-
return "id-".concat(Math.random().toString(36).slice(2, 10), "-").concat(Date.now().toString(36));
|
|
7
|
-
};
|
|
8
|
-
var createId = function () {
|
|
9
|
-
var cryptoApi = globalThis.crypto;
|
|
10
|
-
if (cryptoApi === null || cryptoApi === void 0 ? void 0 : cryptoApi.randomUUID) {
|
|
11
|
-
return cryptoApi.randomUUID();
|
|
12
|
-
}
|
|
13
|
-
return fallbackId();
|
|
14
|
-
};
|
|
15
|
-
|
|
16
5
|
/******************************************************************************
|
|
17
6
|
Copyright (c) Microsoft Corporation.
|
|
18
7
|
|
|
@@ -82,6 +71,17 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
82
71
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
83
72
|
};
|
|
84
73
|
|
|
74
|
+
var fallbackId = function () {
|
|
75
|
+
return "id-".concat(Math.random().toString(36).slice(2, 10), "-").concat(Date.now().toString(36));
|
|
76
|
+
};
|
|
77
|
+
var createId = function () {
|
|
78
|
+
var cryptoApi = globalThis.crypto;
|
|
79
|
+
if (cryptoApi === null || cryptoApi === void 0 ? void 0 : cryptoApi.randomUUID) {
|
|
80
|
+
return cryptoApi.randomUUID();
|
|
81
|
+
}
|
|
82
|
+
return fallbackId();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
85
|
var DEFAULT_PADDING = 12;
|
|
86
86
|
var DEFAULT_TOLERANCE = 0.5;
|
|
87
87
|
var DEFAULT_STUB_LENGTH = 12;
|
|
@@ -848,7 +848,7 @@ var createLinkPortCreationState = function () { return ({
|
|
|
848
848
|
var linkPortCreationDemoConfig = ({
|
|
849
849
|
id: 'link-port-creation',
|
|
850
850
|
title: 'Link Creates Port',
|
|
851
|
-
description: 'Drag from a port to an element to auto-create a target port.',
|
|
851
|
+
description: 'Drag from a port to an element to auto-create a target port, then compare default and host-customized target-port creation.',
|
|
852
852
|
createState: createLinkPortCreationState,
|
|
853
853
|
elementShapes: baseElementShapes,
|
|
854
854
|
portShapes: basePortShapes,
|
|
@@ -3486,55 +3486,96 @@ var labelStyleDemoConfig = {
|
|
|
3486
3486
|
var createLinkColorPoolState = function () { return ({
|
|
3487
3487
|
elements: [
|
|
3488
3488
|
{
|
|
3489
|
-
id: 'lc-
|
|
3490
|
-
position: { x: 80, y:
|
|
3489
|
+
id: 'lc-load-missing-source',
|
|
3490
|
+
position: { x: 80, y: 160 },
|
|
3491
3491
|
size: { width: 190, height: 120 },
|
|
3492
3492
|
shapeId: 'default',
|
|
3493
3493
|
},
|
|
3494
3494
|
{
|
|
3495
|
-
id: 'lc-
|
|
3496
|
-
position: { x: 350, y:
|
|
3495
|
+
id: 'lc-load-missing-target',
|
|
3496
|
+
position: { x: 350, y: 160 },
|
|
3497
3497
|
size: { width: 190, height: 120 },
|
|
3498
3498
|
shapeId: 'default',
|
|
3499
3499
|
},
|
|
3500
3500
|
{
|
|
3501
|
-
id: 'lc-
|
|
3502
|
-
position: { x: 80, y:
|
|
3501
|
+
id: 'lc-load-blank-source',
|
|
3502
|
+
position: { x: 80, y: 350 },
|
|
3503
3503
|
size: { width: 190, height: 120 },
|
|
3504
3504
|
shapeId: 'panel',
|
|
3505
3505
|
},
|
|
3506
3506
|
{
|
|
3507
|
-
id: 'lc-
|
|
3508
|
-
position: { x: 350, y:
|
|
3507
|
+
id: 'lc-load-blank-target',
|
|
3508
|
+
position: { x: 350, y: 350 },
|
|
3509
3509
|
size: { width: 190, height: 120 },
|
|
3510
3510
|
shapeId: 'panel',
|
|
3511
3511
|
},
|
|
3512
3512
|
{
|
|
3513
|
-
id: 'lc-
|
|
3514
|
-
position: { x:
|
|
3513
|
+
id: 'lc-load-explicit-source',
|
|
3514
|
+
position: { x: 80, y: 540 },
|
|
3515
|
+
size: { width: 190, height: 120 },
|
|
3516
|
+
shapeId: 'default',
|
|
3517
|
+
},
|
|
3518
|
+
{
|
|
3519
|
+
id: 'lc-load-explicit-target',
|
|
3520
|
+
position: { x: 350, y: 540 },
|
|
3521
|
+
size: { width: 190, height: 120 },
|
|
3522
|
+
shapeId: 'default',
|
|
3523
|
+
},
|
|
3524
|
+
{
|
|
3525
|
+
id: 'lc-create-auto-source',
|
|
3526
|
+
position: { x: 620, y: 250 },
|
|
3515
3527
|
size: { width: 190, height: 120 },
|
|
3516
3528
|
shapeId: 'default',
|
|
3517
3529
|
},
|
|
3518
3530
|
{
|
|
3519
|
-
id: 'lc-
|
|
3520
|
-
position: { x: 620, y:
|
|
3531
|
+
id: 'lc-create-auto-target',
|
|
3532
|
+
position: { x: 620, y: 420 },
|
|
3521
3533
|
size: { width: 190, height: 120 },
|
|
3522
3534
|
shapeId: 'default',
|
|
3523
3535
|
},
|
|
3536
|
+
{
|
|
3537
|
+
id: 'lc-create-explicit-source',
|
|
3538
|
+
position: { x: 870, y: 250 },
|
|
3539
|
+
size: { width: 190, height: 120 },
|
|
3540
|
+
shapeId: 'panel',
|
|
3541
|
+
},
|
|
3542
|
+
{
|
|
3543
|
+
id: 'lc-create-explicit-target',
|
|
3544
|
+
position: { x: 870, y: 420 },
|
|
3545
|
+
size: { width: 190, height: 120 },
|
|
3546
|
+
shapeId: 'panel',
|
|
3547
|
+
},
|
|
3524
3548
|
],
|
|
3525
3549
|
ports: [
|
|
3526
|
-
{ id: 'lc-
|
|
3527
|
-
{ id: 'lc-
|
|
3528
|
-
{ id: 'lc-
|
|
3529
|
-
{ id: 'lc-
|
|
3530
|
-
{ id: 'lc-
|
|
3531
|
-
{ id: 'lc-
|
|
3550
|
+
{ id: 'lc-load-missing-source-port', elementId: 'lc-load-missing-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
|
|
3551
|
+
{ id: 'lc-load-missing-target-port', elementId: 'lc-load-missing-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
|
|
3552
|
+
{ id: 'lc-load-blank-source-port', elementId: 'lc-load-blank-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
|
|
3553
|
+
{ id: 'lc-load-blank-target-port', elementId: 'lc-load-blank-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
|
|
3554
|
+
{ id: 'lc-load-explicit-source-port', elementId: 'lc-load-explicit-source', position: { x: 170, y: 60 }, shapeId: 'port-circle' },
|
|
3555
|
+
{ id: 'lc-load-explicit-target-port', elementId: 'lc-load-explicit-target', position: { x: 20, y: 60 }, shapeId: 'port-circle' },
|
|
3556
|
+
{ id: 'lc-create-auto-source-port', elementId: 'lc-create-auto-source', position: { x: 95, y: 110 }, shapeId: 'port-circle' },
|
|
3557
|
+
{ id: 'lc-create-auto-target-port', elementId: 'lc-create-auto-target', position: { x: 95, y: 10 }, shapeId: 'port-circle' },
|
|
3558
|
+
{ id: 'lc-create-explicit-source-port', elementId: 'lc-create-explicit-source', position: { x: 95, y: 110 }, shapeId: 'port-circle' },
|
|
3559
|
+
{ id: 'lc-create-explicit-target-port', elementId: 'lc-create-explicit-target', position: { x: 95, y: 10 }, shapeId: 'port-circle' },
|
|
3532
3560
|
],
|
|
3533
3561
|
links: [
|
|
3534
3562
|
{
|
|
3535
|
-
id: 'lc-
|
|
3536
|
-
sourcePortId: 'lc-
|
|
3537
|
-
targetPortId: 'lc-
|
|
3563
|
+
id: 'lc-loaded-missing-link',
|
|
3564
|
+
sourcePortId: 'lc-load-missing-source-port',
|
|
3565
|
+
targetPortId: 'lc-load-missing-target-port',
|
|
3566
|
+
points: [],
|
|
3567
|
+
},
|
|
3568
|
+
{
|
|
3569
|
+
id: 'lc-loaded-blank-link',
|
|
3570
|
+
sourcePortId: 'lc-load-blank-source-port',
|
|
3571
|
+
targetPortId: 'lc-load-blank-target-port',
|
|
3572
|
+
points: [],
|
|
3573
|
+
style: { stroke: ' ', strokeWidth: 2 },
|
|
3574
|
+
},
|
|
3575
|
+
{
|
|
3576
|
+
id: 'lc-loaded-explicit-link',
|
|
3577
|
+
sourcePortId: 'lc-load-explicit-source-port',
|
|
3578
|
+
targetPortId: 'lc-load-explicit-target-port',
|
|
3538
3579
|
points: [],
|
|
3539
3580
|
style: { stroke: '#374151', strokeWidth: 2 },
|
|
3540
3581
|
},
|
|
@@ -3542,18 +3583,20 @@ var createLinkColorPoolState = function () { return ({
|
|
|
3542
3583
|
texts: [
|
|
3543
3584
|
{
|
|
3544
3585
|
id: 'lc-intro',
|
|
3545
|
-
content: '
|
|
3586
|
+
content: 'Change Color Mode, then use Reload Demo State to compare load-time fill. The left column loads one missing-stroke link, one blank-stroke link, and one explicit-stroke link. The right column actions add new links so you can compare creation-time color assignment with explicit-stroke preservation under the same policy.',
|
|
3546
3587
|
position: { x: 80, y: 86 },
|
|
3547
3588
|
},
|
|
3548
|
-
{ id: 'lc-
|
|
3549
|
-
{ id: 'lc-
|
|
3550
|
-
{ id: 'lc-
|
|
3589
|
+
{ id: 'lc-load-missing-label', content: 'Loaded link with missing stroke', ownerId: 'lc-load-missing-source', position: { x: 10, y: -16 } },
|
|
3590
|
+
{ id: 'lc-load-blank-label', content: 'Loaded link with blank stroke', ownerId: 'lc-load-blank-source', position: { x: 10, y: -16 } },
|
|
3591
|
+
{ id: 'lc-load-explicit-label', content: 'Loaded link with explicit stroke', ownerId: 'lc-load-explicit-source', position: { x: 10, y: -16 } },
|
|
3592
|
+
{ id: 'lc-create-auto-label', content: 'Add new unstyled links here', ownerId: 'lc-create-auto-source', position: { x: 10, y: -16 } },
|
|
3593
|
+
{ id: 'lc-create-explicit-label', content: 'Add new explicit-stroke links here', ownerId: 'lc-create-explicit-source', position: { x: 10, y: -16 } },
|
|
3551
3594
|
],
|
|
3552
3595
|
}); };
|
|
3553
3596
|
var linkColorPoolDemoConfig = {
|
|
3554
3597
|
id: 'link-color-pool',
|
|
3555
3598
|
title: 'Link Color Pool',
|
|
3556
|
-
description: 'Verify
|
|
3599
|
+
description: 'Verify off/default/custom load-time fill for missing link strokes and compare it with creation-time color assignment.',
|
|
3557
3600
|
createState: createLinkColorPoolState,
|
|
3558
3601
|
elementShapes: baseElementShapes,
|
|
3559
3602
|
portShapes: basePortShapes,
|
|
@@ -3561,39 +3604,188 @@ var linkColorPoolDemoConfig = {
|
|
|
3561
3604
|
defaultPortShapeId: 'port-circle',
|
|
3562
3605
|
actions: [
|
|
3563
3606
|
{
|
|
3564
|
-
id: 'add-link-
|
|
3565
|
-
label: 'Add
|
|
3607
|
+
id: 'add-link-create-auto',
|
|
3608
|
+
label: 'Add new unstyled link',
|
|
3566
3609
|
run: function (editor) {
|
|
3567
3610
|
editor.addLink({
|
|
3568
|
-
id: "link-color-
|
|
3569
|
-
sourcePortId: 'lc-
|
|
3570
|
-
targetPortId: 'lc-
|
|
3611
|
+
id: "link-color-create-auto-".concat(createId()),
|
|
3612
|
+
sourcePortId: 'lc-create-auto-source-port',
|
|
3613
|
+
targetPortId: 'lc-create-auto-target-port',
|
|
3571
3614
|
points: [],
|
|
3572
3615
|
});
|
|
3573
3616
|
},
|
|
3574
3617
|
},
|
|
3575
3618
|
{
|
|
3576
|
-
id: 'add-link-
|
|
3577
|
-
label: 'Add
|
|
3619
|
+
id: 'add-link-create-explicit',
|
|
3620
|
+
label: 'Add new explicit-stroke link',
|
|
3578
3621
|
run: function (editor) {
|
|
3579
3622
|
editor.addLink({
|
|
3580
|
-
id: "link-color-
|
|
3581
|
-
sourcePortId: 'lc-
|
|
3582
|
-
targetPortId: 'lc-
|
|
3623
|
+
id: "link-color-create-explicit-".concat(createId()),
|
|
3624
|
+
sourcePortId: 'lc-create-explicit-source-port',
|
|
3625
|
+
targetPortId: 'lc-create-explicit-target-port',
|
|
3583
3626
|
points: [],
|
|
3627
|
+
style: {
|
|
3628
|
+
stroke: '#111827',
|
|
3629
|
+
strokeWidth: 2,
|
|
3630
|
+
},
|
|
3584
3631
|
});
|
|
3585
3632
|
},
|
|
3586
3633
|
},
|
|
3634
|
+
],
|
|
3635
|
+
};
|
|
3636
|
+
|
|
3637
|
+
var linkLabelDemoSourceId = 'link-label-source';
|
|
3638
|
+
var linkLabelDemoTargetId = 'link-label-target';
|
|
3639
|
+
var linkLabelDemoLinkId = 'link-label-link';
|
|
3640
|
+
var linkLabelDemoTextId = 'link-label-text';
|
|
3641
|
+
var resolveLinkMidpoint = function (points) {
|
|
3642
|
+
if (points.length === 0)
|
|
3643
|
+
return { x: 0, y: 0 };
|
|
3644
|
+
if (points.length === 1)
|
|
3645
|
+
return __assign({}, points[0]);
|
|
3646
|
+
var total = 0;
|
|
3647
|
+
for (var index = 1; index < points.length; index += 1) {
|
|
3648
|
+
total += Math.hypot(points[index].x - points[index - 1].x, points[index].y - points[index - 1].y);
|
|
3649
|
+
}
|
|
3650
|
+
var halfway = total / 2;
|
|
3651
|
+
var travelled = 0;
|
|
3652
|
+
for (var index = 1; index < points.length; index += 1) {
|
|
3653
|
+
var segment = Math.hypot(points[index].x - points[index - 1].x, points[index].y - points[index - 1].y);
|
|
3654
|
+
if (travelled + segment >= halfway) {
|
|
3655
|
+
var ratio = segment === 0 ? 0 : (halfway - travelled) / segment;
|
|
3656
|
+
return {
|
|
3657
|
+
x: points[index - 1].x + (points[index].x - points[index - 1].x) * ratio,
|
|
3658
|
+
y: points[index - 1].y + (points[index].y - points[index - 1].y) * ratio,
|
|
3659
|
+
};
|
|
3660
|
+
}
|
|
3661
|
+
travelled += segment;
|
|
3662
|
+
}
|
|
3663
|
+
return __assign({}, points[points.length - 1]);
|
|
3664
|
+
};
|
|
3665
|
+
var nudgeLinkLabel = function (editor, state) {
|
|
3666
|
+
var link = state.links.find(function (item) { return item.id === linkLabelDemoLinkId; });
|
|
3667
|
+
var label = state.texts.find(function (item) { return item.id === linkLabelDemoTextId; });
|
|
3668
|
+
if (!link || !label)
|
|
3669
|
+
return;
|
|
3670
|
+
var midpoint = resolveLinkMidpoint(link.points);
|
|
3671
|
+
editor.moveTextTo(linkLabelDemoTextId, midpoint.x + 72, midpoint.y - 24);
|
|
3672
|
+
};
|
|
3673
|
+
var createLinkLabelsState = function () { return ({
|
|
3674
|
+
elements: [
|
|
3675
|
+
{
|
|
3676
|
+
id: linkLabelDemoSourceId,
|
|
3677
|
+
position: { x: 120, y: 180 },
|
|
3678
|
+
size: { width: 220, height: 120 },
|
|
3679
|
+
shapeId: 'default',
|
|
3680
|
+
},
|
|
3681
|
+
{
|
|
3682
|
+
id: linkLabelDemoTargetId,
|
|
3683
|
+
position: { x: 500, y: 220 },
|
|
3684
|
+
size: { width: 220, height: 140 },
|
|
3685
|
+
shapeId: 'panel',
|
|
3686
|
+
},
|
|
3687
|
+
],
|
|
3688
|
+
ports: [
|
|
3689
|
+
{
|
|
3690
|
+
id: 'link-label-source-port',
|
|
3691
|
+
elementId: linkLabelDemoSourceId,
|
|
3692
|
+
position: { x: 220, y: 60 },
|
|
3693
|
+
shapeId: 'port-circle',
|
|
3694
|
+
moveMode: 'border',
|
|
3695
|
+
anchorCenter: true,
|
|
3696
|
+
},
|
|
3697
|
+
{
|
|
3698
|
+
id: 'link-label-target-port',
|
|
3699
|
+
elementId: linkLabelDemoTargetId,
|
|
3700
|
+
position: { x: 0, y: 70 },
|
|
3701
|
+
shapeId: 'port-circle',
|
|
3702
|
+
moveMode: 'border',
|
|
3703
|
+
anchorCenter: true,
|
|
3704
|
+
},
|
|
3705
|
+
],
|
|
3706
|
+
links: [
|
|
3707
|
+
{
|
|
3708
|
+
id: linkLabelDemoLinkId,
|
|
3709
|
+
sourcePortId: 'link-label-source-port',
|
|
3710
|
+
targetPortId: 'link-label-target-port',
|
|
3711
|
+
points: [],
|
|
3712
|
+
},
|
|
3713
|
+
],
|
|
3714
|
+
texts: [
|
|
3715
|
+
{
|
|
3716
|
+
id: "".concat(linkLabelDemoSourceId, "-label"),
|
|
3717
|
+
content: 'Source node',
|
|
3718
|
+
position: { x: 12, y: -14 },
|
|
3719
|
+
ownerId: linkLabelDemoSourceId,
|
|
3720
|
+
},
|
|
3721
|
+
{
|
|
3722
|
+
id: "".concat(linkLabelDemoTargetId, "-label"),
|
|
3723
|
+
content: 'Move me, reroute me',
|
|
3724
|
+
position: { x: 12, y: -14 },
|
|
3725
|
+
ownerId: linkLabelDemoTargetId,
|
|
3726
|
+
},
|
|
3727
|
+
{
|
|
3728
|
+
id: linkLabelDemoTextId,
|
|
3729
|
+
content: 'I am just owned text',
|
|
3730
|
+
position: { x: 0, y: -24 },
|
|
3731
|
+
ownerId: linkLabelDemoLinkId,
|
|
3732
|
+
layout: {
|
|
3733
|
+
boundsMode: 'fixed',
|
|
3734
|
+
fixedSize: { width: 160, height: 24 },
|
|
3735
|
+
wrap: 'none',
|
|
3736
|
+
overflow: 'ellipsis-end',
|
|
3737
|
+
},
|
|
3738
|
+
style: {
|
|
3739
|
+
fill: '#1f2937',
|
|
3740
|
+
backgroundFill: '#fef3c7',
|
|
3741
|
+
padding: 4,
|
|
3742
|
+
},
|
|
3743
|
+
},
|
|
3744
|
+
{
|
|
3745
|
+
id: 'link-label-tip',
|
|
3746
|
+
content: 'This label is TextData owned by the link. Drag or edit it, reroute the link, then delete the link to confirm the label follows and cascades away.',
|
|
3747
|
+
position: { x: 120, y: 110 },
|
|
3748
|
+
layout: {
|
|
3749
|
+
boundsMode: 'fixed',
|
|
3750
|
+
fixedSize: { width: 620, height: 44 },
|
|
3751
|
+
wrap: 'word',
|
|
3752
|
+
overflow: 'clip',
|
|
3753
|
+
padding: 0,
|
|
3754
|
+
},
|
|
3755
|
+
style: {
|
|
3756
|
+
fill: '#475569',
|
|
3757
|
+
},
|
|
3758
|
+
},
|
|
3759
|
+
],
|
|
3760
|
+
}); };
|
|
3761
|
+
var linkLabelsDemoConfig = {
|
|
3762
|
+
id: 'link-labels',
|
|
3763
|
+
title: 'Link Labels',
|
|
3764
|
+
description: 'Link-owned text stays anchored to the route midpoint. Drag or edit the label, reroute the link, then delete the link to watch the owned text disappear with it.',
|
|
3765
|
+
createState: createLinkLabelsState,
|
|
3766
|
+
elementShapes: baseElementShapes,
|
|
3767
|
+
portShapes: basePortShapes,
|
|
3768
|
+
defaultElementShapeId: 'default',
|
|
3769
|
+
defaultPortShapeId: 'port-circle',
|
|
3770
|
+
actions: [
|
|
3771
|
+
{
|
|
3772
|
+
id: 'link-label-offset',
|
|
3773
|
+
label: 'Offset label via API',
|
|
3774
|
+
run: function (editor, state) { return nudgeLinkLabel(editor, state); },
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
id: 'link-label-reroute',
|
|
3778
|
+
label: 'Move target + reroute',
|
|
3779
|
+
run: function (editor) {
|
|
3780
|
+
editor.moveElementTo(linkLabelDemoTargetId, 660, 320);
|
|
3781
|
+
editor.rerouteAllLinks();
|
|
3782
|
+
},
|
|
3783
|
+
},
|
|
3587
3784
|
{
|
|
3588
|
-
id: '
|
|
3589
|
-
label: '
|
|
3785
|
+
id: 'link-label-delete',
|
|
3786
|
+
label: 'Delete labeled link',
|
|
3590
3787
|
run: function (editor) {
|
|
3591
|
-
editor.
|
|
3592
|
-
id: "link-color-custom-".concat(createId()),
|
|
3593
|
-
sourcePortId: 'lc-custom-source-port',
|
|
3594
|
-
targetPortId: 'lc-custom-target-port',
|
|
3595
|
-
points: [],
|
|
3596
|
-
});
|
|
3788
|
+
editor.removeLink(linkLabelDemoLinkId);
|
|
3597
3789
|
},
|
|
3598
3790
|
},
|
|
3599
3791
|
],
|
|
@@ -6115,21 +6307,20 @@ var TextLayoutService = /** @class */ (function () {
|
|
|
6115
6307
|
return ids;
|
|
6116
6308
|
};
|
|
6117
6309
|
TextLayoutService.prototype.shouldTrackOwnerBoundLayout = function (text) {
|
|
6118
|
-
var _a;
|
|
6119
6310
|
if (!text.layout)
|
|
6120
6311
|
return false;
|
|
6121
|
-
var boundsMode =
|
|
6312
|
+
var boundsMode = this.resolveDefaultBoundsMode(text);
|
|
6122
6313
|
return boundsMode === 'owner-width' || boundsMode === 'owner-box';
|
|
6123
6314
|
};
|
|
6124
6315
|
TextLayoutService.prototype.resolveTextLayoutBounds = function (text, padding) {
|
|
6125
|
-
var _a, _b
|
|
6316
|
+
var _a, _b;
|
|
6126
6317
|
var layout = text.layout;
|
|
6127
6318
|
if (!layout)
|
|
6128
6319
|
return {};
|
|
6129
|
-
var boundsMode =
|
|
6320
|
+
var boundsMode = this.resolveDefaultBoundsMode(text);
|
|
6130
6321
|
if (boundsMode === 'fixed') {
|
|
6131
|
-
var width = (
|
|
6132
|
-
var height = (
|
|
6322
|
+
var width = (_a = layout.fixedSize) === null || _a === void 0 ? void 0 : _a.width;
|
|
6323
|
+
var height = (_b = layout.fixedSize) === null || _b === void 0 ? void 0 : _b.height;
|
|
6133
6324
|
return {
|
|
6134
6325
|
width: typeof width === 'number' ? Math.max(0, width - padding * 2) : undefined,
|
|
6135
6326
|
height: typeof height === 'number' ? Math.max(0, height - padding * 2) : undefined,
|
|
@@ -6149,6 +6340,14 @@ var TextLayoutService = /** @class */ (function () {
|
|
|
6149
6340
|
}
|
|
6150
6341
|
return {};
|
|
6151
6342
|
};
|
|
6343
|
+
TextLayoutService.prototype.resolveDefaultBoundsMode = function (text) {
|
|
6344
|
+
var _a;
|
|
6345
|
+
if ((_a = text.layout) === null || _a === void 0 ? void 0 : _a.boundsMode)
|
|
6346
|
+
return text.layout.boundsMode;
|
|
6347
|
+
if (!text.ownerId)
|
|
6348
|
+
return undefined;
|
|
6349
|
+
return this.model.getElement(text.ownerId) ? 'owner-width' : undefined;
|
|
6350
|
+
};
|
|
6152
6351
|
TextLayoutService.prototype.wrapText = function (content, maxWidth, mode, text) {
|
|
6153
6352
|
var _this = this;
|
|
6154
6353
|
if (maxWidth === undefined || !Number.isFinite(maxWidth)) {
|
|
@@ -8043,6 +8242,10 @@ var DEFAULT_LINK_COLOR_POOL = [
|
|
|
8043
8242
|
'#9c755f',
|
|
8044
8243
|
'#bab0ab',
|
|
8045
8244
|
];
|
|
8245
|
+
var hasUsableLinkStroke = function (style) {
|
|
8246
|
+
var stroke = style === null || style === void 0 ? void 0 : style.stroke;
|
|
8247
|
+
return stroke !== undefined && stroke !== null && "".concat(stroke).trim().length > 0;
|
|
8248
|
+
};
|
|
8046
8249
|
var normalizeLinkColorPoolPolicy = function (policy) {
|
|
8047
8250
|
var _a;
|
|
8048
8251
|
var enabled = Boolean(policy === null || policy === void 0 ? void 0 : policy.enabled);
|
|
@@ -8050,7 +8253,11 @@ var normalizeLinkColorPoolPolicy = function (policy) {
|
|
|
8050
8253
|
.map(function (color) { return color.trim(); })
|
|
8051
8254
|
.filter(function (color) { return color.length > 0; });
|
|
8052
8255
|
var colors = normalizedColors.length > 0 ? normalizedColors : __spreadArray([], DEFAULT_LINK_COLOR_POOL, true);
|
|
8053
|
-
return {
|
|
8256
|
+
return {
|
|
8257
|
+
enabled: enabled,
|
|
8258
|
+
colors: colors,
|
|
8259
|
+
assignOnLoadWhenMissingStroke: Boolean(policy === null || policy === void 0 ? void 0 : policy.assignOnLoadWhenMissingStroke),
|
|
8260
|
+
};
|
|
8054
8261
|
};
|
|
8055
8262
|
var DiagramEngine = /** @class */ (function () {
|
|
8056
8263
|
function DiagramEngine(config) {
|
|
@@ -8096,8 +8303,9 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
8096
8303
|
DiagramEngine.prototype.load = function (state) {
|
|
8097
8304
|
var _this = this;
|
|
8098
8305
|
var patches = this.commandQueue.run(createLoadCommand(state), this.model);
|
|
8306
|
+
var linkColorPatches = this.assignOptionalLinkColorsOnLoad();
|
|
8099
8307
|
var mutationPatches = this.mutationPipeline.run({
|
|
8100
|
-
basePatches: patches,
|
|
8308
|
+
basePatches: __spreadArray(__spreadArray([], patches, true), linkColorPatches, true),
|
|
8101
8309
|
layoutSteps: [function () { return _this.applyAllLayouts(); }],
|
|
8102
8310
|
includeEmptyLinkRouting: true,
|
|
8103
8311
|
});
|
|
@@ -8381,6 +8589,24 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
8381
8589
|
var patches = this.commandQueue.run(createAddPortCommand(nextPort), this.model);
|
|
8382
8590
|
this.emitChange(patches);
|
|
8383
8591
|
};
|
|
8592
|
+
DiagramEngine.prototype.normalizePortDraftForElement = function (elementId, draft) {
|
|
8593
|
+
var _a;
|
|
8594
|
+
var element = this.model.getElement(elementId);
|
|
8595
|
+
if (!element)
|
|
8596
|
+
return null;
|
|
8597
|
+
var nextDraft = __assign(__assign({}, draft), { position: __assign({}, draft.position), size: draft.size ? __assign({}, draft.size) : undefined, style: draft.style ? __assign({}, draft.style) : undefined, textIds: draft.textIds ? __spreadArray([], draft.textIds, true) : undefined, placementPoint: draft.placementPoint ? __assign({}, draft.placementPoint) : undefined, linkAttachPoint: draft.linkAttachPoint ? __assign({}, draft.linkAttachPoint) : undefined, externalLinkAttachPoint: draft.externalLinkAttachPoint ? __assign({}, draft.externalLinkAttachPoint) : undefined, internalLinkAttachPoint: draft.internalLinkAttachPoint ? __assign({}, draft.internalLinkAttachPoint) : undefined, rotationPivot: draft.rotationPivot ? __assign({}, draft.rotationPivot) : undefined });
|
|
8598
|
+
var constrained = this.resolveConstrainedPortRelativePosition({
|
|
8599
|
+
position: nextDraft.position,
|
|
8600
|
+
size: nextDraft.size,
|
|
8601
|
+
style: nextDraft.style,
|
|
8602
|
+
moveMode: nextDraft.moveMode,
|
|
8603
|
+
anchorCenter: nextDraft.anchorCenter,
|
|
8604
|
+
currentAnchorId: nextDraft.currentAnchorId,
|
|
8605
|
+
}, element, nextDraft.position);
|
|
8606
|
+
nextDraft.position = constrained.position;
|
|
8607
|
+
nextDraft.currentAnchorId = (_a = constrained.currentAnchorId) !== null && _a !== void 0 ? _a : undefined;
|
|
8608
|
+
return nextDraft;
|
|
8609
|
+
};
|
|
8384
8610
|
DiagramEngine.prototype.movePortTo = function (id, x, y) {
|
|
8385
8611
|
var snapped = this.snapper.snap({ x: x, y: y });
|
|
8386
8612
|
var port = this.model.getPort(id);
|
|
@@ -9455,21 +9681,41 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
9455
9681
|
return this.linkRoutingService.routeLinksWithEmptyPoints();
|
|
9456
9682
|
};
|
|
9457
9683
|
DiagramEngine.prototype.applyOptionalLinkColor = function (link) {
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
var existingStyle = link.style;
|
|
9461
|
-
var hasExplicitStroke = existingStyle !== undefined &&
|
|
9462
|
-
Object.prototype.hasOwnProperty.call(existingStyle, 'stroke') &&
|
|
9463
|
-
existingStyle.stroke !== undefined &&
|
|
9464
|
-
existingStyle.stroke !== null &&
|
|
9465
|
-
"".concat(existingStyle.stroke).trim().length > 0;
|
|
9466
|
-
if (hasExplicitStroke)
|
|
9684
|
+
var style = this.resolveOptionalLinkColorStyle(link.style);
|
|
9685
|
+
if (style === link.style)
|
|
9467
9686
|
return link;
|
|
9687
|
+
return __assign(__assign({}, link), { style: style });
|
|
9688
|
+
};
|
|
9689
|
+
DiagramEngine.prototype.assignOptionalLinkColorsOnLoad = function () {
|
|
9690
|
+
var _this = this;
|
|
9691
|
+
if (!this.linkColorPoolPolicy.enabled || !this.linkColorPoolPolicy.assignOnLoadWhenMissingStroke) {
|
|
9692
|
+
return [];
|
|
9693
|
+
}
|
|
9694
|
+
var patches = [];
|
|
9695
|
+
this.model.links.forEach(function (link) {
|
|
9696
|
+
var style = _this.resolveOptionalLinkColorStyle(link.style);
|
|
9697
|
+
if (style === link.style)
|
|
9698
|
+
return;
|
|
9699
|
+
link.style = style;
|
|
9700
|
+
patches.push(patchUpdate('link', link.id, { style: style }));
|
|
9701
|
+
});
|
|
9702
|
+
return patches;
|
|
9703
|
+
};
|
|
9704
|
+
DiagramEngine.prototype.resolveOptionalLinkColorStyle = function (style) {
|
|
9705
|
+
if (!this.linkColorPoolPolicy.enabled || hasUsableLinkStroke(style)) {
|
|
9706
|
+
return style;
|
|
9707
|
+
}
|
|
9708
|
+
var stroke = this.pickOptionalLinkColor();
|
|
9709
|
+
if (!stroke)
|
|
9710
|
+
return style;
|
|
9711
|
+
return __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { stroke: stroke });
|
|
9712
|
+
};
|
|
9713
|
+
DiagramEngine.prototype.pickOptionalLinkColor = function () {
|
|
9468
9714
|
var colors = this.linkColorPoolPolicy.colors;
|
|
9469
9715
|
if (colors.length === 0)
|
|
9470
|
-
return
|
|
9716
|
+
return undefined;
|
|
9471
9717
|
var index = Math.max(0, Math.min(colors.length - 1, Math.floor(Math.random() * colors.length)));
|
|
9472
|
-
return
|
|
9718
|
+
return colors[index];
|
|
9473
9719
|
};
|
|
9474
9720
|
DiagramEngine.prototype.refreshLinksForRenderCycle = function () {
|
|
9475
9721
|
if (this.linkRouteRefreshPolicy.mode !== 'redraw-two-endpoint-change')
|
|
@@ -10710,6 +10956,7 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10710
10956
|
this.shapeHoverControls = this.normalizeShapeHoverControls(config.shapeHoverControls);
|
|
10711
10957
|
this.onShapeHoverControlInteracted = config.onShapeHoverControlInteracted;
|
|
10712
10958
|
this.onShapeHoverControlActivated = config.onShapeHoverControlActivated;
|
|
10959
|
+
this.onCreateLinkTargetPort = config.onCreateLinkTargetPort;
|
|
10713
10960
|
}
|
|
10714
10961
|
KonvaInteraction.prototype.setShapeHoverControls = function (controls) {
|
|
10715
10962
|
this.shapeHoverControls = this.normalizeShapeHoverControls(controls);
|
|
@@ -10726,6 +10973,9 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10726
10973
|
var sourceElementId = this.engine.getPortElementId(sourcePortId);
|
|
10727
10974
|
if (!sourceElementId)
|
|
10728
10975
|
return;
|
|
10976
|
+
var sourcePort = this.getPortById(sourcePortId);
|
|
10977
|
+
if (!sourcePort)
|
|
10978
|
+
return;
|
|
10729
10979
|
var sourcePoint = (_a = this.engine.getPortLinkWorldPosition(sourcePortId)) !== null && _a !== void 0 ? _a : this.engine.getPortWorldPosition(sourcePortId);
|
|
10730
10980
|
if (!sourcePoint)
|
|
10731
10981
|
return;
|
|
@@ -10742,6 +10992,7 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10742
10992
|
this.programmaticLinkSession = {
|
|
10743
10993
|
sourcePortId: sourcePortId,
|
|
10744
10994
|
sourceElementId: sourceElementId,
|
|
10995
|
+
sourcePort: this.clonePortData(sourcePort),
|
|
10745
10996
|
start: start,
|
|
10746
10997
|
current: start,
|
|
10747
10998
|
};
|
|
@@ -10751,6 +11002,7 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10751
11002
|
mode: 'link-drag',
|
|
10752
11003
|
sourcePortId: sourcePortId,
|
|
10753
11004
|
sourceElementId: sourceElementId,
|
|
11005
|
+
sourcePort: this.clonePortData(sourcePort),
|
|
10754
11006
|
start: start,
|
|
10755
11007
|
current: start,
|
|
10756
11008
|
isMulti: false,
|
|
@@ -10766,7 +11018,7 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10766
11018
|
}
|
|
10767
11019
|
};
|
|
10768
11020
|
KonvaInteraction.prototype.updateLinkPreview = function (pointer) {
|
|
10769
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
11021
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
10770
11022
|
if (this.programmaticLinkSession) {
|
|
10771
11023
|
this.programmaticLinkSession.current = __assign({}, pointer);
|
|
10772
11024
|
}
|
|
@@ -10778,28 +11030,29 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10778
11030
|
return;
|
|
10779
11031
|
}
|
|
10780
11032
|
var sourcePortId = (_c = (_b = this.programmaticLinkSession) === null || _b === void 0 ? void 0 : _b.sourcePortId) !== null && _c !== void 0 ? _c : (((_d = this.dragState) === null || _d === void 0 ? void 0 : _d.mode) === 'link-drag' ? this.dragState.sourcePortId : null);
|
|
11033
|
+
var sourceElementId = (_f = (_e = this.programmaticLinkSession) === null || _e === void 0 ? void 0 : _e.sourceElementId) !== null && _f !== void 0 ? _f : (((_g = this.dragState) === null || _g === void 0 ? void 0 : _g.mode) === 'link-drag' ? this.dragState.sourceElementId : null);
|
|
10781
11034
|
if (!sourcePortId)
|
|
10782
11035
|
return;
|
|
10783
11036
|
var source = this.resolveLinkPreviewSource(sourcePortId, pointer);
|
|
10784
11037
|
if (source) {
|
|
10785
|
-
(
|
|
11038
|
+
(_h = this.renderer) === null || _h === void 0 ? void 0 : _h.renderTempLink([source, pointer]);
|
|
10786
11039
|
}
|
|
10787
11040
|
var hit = this.resolveHit(pointer);
|
|
10788
|
-
if ((hit === null || hit === void 0 ? void 0 : hit.type) === 'element') {
|
|
10789
|
-
var placeholder = this.createPlaceholderPort(hit.id, pointer, sourcePortId);
|
|
11041
|
+
if ((hit === null || hit === void 0 ? void 0 : hit.type) === 'element' && sourceElementId) {
|
|
11042
|
+
var placeholder = this.createPlaceholderPort(hit.id, pointer, sourcePortId, sourceElementId);
|
|
10790
11043
|
if (placeholder) {
|
|
10791
11044
|
var hostElement = this.getElementById(hit.id);
|
|
10792
11045
|
if (hostElement) {
|
|
10793
|
-
var hostWorld = (
|
|
10794
|
-
(
|
|
11046
|
+
var hostWorld = (_j = this.engine.getElementWorldPosition(hit.id)) !== null && _j !== void 0 ? _j : hostElement.position;
|
|
11047
|
+
(_l = (_k = this.renderer) === null || _k === void 0 ? void 0 : _k.renderPortPlaceholder) === null || _l === void 0 ? void 0 : _l.call(_k, placeholder, { id: hostElement.id, position: hostWorld, size: hostElement.size, shapeId: hostElement.shapeId });
|
|
10795
11048
|
}
|
|
10796
11049
|
else {
|
|
10797
|
-
(
|
|
11050
|
+
(_o = (_m = this.renderer) === null || _m === void 0 ? void 0 : _m.renderPortPlaceholder) === null || _o === void 0 ? void 0 : _o.call(_m, placeholder);
|
|
10798
11051
|
}
|
|
10799
11052
|
}
|
|
10800
11053
|
return;
|
|
10801
11054
|
}
|
|
10802
|
-
(
|
|
11055
|
+
(_q = (_p = this.renderer) === null || _p === void 0 ? void 0 : _p.clearPortPlaceholder) === null || _q === void 0 ? void 0 : _q.call(_p);
|
|
10803
11056
|
};
|
|
10804
11057
|
KonvaInteraction.prototype.completeLinkToPort = function (targetPortId) {
|
|
10805
11058
|
var _a, _b;
|
|
@@ -10961,10 +11214,14 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
10961
11214
|
}
|
|
10962
11215
|
}
|
|
10963
11216
|
else {
|
|
11217
|
+
var sourcePort = _this.getPortById(hit.id);
|
|
11218
|
+
if (!sourcePort)
|
|
11219
|
+
return;
|
|
10964
11220
|
_this.dragState = {
|
|
10965
11221
|
mode: 'link-drag',
|
|
10966
11222
|
sourcePortId: hit.id,
|
|
10967
11223
|
sourceElementId: elementId,
|
|
11224
|
+
sourcePort: _this.clonePortData(sourcePort),
|
|
10968
11225
|
start: point,
|
|
10969
11226
|
current: point,
|
|
10970
11227
|
isMulti: isMulti,
|
|
@@ -11146,7 +11403,7 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
11146
11403
|
}
|
|
11147
11404
|
}
|
|
11148
11405
|
else if ((hit === null || hit === void 0 ? void 0 : hit.type) === 'element') {
|
|
11149
|
-
var placeholder = _this.createPlaceholderPort(hit.id, point, _this.dragState.sourcePortId);
|
|
11406
|
+
var placeholder = _this.createPlaceholderPort(hit.id, point, _this.dragState.sourcePortId, _this.dragState.sourceElementId);
|
|
11150
11407
|
if (placeholder) {
|
|
11151
11408
|
var hostElement = _this.getElementById(hit.id);
|
|
11152
11409
|
if (hostElement) {
|
|
@@ -12821,7 +13078,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12821
13078
|
return { createdLinkId: createdLinkId, targetPortId: targetPortId, targetElementId: targetElementId };
|
|
12822
13079
|
};
|
|
12823
13080
|
KonvaInteraction.prototype.tryCreateLinkToElement = function (sourcePortId, sourceElementId, targetElementId, worldPoint) {
|
|
12824
|
-
var
|
|
13081
|
+
var _a, _b;
|
|
13082
|
+
var targetPort = this.createPortForLink(targetElementId, worldPoint, sourcePortId, sourceElementId);
|
|
12825
13083
|
if (!targetPort) {
|
|
12826
13084
|
return { createdLinkId: null, targetPortId: null, targetElementId: null };
|
|
12827
13085
|
}
|
|
@@ -12837,7 +13095,10 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12837
13095
|
return { createdLinkId: null, targetPortId: targetPort.id, targetElementId: targetElementId };
|
|
12838
13096
|
}
|
|
12839
13097
|
this.engine.addPortToElement(targetElementId, targetPort);
|
|
12840
|
-
this.engine.
|
|
13098
|
+
var targetElementWorld = (_a = this.engine.getElementWorldPosition(targetElementId)) !== null && _a !== void 0 ? _a : (_b = this.getElementById(targetElementId)) === null || _b === void 0 ? void 0 : _b.position;
|
|
13099
|
+
if (targetElementWorld) {
|
|
13100
|
+
this.engine.movePortTo(targetPort.id, targetElementWorld.x + targetPort.position.x, targetElementWorld.y + targetPort.position.y);
|
|
13101
|
+
}
|
|
12841
13102
|
var createdLinkId = createId();
|
|
12842
13103
|
this.engine.addLink({
|
|
12843
13104
|
id: createdLinkId,
|
|
@@ -12847,61 +13108,139 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12847
13108
|
});
|
|
12848
13109
|
return { createdLinkId: createdLinkId, targetPortId: targetPort.id, targetElementId: targetElementId };
|
|
12849
13110
|
};
|
|
12850
|
-
KonvaInteraction.prototype.createPortForLink = function (elementId, worldPoint, sourcePortId) {
|
|
12851
|
-
var
|
|
12852
|
-
|
|
12853
|
-
if (!element)
|
|
13111
|
+
KonvaInteraction.prototype.createPortForLink = function (elementId, worldPoint, sourcePortId, sourceElementId) {
|
|
13112
|
+
var resolved = this.resolveLinkTargetPortDraft(elementId, worldPoint, sourcePortId, sourceElementId, 'commit');
|
|
13113
|
+
if (!resolved)
|
|
12854
13114
|
return null;
|
|
12855
|
-
var elementPosition = (_a = this.engine.getElementWorldPosition(elementId)) !== null && _a !== void 0 ? _a : element.position;
|
|
12856
|
-
var relative = {
|
|
12857
|
-
x: worldPoint.x - elementPosition.x,
|
|
12858
|
-
y: worldPoint.y - elementPosition.y,
|
|
12859
|
-
};
|
|
12860
|
-
var sourcePort = this.getPortById(sourcePortId);
|
|
12861
|
-
var destinationMoveMode = ((_b = element.portMovement) === null || _b === void 0 ? void 0 : _b.moveMode) && element.portMovement.moveMode !== 'anchors'
|
|
12862
|
-
? element.portMovement.moveMode
|
|
12863
|
-
: undefined;
|
|
12864
13115
|
return {
|
|
12865
13116
|
id: createId(),
|
|
12866
13117
|
elementId: elementId,
|
|
12867
|
-
position:
|
|
12868
|
-
shapeId:
|
|
12869
|
-
size:
|
|
12870
|
-
style:
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
13118
|
+
position: __assign({}, resolved.draft.position),
|
|
13119
|
+
shapeId: resolved.draft.shapeId,
|
|
13120
|
+
size: resolved.draft.size ? __assign({}, resolved.draft.size) : undefined,
|
|
13121
|
+
style: resolved.draft.style ? __assign({}, resolved.draft.style) : undefined,
|
|
13122
|
+
textIds: resolved.draft.textIds ? __spreadArray([], resolved.draft.textIds, true) : undefined,
|
|
13123
|
+
moveMode: resolved.draft.moveMode,
|
|
13124
|
+
anchorCenter: resolved.draft.anchorCenter,
|
|
13125
|
+
orientToHostBorder: resolved.draft.orientToHostBorder,
|
|
13126
|
+
placementPoint: resolved.draft.placementPoint ? __assign({}, resolved.draft.placementPoint) : undefined,
|
|
13127
|
+
linkAttachPoint: resolved.draft.linkAttachPoint ? __assign({}, resolved.draft.linkAttachPoint) : undefined,
|
|
13128
|
+
externalLinkAttachPoint: resolved.draft.externalLinkAttachPoint ? __assign({}, resolved.draft.externalLinkAttachPoint) : undefined,
|
|
13129
|
+
internalLinkAttachPoint: resolved.draft.internalLinkAttachPoint ? __assign({}, resolved.draft.internalLinkAttachPoint) : undefined,
|
|
13130
|
+
rotationPivot: resolved.draft.rotationPivot ? __assign({}, resolved.draft.rotationPivot) : undefined,
|
|
13131
|
+
currentAnchorId: resolved.draft.currentAnchorId,
|
|
12879
13132
|
};
|
|
12880
13133
|
};
|
|
12881
|
-
KonvaInteraction.prototype.createPlaceholderPort = function (elementId, worldPoint, sourcePortId) {
|
|
12882
|
-
var _a
|
|
12883
|
-
var
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
: undefined;
|
|
13134
|
+
KonvaInteraction.prototype.createPlaceholderPort = function (elementId, worldPoint, sourcePortId, sourceElementId) {
|
|
13135
|
+
var _a;
|
|
13136
|
+
var resolved = this.resolveLinkTargetPortDraft(elementId, worldPoint, sourcePortId, sourceElementId, 'preview');
|
|
13137
|
+
if (!resolved)
|
|
13138
|
+
return null;
|
|
13139
|
+
var hostWorld = (_a = this.engine.getElementWorldPosition(elementId)) !== null && _a !== void 0 ? _a : resolved.targetElement.position;
|
|
12888
13140
|
return {
|
|
12889
13141
|
id: "port-placeholder:".concat(sourcePortId),
|
|
12890
13142
|
elementId: elementId,
|
|
12891
|
-
position: {
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
13143
|
+
position: {
|
|
13144
|
+
x: hostWorld.x + resolved.draft.position.x,
|
|
13145
|
+
y: hostWorld.y + resolved.draft.position.y,
|
|
13146
|
+
},
|
|
13147
|
+
shapeId: resolved.draft.shapeId,
|
|
13148
|
+
size: resolved.draft.size ? __assign({}, resolved.draft.size) : undefined,
|
|
13149
|
+
style: resolved.draft.style ? __assign({}, resolved.draft.style) : undefined,
|
|
13150
|
+
textIds: resolved.draft.textIds ? __spreadArray([], resolved.draft.textIds, true) : undefined,
|
|
13151
|
+
moveMode: resolved.draft.moveMode,
|
|
13152
|
+
anchorCenter: resolved.draft.anchorCenter,
|
|
13153
|
+
orientToHostBorder: resolved.draft.orientToHostBorder,
|
|
13154
|
+
placementPoint: resolved.draft.placementPoint ? __assign({}, resolved.draft.placementPoint) : undefined,
|
|
13155
|
+
linkAttachPoint: resolved.draft.linkAttachPoint ? __assign({}, resolved.draft.linkAttachPoint) : undefined,
|
|
13156
|
+
externalLinkAttachPoint: resolved.draft.externalLinkAttachPoint ? __assign({}, resolved.draft.externalLinkAttachPoint) : undefined,
|
|
13157
|
+
internalLinkAttachPoint: resolved.draft.internalLinkAttachPoint ? __assign({}, resolved.draft.internalLinkAttachPoint) : undefined,
|
|
13158
|
+
rotationPivot: resolved.draft.rotationPivot ? __assign({}, resolved.draft.rotationPivot) : undefined,
|
|
13159
|
+
currentAnchorId: resolved.draft.currentAnchorId,
|
|
13160
|
+
};
|
|
13161
|
+
};
|
|
13162
|
+
KonvaInteraction.prototype.resolveLinkTargetPortDraft = function (elementId, worldPoint, sourcePortId, sourceElementId, phase) {
|
|
13163
|
+
var _a;
|
|
13164
|
+
var targetElement = this.getElementById(elementId);
|
|
13165
|
+
var sourcePort = this.resolveLinkSourcePort(sourcePortId);
|
|
13166
|
+
if (!targetElement || !sourcePort)
|
|
13167
|
+
return null;
|
|
13168
|
+
var defaultDraft = this.buildDefaultLinkTargetPortDraft(targetElement, worldPoint, sourcePort);
|
|
13169
|
+
var override = (_a = this.onCreateLinkTargetPort) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
13170
|
+
phase: phase,
|
|
13171
|
+
pointer: __assign({}, worldPoint),
|
|
13172
|
+
sourcePortId: sourcePortId,
|
|
13173
|
+
sourceElementId: sourceElementId,
|
|
13174
|
+
targetElementId: elementId,
|
|
13175
|
+
sourcePort: this.clonePortData(sourcePort),
|
|
13176
|
+
targetElement: this.cloneElementData(targetElement),
|
|
13177
|
+
defaultPort: this.cloneLinkTargetPortDraft(defaultDraft),
|
|
13178
|
+
});
|
|
13179
|
+
var mergedDraft = this.mergeLinkTargetPortDraft(defaultDraft, override);
|
|
13180
|
+
var normalizedDraft = this.engine.normalizePortDraftForElement(elementId, mergedDraft);
|
|
13181
|
+
if (!normalizedDraft)
|
|
13182
|
+
return null;
|
|
13183
|
+
return {
|
|
13184
|
+
draft: normalizedDraft,
|
|
13185
|
+
targetElement: this.cloneElementData(targetElement),
|
|
13186
|
+
};
|
|
13187
|
+
};
|
|
13188
|
+
KonvaInteraction.prototype.buildDefaultLinkTargetPortDraft = function (element, worldPoint, sourcePort) {
|
|
13189
|
+
var _a, _b, _c, _d;
|
|
13190
|
+
var elementPosition = (_a = this.engine.getElementWorldPosition(element.id)) !== null && _a !== void 0 ? _a : element.position;
|
|
13191
|
+
var destinationMoveMode = ((_b = element.portMovement) === null || _b === void 0 ? void 0 : _b.moveMode) && element.portMovement.moveMode !== 'anchors'
|
|
13192
|
+
? element.portMovement.moveMode
|
|
13193
|
+
: undefined;
|
|
13194
|
+
return {
|
|
13195
|
+
position: {
|
|
13196
|
+
x: worldPoint.x - elementPosition.x,
|
|
13197
|
+
y: worldPoint.y - elementPosition.y,
|
|
13198
|
+
},
|
|
13199
|
+
shapeId: sourcePort.shapeId,
|
|
13200
|
+
size: sourcePort.size ? __assign({}, sourcePort.size) : undefined,
|
|
13201
|
+
style: sourcePort.style ? __assign({}, sourcePort.style) : undefined,
|
|
13202
|
+
moveMode: destinationMoveMode !== null && destinationMoveMode !== void 0 ? destinationMoveMode : sourcePort.moveMode,
|
|
13203
|
+
anchorCenter: (_c = sourcePort.anchorCenter) !== null && _c !== void 0 ? _c : true,
|
|
13204
|
+
orientToHostBorder: (_d = sourcePort.orientToHostBorder) !== null && _d !== void 0 ? _d : true,
|
|
13205
|
+
placementPoint: sourcePort.placementPoint ? __assign({}, sourcePort.placementPoint) : undefined,
|
|
13206
|
+
linkAttachPoint: sourcePort.linkAttachPoint ? __assign({}, sourcePort.linkAttachPoint) : undefined,
|
|
13207
|
+
externalLinkAttachPoint: sourcePort.externalLinkAttachPoint ? __assign({}, sourcePort.externalLinkAttachPoint) : undefined,
|
|
13208
|
+
internalLinkAttachPoint: sourcePort.internalLinkAttachPoint ? __assign({}, sourcePort.internalLinkAttachPoint) : undefined,
|
|
13209
|
+
rotationPivot: sourcePort.rotationPivot ? __assign({}, sourcePort.rotationPivot) : undefined,
|
|
12903
13210
|
};
|
|
12904
13211
|
};
|
|
13212
|
+
KonvaInteraction.prototype.mergeLinkTargetPortDraft = function (defaultDraft, override) {
|
|
13213
|
+
return this.cloneLinkTargetPortDraft(__assign(__assign({}, defaultDraft), (override !== null && override !== void 0 ? override : {})));
|
|
13214
|
+
};
|
|
13215
|
+
KonvaInteraction.prototype.resolveLinkSourcePort = function (sourcePortId) {
|
|
13216
|
+
var _a, _b;
|
|
13217
|
+
if (((_a = this.programmaticLinkSession) === null || _a === void 0 ? void 0 : _a.sourcePortId) === sourcePortId) {
|
|
13218
|
+
return this.clonePortData(this.programmaticLinkSession.sourcePort);
|
|
13219
|
+
}
|
|
13220
|
+
if (((_b = this.dragState) === null || _b === void 0 ? void 0 : _b.mode) === 'link-drag' && this.dragState.sourcePortId === sourcePortId) {
|
|
13221
|
+
return this.clonePortData(this.dragState.sourcePort);
|
|
13222
|
+
}
|
|
13223
|
+
var sourcePort = this.getPortById(sourcePortId);
|
|
13224
|
+
return sourcePort ? this.clonePortData(sourcePort) : null;
|
|
13225
|
+
};
|
|
13226
|
+
KonvaInteraction.prototype.clonePortData = function (port) {
|
|
13227
|
+
return __assign(__assign({}, port), { position: __assign({}, port.position), size: port.size ? __assign({}, port.size) : undefined, style: port.style ? __assign({}, port.style) : undefined, textIds: port.textIds ? __spreadArray([], port.textIds, true) : undefined, placementPoint: port.placementPoint ? __assign({}, port.placementPoint) : undefined, linkAttachPoint: port.linkAttachPoint ? __assign({}, port.linkAttachPoint) : undefined, externalLinkAttachPoint: port.externalLinkAttachPoint ? __assign({}, port.externalLinkAttachPoint) : undefined, internalLinkAttachPoint: port.internalLinkAttachPoint ? __assign({}, port.internalLinkAttachPoint) : undefined, rotationPivot: port.rotationPivot ? __assign({}, port.rotationPivot) : undefined });
|
|
13228
|
+
};
|
|
13229
|
+
KonvaInteraction.prototype.cloneLinkTargetPortDraft = function (draft) {
|
|
13230
|
+
return __assign(__assign({}, draft), { position: __assign({}, draft.position), size: draft.size ? __assign({}, draft.size) : undefined, style: draft.style ? __assign({}, draft.style) : undefined, textIds: draft.textIds ? __spreadArray([], draft.textIds, true) : undefined, placementPoint: draft.placementPoint ? __assign({}, draft.placementPoint) : undefined, linkAttachPoint: draft.linkAttachPoint ? __assign({}, draft.linkAttachPoint) : undefined, externalLinkAttachPoint: draft.externalLinkAttachPoint ? __assign({}, draft.externalLinkAttachPoint) : undefined, internalLinkAttachPoint: draft.internalLinkAttachPoint ? __assign({}, draft.internalLinkAttachPoint) : undefined, rotationPivot: draft.rotationPivot ? __assign({}, draft.rotationPivot) : undefined });
|
|
13231
|
+
};
|
|
13232
|
+
KonvaInteraction.prototype.cloneElementData = function (element) {
|
|
13233
|
+
return __assign(__assign({}, element), { position: __assign({}, element.position), size: __assign({}, element.size), style: element.style ? __assign({}, element.style) : undefined, portIds: element.portIds ? __spreadArray([], element.portIds, true) : undefined, textIds: element.textIds ? __spreadArray([], element.textIds, true) : undefined, layout: element.layout ? __assign({}, element.layout) : undefined, childElementInteraction: element.childElementInteraction ? __assign({}, element.childElementInteraction) : undefined, portMovement: element.portMovement
|
|
13234
|
+
? __assign(__assign({}, element.portMovement), { anchorConstraint: element.portMovement.anchorConstraint
|
|
13235
|
+
? __assign({}, element.portMovement.anchorConstraint) : undefined, positionLimits: element.portMovement.positionLimits
|
|
13236
|
+
? {
|
|
13237
|
+
x: element.portMovement.positionLimits.x
|
|
13238
|
+
? __assign({}, element.portMovement.positionLimits.x) : undefined,
|
|
13239
|
+
y: element.portMovement.positionLimits.y
|
|
13240
|
+
? __assign({}, element.portMovement.positionLimits.y) : undefined,
|
|
13241
|
+
}
|
|
13242
|
+
: undefined }) : undefined });
|
|
13243
|
+
};
|
|
12905
13244
|
KonvaInteraction.prototype.getElementById = function (id) {
|
|
12906
13245
|
return this.engine.getState().elements.find(function (element) { return element.id === id; });
|
|
12907
13246
|
};
|
|
@@ -14018,6 +14357,7 @@ var createDiagramEditor = function (config) {
|
|
|
14018
14357
|
shapeHoverControls: config.elementShapeHoverControls,
|
|
14019
14358
|
onShapeHoverControlInteracted: config.onElementShapeHoverControlInteraction,
|
|
14020
14359
|
onShapeHoverControlActivated: config.onElementShapeHoverControlActivated,
|
|
14360
|
+
onCreateLinkTargetPort: config.onCreateLinkTargetPort,
|
|
14021
14361
|
});
|
|
14022
14362
|
interaction.bind();
|
|
14023
14363
|
if (config.initialState) {
|
|
@@ -14117,7 +14457,7 @@ var useDisplayBoxMetricsUpdater = function () {
|
|
|
14117
14457
|
};
|
|
14118
14458
|
|
|
14119
14459
|
var useDemoEditor = function (_a) {
|
|
14120
|
-
var createState = _a.createState, elementShapes = _a.elementShapes, portShapes = _a.portShapes, router = _a.router, snapDefault = _a.snapDefault, linkRouteRefreshPolicy = _a.linkRouteRefreshPolicy, linkColorPoolPolicy = _a.linkColorPoolPolicy, elementShapeHoverControls = _a.elementShapeHoverControls, onElementShapeHoverControlInteraction = _a.onElementShapeHoverControlInteraction, onElementShapeHoverControlActivated = _a.onElementShapeHoverControlActivated;
|
|
14460
|
+
var createState = _a.createState, elementShapes = _a.elementShapes, portShapes = _a.portShapes, router = _a.router, snapDefault = _a.snapDefault, linkRouteRefreshPolicy = _a.linkRouteRefreshPolicy, linkColorPoolPolicy = _a.linkColorPoolPolicy, elementShapeHoverControls = _a.elementShapeHoverControls, onElementShapeHoverControlInteraction = _a.onElementShapeHoverControlInteraction, onElementShapeHoverControlActivated = _a.onElementShapeHoverControlActivated, onCreateLinkTargetPort = _a.onCreateLinkTargetPort;
|
|
14121
14461
|
var containerRef = React.useRef(null);
|
|
14122
14462
|
var editorRef = React.useRef(null);
|
|
14123
14463
|
var _b = React.useState(null), diagramState = _b[0], setDiagramState = _b[1];
|
|
@@ -14164,6 +14504,7 @@ var useDemoEditor = function (_a) {
|
|
|
14164
14504
|
elementShapeHoverControls: elementShapeHoverControls,
|
|
14165
14505
|
onElementShapeHoverControlInteraction: onElementShapeHoverControlInteraction,
|
|
14166
14506
|
onElementShapeHoverControlActivated: onElementShapeHoverControlActivated,
|
|
14507
|
+
onCreateLinkTargetPort: onCreateLinkTargetPort,
|
|
14167
14508
|
onChange: function (event) {
|
|
14168
14509
|
setDiagramState(event.state);
|
|
14169
14510
|
var viewportPatch = event.patches.find(function (patch) { return patch.entity === 'viewport'; });
|
|
@@ -14211,6 +14552,7 @@ var useDemoEditor = function (_a) {
|
|
|
14211
14552
|
elementShapeHoverControls,
|
|
14212
14553
|
onElementShapeHoverControlInteraction,
|
|
14213
14554
|
onElementShapeHoverControlActivated,
|
|
14555
|
+
onCreateLinkTargetPort,
|
|
14214
14556
|
]);
|
|
14215
14557
|
return {
|
|
14216
14558
|
containerRef: containerRef,
|
|
@@ -14558,6 +14900,66 @@ var LinkCancelDemo = function () {
|
|
|
14558
14900
|
React.createElement(DisplayBoxStage, { containerRef: containerRef })));
|
|
14559
14901
|
};
|
|
14560
14902
|
|
|
14903
|
+
var LinkPortCreationDemo = function () {
|
|
14904
|
+
var _a = React.useState(false), useHostTargetPort = _a[0], setUseHostTargetPort = _a[1];
|
|
14905
|
+
var onCreateLinkTargetPort = React.useMemo(function () {
|
|
14906
|
+
if (!useHostTargetPort)
|
|
14907
|
+
return undefined;
|
|
14908
|
+
return function (_a) {
|
|
14909
|
+
var defaultPort = _a.defaultPort;
|
|
14910
|
+
return ({
|
|
14911
|
+
shapeId: 'port-dark',
|
|
14912
|
+
size: { width: 16, height: 16 },
|
|
14913
|
+
style: {
|
|
14914
|
+
fill: '#f97316',
|
|
14915
|
+
stroke: '#9a3412',
|
|
14916
|
+
strokeWidth: 2,
|
|
14917
|
+
name: 'port',
|
|
14918
|
+
},
|
|
14919
|
+
position: {
|
|
14920
|
+
x: defaultPort.position.x,
|
|
14921
|
+
y: 24,
|
|
14922
|
+
},
|
|
14923
|
+
orientToHostBorder: false,
|
|
14924
|
+
});
|
|
14925
|
+
};
|
|
14926
|
+
}, [useHostTargetPort]);
|
|
14927
|
+
var _b = useDemoEditor({
|
|
14928
|
+
createState: linkPortCreationDemoConfig.createState,
|
|
14929
|
+
elementShapes: linkPortCreationDemoConfig.elementShapes,
|
|
14930
|
+
portShapes: linkPortCreationDemoConfig.portShapes,
|
|
14931
|
+
router: linkPortCreationDemoConfig.router,
|
|
14932
|
+
snapDefault: linkPortCreationDemoConfig.snapDefault,
|
|
14933
|
+
linkRouteRefreshPolicy: linkPortCreationDemoConfig.linkRouteRefreshPolicy,
|
|
14934
|
+
linkColorPoolPolicy: linkPortCreationDemoConfig.linkColorPoolPolicy,
|
|
14935
|
+
onCreateLinkTargetPort: onCreateLinkTargetPort,
|
|
14936
|
+
}), containerRef = _b.containerRef, editorRef = _b.editorRef, diagramState = _b.diagramState, selection = _b.selection, snapEnabled = _b.snapEnabled, setSnapEnabled = _b.setSnapEnabled;
|
|
14937
|
+
var nextOffset = useOffsetSequence();
|
|
14938
|
+
var actionHelpers = React.useMemo(function () { return ({ nextOffset: nextOffset }); }, [nextOffset]);
|
|
14939
|
+
var controls = useDemoControls({
|
|
14940
|
+
demo: linkPortCreationDemoConfig,
|
|
14941
|
+
editorRef: editorRef,
|
|
14942
|
+
diagramState: diagramState,
|
|
14943
|
+
selection: selection,
|
|
14944
|
+
snapEnabled: snapEnabled,
|
|
14945
|
+
setSnapEnabled: setSnapEnabled,
|
|
14946
|
+
actionHelpers: actionHelpers,
|
|
14947
|
+
});
|
|
14948
|
+
return (React.createElement("section", null,
|
|
14949
|
+
React.createElement("div", { style: { marginBottom: 12 } },
|
|
14950
|
+
React.createElement("h2", { style: { marginTop: 0, marginBottom: 4 } }, linkPortCreationDemoConfig.title),
|
|
14951
|
+
React.createElement("p", { style: { marginTop: 0, marginBottom: 8 } }, linkPortCreationDemoConfig.description),
|
|
14952
|
+
React.createElement("label", { style: { display: 'inline-flex', alignItems: 'center', gap: 8, fontWeight: 600 } },
|
|
14953
|
+
React.createElement("input", { type: "checkbox", checked: useHostTargetPort, onChange: function (event) { return setUseHostTargetPort(event.target.checked); } }),
|
|
14954
|
+
"Customize target port via onCreateLinkTargetPort"),
|
|
14955
|
+
React.createElement("p", { style: { marginTop: 8, marginBottom: 0, color: '#5c4a2c' } },
|
|
14956
|
+
"Default mode clones the source port. Custom mode reshapes the target-port preview and commit together; host cancellation still belongs to ",
|
|
14957
|
+
React.createElement("code", null, "elementLinkConnecting"),
|
|
14958
|
+
".")),
|
|
14959
|
+
React.createElement(DisplayBoxControls, { actions: linkPortCreationDemoConfig.actions, snapEnabled: controls.snapEnabled, selectedLinkRouting: controls.selectedLinkRouting, canToggleLinkRouting: controls.canToggleLinkRouting, onReload: controls.handleReload, onZoomIn: controls.handleZoomIn, onZoomOut: controls.handleZoomOut, onResetViewport: controls.handleResetViewport, onToggleSnap: controls.handleToggleSnap, onManualRender: controls.handleManualRender, onToggleLinkRouting: controls.handleToggleLinkRouting, onAction: controls.handleAction, onExportImage: controls.handleExportImage, onClearExportPreview: controls.handleClearExportPreview, exportPreviewDataUrl: controls.exportPreviewDataUrl, exportError: controls.exportError }),
|
|
14960
|
+
React.createElement(DisplayBoxStage, { containerRef: containerRef, stageStyle: linkPortCreationDemoConfig.stageStyle })));
|
|
14961
|
+
};
|
|
14962
|
+
|
|
14561
14963
|
var parentOptions = [
|
|
14562
14964
|
{ id: 'layout-row', label: 'Horizontal layout' },
|
|
14563
14965
|
{ id: 'layout-column', label: 'Vertical layout' },
|
|
@@ -16493,9 +16895,10 @@ var LinkColorPoolDemo = function () {
|
|
|
16493
16895
|
var linkColorPoolPolicy = React.useMemo(function () {
|
|
16494
16896
|
if (mode === 'off')
|
|
16495
16897
|
return undefined;
|
|
16496
|
-
if (mode === 'default')
|
|
16497
|
-
return { enabled: true };
|
|
16498
|
-
|
|
16898
|
+
if (mode === 'default') {
|
|
16899
|
+
return { enabled: true, assignOnLoadWhenMissingStroke: true };
|
|
16900
|
+
}
|
|
16901
|
+
return { enabled: true, assignOnLoadWhenMissingStroke: true, colors: customPool };
|
|
16499
16902
|
}, [mode]);
|
|
16500
16903
|
return (React.createElement(SimpleDemo, { demo: linkColorPoolDemoConfig, linkColorPoolPolicy: linkColorPoolPolicy, beforeStage: React.createElement("div", { style: {
|
|
16501
16904
|
marginBottom: 12,
|
|
@@ -16507,9 +16910,10 @@ var LinkColorPoolDemo = function () {
|
|
|
16507
16910
|
React.createElement("label", { htmlFor: "link-color-mode", style: { display: 'inline-flex', alignItems: 'center', gap: 8, fontWeight: 600 } },
|
|
16508
16911
|
"Color Mode",
|
|
16509
16912
|
React.createElement("select", { id: "link-color-mode", value: mode, onChange: function (event) { return setMode(event.target.value); } },
|
|
16510
|
-
React.createElement("option", { value: "off" }, "Off (
|
|
16511
|
-
React.createElement("option", { value: "default" }, "Default
|
|
16512
|
-
React.createElement("option", { value: "custom" }, "Custom pool (#0b7285, #e8590c, #5f3dc4)")))
|
|
16913
|
+
React.createElement("option", { value: "off" }, "Off (no load fill)"),
|
|
16914
|
+
React.createElement("option", { value: "default" }, "Default pool load fill"),
|
|
16915
|
+
React.createElement("option", { value: "custom" }, "Custom pool load fill (#0b7285, #e8590c, #5f3dc4)"))),
|
|
16916
|
+
React.createElement("p", { style: { margin: '8px 0 0', fontSize: 13 } }, "Switching modes recreates the demo so the seeded loaded links can prove whether missing and blank strokes are filled, while explicit loaded strokes stay untouched.")) }));
|
|
16513
16917
|
};
|
|
16514
16918
|
|
|
16515
16919
|
var sidePositions = {
|
|
@@ -16921,218 +17325,86 @@ var VertexControlLinkSessionDemo = function () {
|
|
|
16921
17325
|
};
|
|
16922
17326
|
|
|
16923
17327
|
var wrapSimpleDemo = function (demo) { return function () { return React.createElement(SimpleDemo, { demo: demo }); }; };
|
|
16924
|
-
var
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
16954
|
-
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
id: shapeGalleryDemoConfig.id,
|
|
17005
|
-
title: shapeGalleryDemoConfig.title,
|
|
17006
|
-
description: shapeGalleryDemoConfig.description,
|
|
17007
|
-
Component: wrapSimpleDemo(shapeGalleryDemoConfig),
|
|
17008
|
-
},
|
|
17009
|
-
{
|
|
17010
|
-
id: roundedRectRadiusDemoConfig.id,
|
|
17011
|
-
title: roundedRectRadiusDemoConfig.title,
|
|
17012
|
-
description: roundedRectRadiusDemoConfig.description,
|
|
17013
|
-
Component: wrapSimpleDemo(roundedRectRadiusDemoConfig),
|
|
17014
|
-
},
|
|
17015
|
-
{
|
|
17016
|
-
id: rotatedCreationDemoConfig.id,
|
|
17017
|
-
title: rotatedCreationDemoConfig.title,
|
|
17018
|
-
description: rotatedCreationDemoConfig.description,
|
|
17019
|
-
Component: wrapSimpleDemo(rotatedCreationDemoConfig),
|
|
17020
|
-
},
|
|
17021
|
-
{
|
|
17022
|
-
id: svgPathDemoConfig.id,
|
|
17023
|
-
title: svgPathDemoConfig.title,
|
|
17024
|
-
description: svgPathDemoConfig.description,
|
|
17025
|
-
Component: SvgPathDemo,
|
|
17026
|
-
},
|
|
17027
|
-
{
|
|
17028
|
-
id: asymmetricPortMultiAnchorDemoConfig.id,
|
|
17029
|
-
title: asymmetricPortMultiAnchorDemoConfig.title,
|
|
17030
|
-
description: asymmetricPortMultiAnchorDemoConfig.description,
|
|
17031
|
-
Component: AsymmetricPortMultiAnchorDemo,
|
|
17032
|
-
},
|
|
17033
|
-
{
|
|
17034
|
-
id: multiLevelTreeDemoConfig.id,
|
|
17035
|
-
title: multiLevelTreeDemoConfig.title,
|
|
17036
|
-
description: multiLevelTreeDemoConfig.description,
|
|
17037
|
-
Component: wrapSimpleDemo(multiLevelTreeDemoConfig),
|
|
17038
|
-
},
|
|
17039
|
-
{
|
|
17040
|
-
id: multipleElementsDemoConfig.id,
|
|
17041
|
-
title: multipleElementsDemoConfig.title,
|
|
17042
|
-
description: multipleElementsDemoConfig.description,
|
|
17043
|
-
Component: wrapSimpleDemo(multipleElementsDemoConfig),
|
|
17044
|
-
},
|
|
17045
|
-
{
|
|
17046
|
-
id: portConstraintsDemoConfig.id,
|
|
17047
|
-
title: portConstraintsDemoConfig.title,
|
|
17048
|
-
description: portConstraintsDemoConfig.description,
|
|
17049
|
-
Component: wrapSimpleDemo(portConstraintsDemoConfig),
|
|
17050
|
-
},
|
|
17051
|
-
{
|
|
17052
|
-
id: portPositionLimitsDemoConfig.id,
|
|
17053
|
-
title: portPositionLimitsDemoConfig.title,
|
|
17054
|
-
description: portPositionLimitsDemoConfig.description,
|
|
17055
|
-
Component: wrapSimpleDemo(portPositionLimitsDemoConfig),
|
|
17056
|
-
},
|
|
17057
|
-
{
|
|
17058
|
-
id: labelStyleDemoConfig.id,
|
|
17059
|
-
title: labelStyleDemoConfig.title,
|
|
17060
|
-
description: labelStyleDemoConfig.description,
|
|
17061
|
-
Component: wrapSimpleDemo(labelStyleDemoConfig),
|
|
17062
|
-
},
|
|
17063
|
-
{
|
|
17064
|
-
id: linkColorPoolDemoConfig.id,
|
|
17065
|
-
title: linkColorPoolDemoConfig.title,
|
|
17066
|
-
description: linkColorPoolDemoConfig.description,
|
|
17067
|
-
Component: LinkColorPoolDemo,
|
|
17068
|
-
},
|
|
17069
|
-
{
|
|
17070
|
-
id: portBorderDemoConfig.id,
|
|
17071
|
-
title: portBorderDemoConfig.title,
|
|
17072
|
-
description: portBorderDemoConfig.description,
|
|
17073
|
-
Component: wrapSimpleDemo(portBorderDemoConfig),
|
|
17074
|
-
},
|
|
17075
|
-
{
|
|
17076
|
-
id: shapeBorderMovementDemoConfig.id,
|
|
17077
|
-
title: shapeBorderMovementDemoConfig.title,
|
|
17078
|
-
description: shapeBorderMovementDemoConfig.description,
|
|
17079
|
-
Component: wrapSimpleDemo(shapeBorderMovementDemoConfig),
|
|
17080
|
-
},
|
|
17081
|
-
{
|
|
17082
|
-
id: shapeHoverControlsDemoConfig.id,
|
|
17083
|
-
title: shapeHoverControlsDemoConfig.title,
|
|
17084
|
-
description: shapeHoverControlsDemoConfig.description,
|
|
17085
|
-
Component: ShapeHoverControlsDemo,
|
|
17086
|
-
},
|
|
17087
|
-
{
|
|
17088
|
-
id: vertexControlLinkSessionDemoConfig.id,
|
|
17089
|
-
title: vertexControlLinkSessionDemoConfig.title,
|
|
17090
|
-
description: vertexControlLinkSessionDemoConfig.description,
|
|
17091
|
-
Component: VertexControlLinkSessionDemo,
|
|
17092
|
-
},
|
|
17093
|
-
{
|
|
17094
|
-
id: childConstraintsDemoConfig.id,
|
|
17095
|
-
title: childConstraintsDemoConfig.title,
|
|
17096
|
-
description: childConstraintsDemoConfig.description,
|
|
17097
|
-
Component: wrapSimpleDemo(childConstraintsDemoConfig),
|
|
17098
|
-
},
|
|
17099
|
-
{
|
|
17100
|
-
id: gridOverlayDemoConfig.id,
|
|
17101
|
-
title: gridOverlayDemoConfig.title,
|
|
17102
|
-
description: gridOverlayDemoConfig.description,
|
|
17103
|
-
Component: wrapSimpleDemo(gridOverlayDemoConfig),
|
|
17104
|
-
},
|
|
17105
|
-
{
|
|
17106
|
-
id: routingDemoConfig.id,
|
|
17107
|
-
title: routingDemoConfig.title,
|
|
17108
|
-
description: routingDemoConfig.description,
|
|
17109
|
-
Component: wrapSimpleDemo(routingDemoConfig),
|
|
17110
|
-
},
|
|
17111
|
-
{
|
|
17112
|
-
id: obstacleRoutingDemoConfig.id,
|
|
17113
|
-
title: obstacleRoutingDemoConfig.title,
|
|
17114
|
-
description: obstacleRoutingDemoConfig.description,
|
|
17115
|
-
Component: ObstacleRoutingDemo,
|
|
17116
|
-
},
|
|
17117
|
-
{
|
|
17118
|
-
id: offsetAnchorAvoidanceDemoConfig.id,
|
|
17119
|
-
title: offsetAnchorAvoidanceDemoConfig.title,
|
|
17120
|
-
description: offsetAnchorAvoidanceDemoConfig.description,
|
|
17121
|
-
Component: OffsetAnchorAvoidanceDemo,
|
|
17122
|
-
},
|
|
17123
|
-
{
|
|
17124
|
-
id: zoomToFitElementsDemoConfig.id,
|
|
17125
|
-
title: zoomToFitElementsDemoConfig.title,
|
|
17126
|
-
description: zoomToFitElementsDemoConfig.description,
|
|
17127
|
-
Component: ZoomToFitElementsDemo,
|
|
17128
|
-
},
|
|
17129
|
-
{
|
|
17130
|
-
id: linkBendHandlesDemoConfig.id,
|
|
17131
|
-
title: linkBendHandlesDemoConfig.title,
|
|
17132
|
-
description: linkBendHandlesDemoConfig.description,
|
|
17133
|
-
Component: wrapSimpleDemo(linkBendHandlesDemoConfig),
|
|
17134
|
-
},
|
|
17135
|
-
];
|
|
17328
|
+
var menuGroupOrder = {
|
|
17329
|
+
basics: 1,
|
|
17330
|
+
layoutText: 2,
|
|
17331
|
+
shapes: 3,
|
|
17332
|
+
portsAnchors: 4,
|
|
17333
|
+
linksRouting: 5,
|
|
17334
|
+
eventsIntegration: 6,
|
|
17335
|
+
};
|
|
17336
|
+
var registerDemo = function (demo, Component, menuGroup, menuOrder) { return ({
|
|
17337
|
+
demo: demo,
|
|
17338
|
+
Component: Component,
|
|
17339
|
+
menuGroup: menuGroup,
|
|
17340
|
+
menuOrder: menuOrder,
|
|
17341
|
+
}); };
|
|
17342
|
+
var toDemoDefinition = function (_a) {
|
|
17343
|
+
var demo = _a.demo, Component = _a.Component, menuGroup = _a.menuGroup, menuOrder = _a.menuOrder;
|
|
17344
|
+
return ({
|
|
17345
|
+
id: demo.id,
|
|
17346
|
+
title: demo.title,
|
|
17347
|
+
description: demo.description,
|
|
17348
|
+
Component: Component,
|
|
17349
|
+
menuGroup: menuGroup,
|
|
17350
|
+
menuOrder: menuOrder,
|
|
17351
|
+
});
|
|
17352
|
+
};
|
|
17353
|
+
var compareDemoDefinitions = function (left, right) {
|
|
17354
|
+
return menuGroupOrder[left.menuGroup] - menuGroupOrder[right.menuGroup]
|
|
17355
|
+
|| left.menuOrder - right.menuOrder
|
|
17356
|
+
|| left.title.localeCompare(right.title);
|
|
17357
|
+
};
|
|
17358
|
+
var basics = [
|
|
17359
|
+
registerDemo(basicDemoConfig, wrapSimpleDemo(basicDemoConfig), 'basics', 1),
|
|
17360
|
+
registerDemo(multipleElementsDemoConfig, wrapSimpleDemo(multipleElementsDemoConfig), 'basics', 2),
|
|
17361
|
+
registerDemo(nestedDemoConfig, wrapSimpleDemo(nestedDemoConfig), 'basics', 3),
|
|
17362
|
+
registerDemo(selectionDemoConfig, wrapSimpleDemo(selectionDemoConfig), 'basics', 4),
|
|
17363
|
+
registerDemo(elementVisibilitySelectionDemoConfig, wrapSimpleDemo(elementVisibilitySelectionDemoConfig), 'basics', 5),
|
|
17364
|
+
registerDemo(zoomToFitElementsDemoConfig, ZoomToFitElementsDemo, 'basics', 6),
|
|
17365
|
+
];
|
|
17366
|
+
var layoutAndText = [
|
|
17367
|
+
registerDemo(textDemoConfig, TextLayoutDemo, 'layoutText', 1),
|
|
17368
|
+
registerDemo(labelStyleDemoConfig, wrapSimpleDemo(labelStyleDemoConfig), 'layoutText', 2),
|
|
17369
|
+
registerDemo(autoLayoutDemoConfig, AutoLayoutDemo, 'layoutText', 3),
|
|
17370
|
+
registerDemo(multiLevelTreeDemoConfig, wrapSimpleDemo(multiLevelTreeDemoConfig), 'layoutText', 4),
|
|
17371
|
+
registerDemo(childConstraintsDemoConfig, wrapSimpleDemo(childConstraintsDemoConfig), 'layoutText', 5),
|
|
17372
|
+
registerDemo(gridOverlayDemoConfig, wrapSimpleDemo(gridOverlayDemoConfig), 'layoutText', 6),
|
|
17373
|
+
];
|
|
17374
|
+
var shapes = [
|
|
17375
|
+
registerDemo(customDemoConfig, wrapSimpleDemo(customDemoConfig), 'shapes', 1),
|
|
17376
|
+
registerDemo(shapeGalleryDemoConfig, wrapSimpleDemo(shapeGalleryDemoConfig), 'shapes', 2),
|
|
17377
|
+
registerDemo(roundedRectRadiusDemoConfig, wrapSimpleDemo(roundedRectRadiusDemoConfig), 'shapes', 3),
|
|
17378
|
+
registerDemo(rotatedCreationDemoConfig, wrapSimpleDemo(rotatedCreationDemoConfig), 'shapes', 4),
|
|
17379
|
+
registerDemo(svgPathDemoConfig, SvgPathDemo, 'shapes', 5),
|
|
17380
|
+
registerDemo(shapeBorderMovementDemoConfig, wrapSimpleDemo(shapeBorderMovementDemoConfig), 'shapes', 6),
|
|
17381
|
+
registerDemo(shapeHoverControlsDemoConfig, ShapeHoverControlsDemo, 'shapes', 7),
|
|
17382
|
+
];
|
|
17383
|
+
var portsAndAnchors = [
|
|
17384
|
+
registerDemo(linkPortCreationDemoConfig, LinkPortCreationDemo, 'portsAnchors', 1),
|
|
17385
|
+
registerDemo(portConstraintsDemoConfig, wrapSimpleDemo(portConstraintsDemoConfig), 'portsAnchors', 2),
|
|
17386
|
+
registerDemo(portPositionLimitsDemoConfig, wrapSimpleDemo(portPositionLimitsDemoConfig), 'portsAnchors', 3),
|
|
17387
|
+
registerDemo(portBorderDemoConfig, wrapSimpleDemo(portBorderDemoConfig), 'portsAnchors', 4),
|
|
17388
|
+
registerDemo(asymmetricPortMultiAnchorDemoConfig, AsymmetricPortMultiAnchorDemo, 'portsAnchors', 5),
|
|
17389
|
+
];
|
|
17390
|
+
var linksAndRouting = [
|
|
17391
|
+
registerDemo(linkCancelDemoConfig, LinkCancelDemo, 'linksRouting', 1),
|
|
17392
|
+
registerDemo(linkBendHandlesDemoConfig, wrapSimpleDemo(linkBendHandlesDemoConfig), 'linksRouting', 2),
|
|
17393
|
+
registerDemo(linkLabelsDemoConfig, wrapSimpleDemo(linkLabelsDemoConfig), 'linksRouting', 3),
|
|
17394
|
+
registerDemo(linkColorPoolDemoConfig, LinkColorPoolDemo, 'linksRouting', 4),
|
|
17395
|
+
registerDemo(routingDemoConfig, wrapSimpleDemo(routingDemoConfig), 'linksRouting', 5),
|
|
17396
|
+
registerDemo(obstacleRoutingDemoConfig, ObstacleRoutingDemo, 'linksRouting', 6),
|
|
17397
|
+
registerDemo(offsetAnchorAvoidanceDemoConfig, OffsetAnchorAvoidanceDemo, 'linksRouting', 7),
|
|
17398
|
+
registerDemo(vertexControlLinkSessionDemoConfig, VertexControlLinkSessionDemo, 'linksRouting', 8),
|
|
17399
|
+
];
|
|
17400
|
+
var eventsAndIntegration = [
|
|
17401
|
+
registerDemo(eventHandlersDemoConfig, EventHandlersDemo, 'eventsIntegration', 1),
|
|
17402
|
+
registerDemo(engineEventsDemoConfig, EngineEventsDemo, 'eventsIntegration', 2),
|
|
17403
|
+
registerDemo(deletionEventsDemoConfig, DeletionEventsDemo, 'eventsIntegration', 3),
|
|
17404
|
+
registerDemo(externalDragDropDemoConfig, ExternalDragDropDemo, 'eventsIntegration', 4),
|
|
17405
|
+
];
|
|
17406
|
+
var demoTabs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], basics, true), layoutAndText, true), shapes, true), portsAndAnchors, true), linksAndRouting, true), eventsAndIntegration, true).map(toDemoDefinition)
|
|
17407
|
+
.sort(compareDemoDefinitions);
|
|
17136
17408
|
|
|
17137
17409
|
exports.baseElementShapes = baseElementShapes;
|
|
17138
17410
|
exports.basePortShapes = basePortShapes;
|