orcasvn-react-diagrams 0.2.10 → 0.2.11
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 +11 -0
- package/README.md +7 -8
- package/ai/api-contract.json +1 -0
- package/ai/manifest.json +1 -1
- package/dist/cjs/examples.js +133 -67
- package/dist/cjs/index.js +42 -13
- package/dist/cjs/types/api/types.d.ts +1 -0
- package/dist/cjs/types/displaybox/demos/linkColorPoolDemo.d.ts +2 -0
- package/dist/cjs/types/engine/DiagramEngine.d.ts +3 -0
- package/dist/esm/examples.js +133 -67
- package/dist/esm/examples.js.map +1 -1
- package/dist/esm/index.js +42 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api/types.d.ts +1 -0
- package/dist/esm/types/displaybox/demos/linkColorPoolDemo.d.ts +2 -0
- package/dist/esm/types/engine/DiagramEngine.d.ts +3 -0
- package/dist/examples.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/docs/API_CONTRACT.md +4 -1
- package/docs/CAPABILITIES.md +1 -1
- package/docs/DOCUMENTATION_WORKFLOW.md +3 -1
- package/docs/INTEGRATION_PLAYBOOK.md +1 -0
- package/package.json +1 -1
- package/src/displaybox/demos/LinkColorPoolDemoTab.tsx +10 -5
- package/src/displaybox/demos/linkColorPoolDemo.ts +84 -49
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.11] - 2026-06-20
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `LinkColorPoolPolicy.assignOnLoadWhenMissingStroke` for opt-in load-time random `style.stroke` assignment on links that load without a usable stroke value.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Load-time link color fill now preserves explicit loaded `style.stroke` values, treats missing/`null`/blank strokes as fill candidates, and uses the active custom-or-default color pool only when the policy is enabled.
|
|
12
|
+
|
|
13
|
+
### Docs
|
|
14
|
+
- Updated release highlights, public API/docs contract text, integration guidance, and machine-readable contract metadata for `v0.2.11`.
|
|
15
|
+
|
|
5
16
|
## [0.2.10] - 2026-05-27
|
|
6
17
|
|
|
7
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -30,14 +30,13 @@ editor.addElement({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
## Release Highlights (v0.2.
|
|
34
|
-
|
|
35
|
-
- Includes all completed `v0.2.1` through `v0.2.
|
|
36
|
-
- `v0.2.
|
|
37
|
-
- `
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
- `ElementData.selectable = false` keeps the element visible while preventing built-in element-body click/marquee/programmatic selection from retaining that element id
|
|
33
|
+
## Release Highlights (v0.2.11)
|
|
34
|
+
|
|
35
|
+
- Includes all completed `v0.2.1` through `v0.2.10` work, plus `v0.2.11` updates.
|
|
36
|
+
- `v0.2.11` link color pool load-time fill:
|
|
37
|
+
- `linkColorPoolPolicy.assignOnLoadWhenMissingStroke = true` backfills loaded links whose `style.stroke` is missing, `null`, or blank after trimming
|
|
38
|
+
- explicit non-empty loaded `style.stroke` values are preserved exactly as loaded
|
|
39
|
+
- the fill uses normalized custom `colors` when provided, otherwise the built-in 20-color pool
|
|
41
40
|
|
|
42
41
|
## API Docs
|
|
43
42
|
|
package/ai/api-contract.json
CHANGED
package/ai/manifest.json
CHANGED
package/dist/cjs/examples.js
CHANGED
|
@@ -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
3515
|
size: { width: 190, height: 120 },
|
|
3516
3516
|
shapeId: 'default',
|
|
3517
3517
|
},
|
|
3518
3518
|
{
|
|
3519
|
-
id: 'lc-
|
|
3520
|
-
position: { x:
|
|
3519
|
+
id: 'lc-load-explicit-target',
|
|
3520
|
+
position: { x: 350, y: 540 },
|
|
3521
3521
|
size: { width: 190, height: 120 },
|
|
3522
3522
|
shapeId: 'default',
|
|
3523
3523
|
},
|
|
3524
|
+
{
|
|
3525
|
+
id: 'lc-create-auto-source',
|
|
3526
|
+
position: { x: 620, y: 250 },
|
|
3527
|
+
size: { width: 190, height: 120 },
|
|
3528
|
+
shapeId: 'default',
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
id: 'lc-create-auto-target',
|
|
3532
|
+
position: { x: 620, y: 420 },
|
|
3533
|
+
size: { width: 190, height: 120 },
|
|
3534
|
+
shapeId: 'default',
|
|
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,38 +3604,30 @@ var linkColorPoolDemoConfig = {
|
|
|
3561
3604
|
defaultPortShapeId: 'port-circle',
|
|
3562
3605
|
actions: [
|
|
3563
3606
|
{
|
|
3564
|
-
id: 'add-link-
|
|
3565
|
-
label: 'Add
|
|
3566
|
-
run: function (editor) {
|
|
3567
|
-
editor.addLink({
|
|
3568
|
-
id: "link-color-off-".concat(createId()),
|
|
3569
|
-
sourcePortId: 'lc-off-source-port',
|
|
3570
|
-
targetPortId: 'lc-off-target-port',
|
|
3571
|
-
points: [],
|
|
3572
|
-
});
|
|
3573
|
-
},
|
|
3574
|
-
},
|
|
3575
|
-
{
|
|
3576
|
-
id: 'add-link-default-pair',
|
|
3577
|
-
label: 'Add link (default pair)',
|
|
3607
|
+
id: 'add-link-create-auto',
|
|
3608
|
+
label: 'Add new unstyled link',
|
|
3578
3609
|
run: function (editor) {
|
|
3579
3610
|
editor.addLink({
|
|
3580
|
-
id: "link-color-
|
|
3581
|
-
sourcePortId: 'lc-
|
|
3582
|
-
targetPortId: 'lc-
|
|
3611
|
+
id: "link-color-create-auto-".concat(createId()),
|
|
3612
|
+
sourcePortId: 'lc-create-auto-source-port',
|
|
3613
|
+
targetPortId: 'lc-create-auto-target-port',
|
|
3583
3614
|
points: [],
|
|
3584
3615
|
});
|
|
3585
3616
|
},
|
|
3586
3617
|
},
|
|
3587
3618
|
{
|
|
3588
|
-
id: 'add-link-
|
|
3589
|
-
label: 'Add
|
|
3619
|
+
id: 'add-link-create-explicit',
|
|
3620
|
+
label: 'Add new explicit-stroke link',
|
|
3590
3621
|
run: function (editor) {
|
|
3591
3622
|
editor.addLink({
|
|
3592
|
-
id: "link-color-
|
|
3593
|
-
sourcePortId: 'lc-
|
|
3594
|
-
targetPortId: 'lc-
|
|
3623
|
+
id: "link-color-create-explicit-".concat(createId()),
|
|
3624
|
+
sourcePortId: 'lc-create-explicit-source-port',
|
|
3625
|
+
targetPortId: 'lc-create-explicit-target-port',
|
|
3595
3626
|
points: [],
|
|
3627
|
+
style: {
|
|
3628
|
+
stroke: '#111827',
|
|
3629
|
+
strokeWidth: 2,
|
|
3630
|
+
},
|
|
3596
3631
|
});
|
|
3597
3632
|
},
|
|
3598
3633
|
},
|
|
@@ -8043,6 +8078,10 @@ var DEFAULT_LINK_COLOR_POOL = [
|
|
|
8043
8078
|
'#9c755f',
|
|
8044
8079
|
'#bab0ab',
|
|
8045
8080
|
];
|
|
8081
|
+
var hasUsableLinkStroke = function (style) {
|
|
8082
|
+
var stroke = style === null || style === void 0 ? void 0 : style.stroke;
|
|
8083
|
+
return stroke !== undefined && stroke !== null && "".concat(stroke).trim().length > 0;
|
|
8084
|
+
};
|
|
8046
8085
|
var normalizeLinkColorPoolPolicy = function (policy) {
|
|
8047
8086
|
var _a;
|
|
8048
8087
|
var enabled = Boolean(policy === null || policy === void 0 ? void 0 : policy.enabled);
|
|
@@ -8050,7 +8089,11 @@ var normalizeLinkColorPoolPolicy = function (policy) {
|
|
|
8050
8089
|
.map(function (color) { return color.trim(); })
|
|
8051
8090
|
.filter(function (color) { return color.length > 0; });
|
|
8052
8091
|
var colors = normalizedColors.length > 0 ? normalizedColors : __spreadArray([], DEFAULT_LINK_COLOR_POOL, true);
|
|
8053
|
-
return {
|
|
8092
|
+
return {
|
|
8093
|
+
enabled: enabled,
|
|
8094
|
+
colors: colors,
|
|
8095
|
+
assignOnLoadWhenMissingStroke: Boolean(policy === null || policy === void 0 ? void 0 : policy.assignOnLoadWhenMissingStroke),
|
|
8096
|
+
};
|
|
8054
8097
|
};
|
|
8055
8098
|
var DiagramEngine = /** @class */ (function () {
|
|
8056
8099
|
function DiagramEngine(config) {
|
|
@@ -8096,8 +8139,9 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
8096
8139
|
DiagramEngine.prototype.load = function (state) {
|
|
8097
8140
|
var _this = this;
|
|
8098
8141
|
var patches = this.commandQueue.run(createLoadCommand(state), this.model);
|
|
8142
|
+
var linkColorPatches = this.assignOptionalLinkColorsOnLoad();
|
|
8099
8143
|
var mutationPatches = this.mutationPipeline.run({
|
|
8100
|
-
basePatches: patches,
|
|
8144
|
+
basePatches: __spreadArray(__spreadArray([], patches, true), linkColorPatches, true),
|
|
8101
8145
|
layoutSteps: [function () { return _this.applyAllLayouts(); }],
|
|
8102
8146
|
includeEmptyLinkRouting: true,
|
|
8103
8147
|
});
|
|
@@ -9455,21 +9499,41 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
9455
9499
|
return this.linkRoutingService.routeLinksWithEmptyPoints();
|
|
9456
9500
|
};
|
|
9457
9501
|
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)
|
|
9502
|
+
var style = this.resolveOptionalLinkColorStyle(link.style);
|
|
9503
|
+
if (style === link.style)
|
|
9467
9504
|
return link;
|
|
9505
|
+
return __assign(__assign({}, link), { style: style });
|
|
9506
|
+
};
|
|
9507
|
+
DiagramEngine.prototype.assignOptionalLinkColorsOnLoad = function () {
|
|
9508
|
+
var _this = this;
|
|
9509
|
+
if (!this.linkColorPoolPolicy.enabled || !this.linkColorPoolPolicy.assignOnLoadWhenMissingStroke) {
|
|
9510
|
+
return [];
|
|
9511
|
+
}
|
|
9512
|
+
var patches = [];
|
|
9513
|
+
this.model.links.forEach(function (link) {
|
|
9514
|
+
var style = _this.resolveOptionalLinkColorStyle(link.style);
|
|
9515
|
+
if (style === link.style)
|
|
9516
|
+
return;
|
|
9517
|
+
link.style = style;
|
|
9518
|
+
patches.push(patchUpdate('link', link.id, { style: style }));
|
|
9519
|
+
});
|
|
9520
|
+
return patches;
|
|
9521
|
+
};
|
|
9522
|
+
DiagramEngine.prototype.resolveOptionalLinkColorStyle = function (style) {
|
|
9523
|
+
if (!this.linkColorPoolPolicy.enabled || hasUsableLinkStroke(style)) {
|
|
9524
|
+
return style;
|
|
9525
|
+
}
|
|
9526
|
+
var stroke = this.pickOptionalLinkColor();
|
|
9527
|
+
if (!stroke)
|
|
9528
|
+
return style;
|
|
9529
|
+
return __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { stroke: stroke });
|
|
9530
|
+
};
|
|
9531
|
+
DiagramEngine.prototype.pickOptionalLinkColor = function () {
|
|
9468
9532
|
var colors = this.linkColorPoolPolicy.colors;
|
|
9469
9533
|
if (colors.length === 0)
|
|
9470
|
-
return
|
|
9534
|
+
return undefined;
|
|
9471
9535
|
var index = Math.max(0, Math.min(colors.length - 1, Math.floor(Math.random() * colors.length)));
|
|
9472
|
-
return
|
|
9536
|
+
return colors[index];
|
|
9473
9537
|
};
|
|
9474
9538
|
DiagramEngine.prototype.refreshLinksForRenderCycle = function () {
|
|
9475
9539
|
if (this.linkRouteRefreshPolicy.mode !== 'redraw-two-endpoint-change')
|
|
@@ -16493,9 +16557,10 @@ var LinkColorPoolDemo = function () {
|
|
|
16493
16557
|
var linkColorPoolPolicy = React.useMemo(function () {
|
|
16494
16558
|
if (mode === 'off')
|
|
16495
16559
|
return undefined;
|
|
16496
|
-
if (mode === 'default')
|
|
16497
|
-
return { enabled: true };
|
|
16498
|
-
|
|
16560
|
+
if (mode === 'default') {
|
|
16561
|
+
return { enabled: true, assignOnLoadWhenMissingStroke: true };
|
|
16562
|
+
}
|
|
16563
|
+
return { enabled: true, assignOnLoadWhenMissingStroke: true, colors: customPool };
|
|
16499
16564
|
}, [mode]);
|
|
16500
16565
|
return (React.createElement(SimpleDemo, { demo: linkColorPoolDemoConfig, linkColorPoolPolicy: linkColorPoolPolicy, beforeStage: React.createElement("div", { style: {
|
|
16501
16566
|
marginBottom: 12,
|
|
@@ -16507,9 +16572,10 @@ var LinkColorPoolDemo = function () {
|
|
|
16507
16572
|
React.createElement("label", { htmlFor: "link-color-mode", style: { display: 'inline-flex', alignItems: 'center', gap: 8, fontWeight: 600 } },
|
|
16508
16573
|
"Color Mode",
|
|
16509
16574
|
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)")))
|
|
16575
|
+
React.createElement("option", { value: "off" }, "Off (no load fill)"),
|
|
16576
|
+
React.createElement("option", { value: "default" }, "Default pool load fill"),
|
|
16577
|
+
React.createElement("option", { value: "custom" }, "Custom pool load fill (#0b7285, #e8590c, #5f3dc4)"))),
|
|
16578
|
+
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
16579
|
};
|
|
16514
16580
|
|
|
16515
16581
|
var sidePositions = {
|
package/dist/cjs/index.js
CHANGED
|
@@ -3809,6 +3809,10 @@ var DEFAULT_LINK_COLOR_POOL = [
|
|
|
3809
3809
|
'#9c755f',
|
|
3810
3810
|
'#bab0ab',
|
|
3811
3811
|
];
|
|
3812
|
+
var hasUsableLinkStroke = function (style) {
|
|
3813
|
+
var stroke = style === null || style === void 0 ? void 0 : style.stroke;
|
|
3814
|
+
return stroke !== undefined && stroke !== null && "".concat(stroke).trim().length > 0;
|
|
3815
|
+
};
|
|
3812
3816
|
var normalizeLinkColorPoolPolicy = function (policy) {
|
|
3813
3817
|
var _a;
|
|
3814
3818
|
var enabled = Boolean(policy === null || policy === void 0 ? void 0 : policy.enabled);
|
|
@@ -3816,7 +3820,11 @@ var normalizeLinkColorPoolPolicy = function (policy) {
|
|
|
3816
3820
|
.map(function (color) { return color.trim(); })
|
|
3817
3821
|
.filter(function (color) { return color.length > 0; });
|
|
3818
3822
|
var colors = normalizedColors.length > 0 ? normalizedColors : __spreadArray([], DEFAULT_LINK_COLOR_POOL, true);
|
|
3819
|
-
return {
|
|
3823
|
+
return {
|
|
3824
|
+
enabled: enabled,
|
|
3825
|
+
colors: colors,
|
|
3826
|
+
assignOnLoadWhenMissingStroke: Boolean(policy === null || policy === void 0 ? void 0 : policy.assignOnLoadWhenMissingStroke),
|
|
3827
|
+
};
|
|
3820
3828
|
};
|
|
3821
3829
|
var DiagramEngine = /** @class */ (function () {
|
|
3822
3830
|
function DiagramEngine(config) {
|
|
@@ -3862,8 +3870,9 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
3862
3870
|
DiagramEngine.prototype.load = function (state) {
|
|
3863
3871
|
var _this = this;
|
|
3864
3872
|
var patches = this.commandQueue.run(createLoadCommand(state), this.model);
|
|
3873
|
+
var linkColorPatches = this.assignOptionalLinkColorsOnLoad();
|
|
3865
3874
|
var mutationPatches = this.mutationPipeline.run({
|
|
3866
|
-
basePatches: patches,
|
|
3875
|
+
basePatches: __spreadArray(__spreadArray([], patches, true), linkColorPatches, true),
|
|
3867
3876
|
layoutSteps: [function () { return _this.applyAllLayouts(); }],
|
|
3868
3877
|
includeEmptyLinkRouting: true,
|
|
3869
3878
|
});
|
|
@@ -5221,21 +5230,41 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
5221
5230
|
return this.linkRoutingService.routeLinksWithEmptyPoints();
|
|
5222
5231
|
};
|
|
5223
5232
|
DiagramEngine.prototype.applyOptionalLinkColor = function (link) {
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
var existingStyle = link.style;
|
|
5227
|
-
var hasExplicitStroke = existingStyle !== undefined &&
|
|
5228
|
-
Object.prototype.hasOwnProperty.call(existingStyle, 'stroke') &&
|
|
5229
|
-
existingStyle.stroke !== undefined &&
|
|
5230
|
-
existingStyle.stroke !== null &&
|
|
5231
|
-
"".concat(existingStyle.stroke).trim().length > 0;
|
|
5232
|
-
if (hasExplicitStroke)
|
|
5233
|
+
var style = this.resolveOptionalLinkColorStyle(link.style);
|
|
5234
|
+
if (style === link.style)
|
|
5233
5235
|
return link;
|
|
5236
|
+
return __assign(__assign({}, link), { style: style });
|
|
5237
|
+
};
|
|
5238
|
+
DiagramEngine.prototype.assignOptionalLinkColorsOnLoad = function () {
|
|
5239
|
+
var _this = this;
|
|
5240
|
+
if (!this.linkColorPoolPolicy.enabled || !this.linkColorPoolPolicy.assignOnLoadWhenMissingStroke) {
|
|
5241
|
+
return [];
|
|
5242
|
+
}
|
|
5243
|
+
var patches = [];
|
|
5244
|
+
this.model.links.forEach(function (link) {
|
|
5245
|
+
var style = _this.resolveOptionalLinkColorStyle(link.style);
|
|
5246
|
+
if (style === link.style)
|
|
5247
|
+
return;
|
|
5248
|
+
link.style = style;
|
|
5249
|
+
patches.push(patchUpdate('link', link.id, { style: style }));
|
|
5250
|
+
});
|
|
5251
|
+
return patches;
|
|
5252
|
+
};
|
|
5253
|
+
DiagramEngine.prototype.resolveOptionalLinkColorStyle = function (style) {
|
|
5254
|
+
if (!this.linkColorPoolPolicy.enabled || hasUsableLinkStroke(style)) {
|
|
5255
|
+
return style;
|
|
5256
|
+
}
|
|
5257
|
+
var stroke = this.pickOptionalLinkColor();
|
|
5258
|
+
if (!stroke)
|
|
5259
|
+
return style;
|
|
5260
|
+
return __assign(__assign({}, (style !== null && style !== void 0 ? style : {})), { stroke: stroke });
|
|
5261
|
+
};
|
|
5262
|
+
DiagramEngine.prototype.pickOptionalLinkColor = function () {
|
|
5234
5263
|
var colors = this.linkColorPoolPolicy.colors;
|
|
5235
5264
|
if (colors.length === 0)
|
|
5236
|
-
return
|
|
5265
|
+
return undefined;
|
|
5237
5266
|
var index = Math.max(0, Math.min(colors.length - 1, Math.floor(Math.random() * colors.length)));
|
|
5238
|
-
return
|
|
5267
|
+
return colors[index];
|
|
5239
5268
|
};
|
|
5240
5269
|
DiagramEngine.prototype.refreshLinksForRenderCycle = function () {
|
|
5241
5270
|
if (this.linkRouteRefreshPolicy.mode !== 'redraw-two-endpoint-change')
|
|
@@ -193,6 +193,7 @@ export type LinkRouteRefreshPolicy = {
|
|
|
193
193
|
export type LinkColorPoolPolicy = {
|
|
194
194
|
enabled?: boolean;
|
|
195
195
|
colors?: string[];
|
|
196
|
+
assignOnLoadWhenMissingStroke?: boolean;
|
|
196
197
|
};
|
|
197
198
|
export type ElementLayoutMode = 'manual' | 'horizontal' | 'vertical' | 'grid';
|
|
198
199
|
export type ElementLayoutAlign = 'start' | 'center' | 'end';
|
|
@@ -165,6 +165,9 @@ export default class DiagramEngine {
|
|
|
165
165
|
private projectPointToHostBorder;
|
|
166
166
|
private routeLinksWithEmptyPoints;
|
|
167
167
|
private applyOptionalLinkColor;
|
|
168
|
+
private assignOptionalLinkColorsOnLoad;
|
|
169
|
+
private resolveOptionalLinkColorStyle;
|
|
170
|
+
private pickOptionalLinkColor;
|
|
168
171
|
private refreshLinksForRenderCycle;
|
|
169
172
|
private normalizePortsForHostPolicies;
|
|
170
173
|
private computeRemovalDiff;
|