@wcardinal/wcardinal-ui 0.148.0 → 0.150.2

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.
Files changed (31) hide show
  1. package/dist/types/wcardinal/ui/d-view.d.ts +4 -4
  2. package/dist/types/wcardinal/ui/shape/e-shape-connector-bodies.d.ts +3 -0
  3. package/dist/types/wcardinal/ui/shape/e-shape-connector-body-impl.d.ts +24 -0
  4. package/dist/types/wcardinal/ui/shape/e-shape-connector-body.d.ts +14 -0
  5. package/dist/types/wcardinal/ui/shape/e-shape-connector-edge-container.d.ts +3 -0
  6. package/dist/types/wcardinal/ui/shape/index.d.ts +3 -0
  7. package/dist/types/wcardinal/ui/shape/variant/e-shape-connector-line.d.ts +9 -2
  8. package/dist/wcardinal/ui/d-view.js.map +1 -1
  9. package/dist/wcardinal/ui/shape/e-shape-connector-bodies.js +57 -0
  10. package/dist/wcardinal/ui/shape/e-shape-connector-bodies.js.map +1 -0
  11. package/dist/wcardinal/ui/shape/e-shape-connector-body-impl.js +88 -0
  12. package/dist/wcardinal/ui/shape/e-shape-connector-body-impl.js.map +1 -0
  13. package/dist/wcardinal/ui/shape/e-shape-connector-body.js +6 -0
  14. package/dist/wcardinal/ui/shape/e-shape-connector-body.js.map +1 -0
  15. package/dist/wcardinal/ui/shape/e-shape-connector-edge-container-impl.js.map +1 -1
  16. package/dist/wcardinal/ui/shape/e-shape-connector-edge-container.js.map +1 -1
  17. package/dist/wcardinal/ui/shape/index.js +3 -0
  18. package/dist/wcardinal/ui/shape/index.js.map +1 -1
  19. package/dist/wcardinal/ui/shape/variant/deserialize-connector-line.js +21 -2
  20. package/dist/wcardinal/ui/shape/variant/deserialize-connector-line.js.map +1 -1
  21. package/dist/wcardinal/ui/shape/variant/e-shape-connector-line.js +106 -81
  22. package/dist/wcardinal/ui/shape/variant/e-shape-connector-line.js.map +1 -1
  23. package/dist/wcardinal-ui-theme-dark.js +1 -1
  24. package/dist/wcardinal-ui-theme-dark.min.js +1 -1
  25. package/dist/wcardinal-ui-theme-white.js +1 -1
  26. package/dist/wcardinal-ui-theme-white.min.js +1 -1
  27. package/dist/wcardinal-ui.cjs.js +271 -84
  28. package/dist/wcardinal-ui.js +271 -84
  29. package/dist/wcardinal-ui.min.js +2 -2
  30. package/dist/wcardinal-ui.min.js.map +1 -1
  31. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.148.0
2
+ Winter Cardinal UI v0.150.2
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -30908,6 +30908,62 @@
30908
30908
  return null;
30909
30909
  };
30910
30910
 
30911
+ /*
30912
+ * Copyright (C) 2019 Toshiba Corporation
30913
+ * SPDX-License-Identifier: Apache-2.0
30914
+ */
30915
+ var EShapeConnectorBodies = /** @class */ (function () {
30916
+ function EShapeConnectorBodies() {
30917
+ }
30918
+ EShapeConnectorBodies.from = function (values, tailMargin, headMargin) {
30919
+ var result = [];
30920
+ var length = values.length;
30921
+ if (4 < length) {
30922
+ var threshold = 0.000001;
30923
+ var x0 = values[0];
30924
+ var y0 = values[1];
30925
+ if (tailMargin !== 0) {
30926
+ var ex = x0 - values[2];
30927
+ var ey = y0 - values[3];
30928
+ var n = ex * ex + ey * ey;
30929
+ if (threshold < n) {
30930
+ var f = tailMargin / Math.sqrt(n);
30931
+ x0 += ex * f;
30932
+ y0 += ey * f;
30933
+ }
30934
+ }
30935
+ var x1 = values[length - 2];
30936
+ var y1 = values[length - 1];
30937
+ if (headMargin !== 0) {
30938
+ var ex = x1 - values[length - 4];
30939
+ var ey = y1 - values[length - 3];
30940
+ var n = ex * ex + ey * ey;
30941
+ if (threshold < n) {
30942
+ var f = headMargin / Math.sqrt(n);
30943
+ x1 += ex * f;
30944
+ y1 += ey * f;
30945
+ }
30946
+ }
30947
+ var cx = (x1 + x0) * 0.5;
30948
+ var cy = (y1 + y0) * 0.5;
30949
+ var dx = x1 - x0;
30950
+ var dy = y1 - y0;
30951
+ var a = Math.atan2(dy, dx);
30952
+ var c = Math.cos(a);
30953
+ var s = Math.sin(a);
30954
+ var l = dx * dx + dy * dy;
30955
+ var m = threshold < l ? 1 / Math.sqrt(l) : 1;
30956
+ for (var i = 2, imax = length - 2; i < imax; i += 2) {
30957
+ var x = values[i + 0] - cx;
30958
+ var y = values[i + 1] - cy;
30959
+ result.push((c * x + s * y) * m, (c * y - s * x) * m);
30960
+ }
30961
+ }
30962
+ return result;
30963
+ };
30964
+ return EShapeConnectorBodies;
30965
+ }());
30966
+
30911
30967
  /*
30912
30968
  * Copyright (C) 2019 Toshiba Corporation
30913
30969
  * SPDX-License-Identifier: Apache-2.0
@@ -31375,6 +31431,93 @@
31375
31431
  return EShapeConnectorEdgeContainerImpl;
31376
31432
  }());
31377
31433
 
31434
+ /*
31435
+ * Copyright (C) 2019 Toshiba Corporation
31436
+ * SPDX-License-Identifier: Apache-2.0
31437
+ */
31438
+ var EShapeConnectorBodyImpl = /** @class */ (function () {
31439
+ function EShapeConnectorBodyImpl(parent, onChange) {
31440
+ this._parent = parent;
31441
+ this._id = 0;
31442
+ this._values = [];
31443
+ this._lockCount = 0;
31444
+ this._isChanged = false;
31445
+ this._onChange = onChange;
31446
+ }
31447
+ EShapeConnectorBodyImpl.prototype.lock = function () {
31448
+ this._lockCount += 1;
31449
+ if (this._lockCount === 1) {
31450
+ this._isChanged = false;
31451
+ }
31452
+ };
31453
+ EShapeConnectorBodyImpl.prototype.unlock = function () {
31454
+ this._lockCount -= 1;
31455
+ if (this._lockCount === 0) {
31456
+ if (this._isChanged) {
31457
+ this.onChange();
31458
+ }
31459
+ this._isChanged = false;
31460
+ }
31461
+ };
31462
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "id", {
31463
+ get: function () {
31464
+ return this._id;
31465
+ },
31466
+ enumerable: false,
31467
+ configurable: true
31468
+ });
31469
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "values", {
31470
+ get: function () {
31471
+ return this._values;
31472
+ },
31473
+ set: function (newValues) {
31474
+ this.set(newValues);
31475
+ },
31476
+ enumerable: false,
31477
+ configurable: true
31478
+ });
31479
+ EShapeConnectorBodyImpl.prototype.set = function (newValues) {
31480
+ if (newValues != null) {
31481
+ this._id += 1;
31482
+ if (this._values !== newValues) {
31483
+ var length_1 = newValues.length;
31484
+ var values = this._values;
31485
+ for (var i = 0; i < length_1; ++i) {
31486
+ values[i] = newValues[i];
31487
+ }
31488
+ values.length = length_1;
31489
+ }
31490
+ this.onChange();
31491
+ }
31492
+ return this;
31493
+ };
31494
+ EShapeConnectorBodyImpl.prototype.copy = function (source) {
31495
+ return this.set(source.values);
31496
+ };
31497
+ EShapeConnectorBodyImpl.prototype.serialize = function (manager) {
31498
+ return manager.addResource(JSON.stringify(this._values));
31499
+ };
31500
+ EShapeConnectorBodyImpl.prototype.deserialize = function (resourceId, mapping, manager) {
31501
+ var resources = manager.resources;
31502
+ if (0 <= resourceId && resourceId < resources.length) {
31503
+ var parsed = manager.getExtension(resourceId);
31504
+ if (parsed == null) {
31505
+ parsed = JSON.parse(resources[resourceId]);
31506
+ manager.setExtension(resourceId, parsed);
31507
+ }
31508
+ this.set(parsed);
31509
+ }
31510
+ };
31511
+ EShapeConnectorBodyImpl.prototype.onChange = function () {
31512
+ if (0 < this._lockCount) {
31513
+ this._isChanged = true;
31514
+ return;
31515
+ }
31516
+ this._onChange();
31517
+ };
31518
+ return EShapeConnectorBodyImpl;
31519
+ }());
31520
+
31378
31521
  /*
31379
31522
  * Copyright (C) 2019 Toshiba Corporation
31380
31523
  * SPDX-License-Identifier: Apache-2.0
@@ -31388,16 +31531,36 @@
31388
31531
  _this._tailMargin = 0;
31389
31532
  _this._headLocalId = 0;
31390
31533
  _this._headMargin = 0;
31534
+ _this._bodyId = 0;
31535
+ _this._lockCount = 0;
31536
+ _this._isChanged = false;
31391
31537
  var sx = EShapeDefaults.SIZE_X;
31392
31538
  var sy = EShapeDefaults.SIZE_Y;
31393
31539
  var hx = sx * 0.5;
31394
31540
  var hy = sy * 0.5;
31395
- _this._points = new EShapeLinePoints(_this).set(_this.toValues(-hx, -hy, +hx, +hy, 0, 0, []));
31396
- _this._edge = new EShapeConnectorEdgeContainerImpl(_this, function () {
31397
- _this.onEdgeChange();
31398
- });
31541
+ _this._points = new EShapeLinePoints(_this).set([-hx, -hy, +hx, +hy]);
31542
+ var onChangeBound = function () {
31543
+ _this.onChange();
31544
+ };
31545
+ _this._edge = new EShapeConnectorEdgeContainerImpl(_this, onChangeBound);
31546
+ _this._body = new EShapeConnectorBodyImpl(_this, onChangeBound);
31399
31547
  return _this;
31400
31548
  }
31549
+ EShapeConnectorLine.prototype.lock = function () {
31550
+ this._lockCount += 1;
31551
+ if (this._lockCount === 1) {
31552
+ this._isChanged = false;
31553
+ }
31554
+ };
31555
+ EShapeConnectorLine.prototype.unlock = function () {
31556
+ this._lockCount -= 1;
31557
+ if (this._lockCount === 0) {
31558
+ if (this._isChanged) {
31559
+ this.onChange();
31560
+ }
31561
+ this._isChanged = false;
31562
+ }
31563
+ };
31401
31564
  Object.defineProperty(EShapeConnectorLine.prototype, "points", {
31402
31565
  get: function () {
31403
31566
  return this._points;
@@ -31412,6 +31575,13 @@
31412
31575
  enumerable: false,
31413
31576
  configurable: true
31414
31577
  });
31578
+ Object.defineProperty(EShapeConnectorLine.prototype, "body", {
31579
+ get: function () {
31580
+ return this._body;
31581
+ },
31582
+ enumerable: false,
31583
+ configurable: true
31584
+ });
31415
31585
  EShapeConnectorLine.prototype.onAttach = function () {
31416
31586
  _super.prototype.onAttach.call(this);
31417
31587
  this._edge.attach();
@@ -31420,8 +31590,12 @@
31420
31590
  this._edge.detach();
31421
31591
  _super.prototype.onDetach.call(this);
31422
31592
  };
31423
- EShapeConnectorLine.prototype.onEdgeChange = function () {
31593
+ EShapeConnectorLine.prototype.onChange = function () {
31424
31594
  var _a;
31595
+ if (0 < this._lockCount) {
31596
+ this._isChanged = true;
31597
+ return;
31598
+ }
31425
31599
  var edge = this._edge;
31426
31600
  var tail = edge.tail;
31427
31601
  var tailLocalId = tail.localId;
@@ -31429,22 +31603,29 @@
31429
31603
  var head = edge.head;
31430
31604
  var headLocalId = head.localId;
31431
31605
  var headMargin = head.margin;
31606
+ var body = this._body;
31607
+ var bodyId = body.id;
31432
31608
  if (this._tailLocalId !== tailLocalId ||
31433
31609
  this._tailMargin !== tailMargin ||
31434
31610
  this._headLocalId !== headLocalId ||
31435
- this._headMargin !== headMargin) {
31611
+ this._headMargin !== headMargin ||
31612
+ this._bodyId !== bodyId) {
31436
31613
  this._tailLocalId = tailLocalId;
31437
31614
  this._tailMargin = tailMargin;
31438
31615
  this._headLocalId = headLocalId;
31439
31616
  this._headMargin = headMargin;
31440
- // Left
31617
+ this._bodyId !== bodyId;
31618
+ // Tail
31441
31619
  var tailLocal = tail.local;
31442
31620
  var tailLocalX = tailLocal.x;
31443
31621
  var tailLocalY = tailLocal.y;
31444
- // Right
31622
+ // Head
31445
31623
  var headLocal = head.local;
31446
31624
  var headLocalX = headLocal.x;
31447
31625
  var headLocalY = headLocal.y;
31626
+ // Body
31627
+ var bodyValues = body.values;
31628
+ var bodyValuesLength = bodyValues.length;
31448
31629
  // Values
31449
31630
  var transform = this.transform;
31450
31631
  var transformPosition = transform.position;
@@ -31452,7 +31633,60 @@
31452
31633
  var py = transformPosition.y;
31453
31634
  var points = this._points;
31454
31635
  var values = points.values;
31455
- this.toValues(tailLocalX - px, tailLocalY - py, headLocalX - px, headLocalY - py, tailMargin, headMargin, values);
31636
+ if (values.length < 4) {
31637
+ values[0] = 0;
31638
+ values[1] = 0;
31639
+ }
31640
+ var threshold = 0.000001;
31641
+ var x0 = tailLocalX - px;
31642
+ var y0 = tailLocalY - py;
31643
+ var x1 = headLocalX - px;
31644
+ var y1 = headLocalY - py;
31645
+ // Body
31646
+ if (0 < bodyValuesLength) {
31647
+ var cx_1 = (x1 + x0) * 0.5;
31648
+ var cy_1 = (y1 + y0) * 0.5;
31649
+ var dx = x1 - x0;
31650
+ var dy = y1 - y0;
31651
+ var a = Math.atan2(dy, dx);
31652
+ var c = Math.cos(a);
31653
+ var s = Math.sin(a);
31654
+ var l = Math.sqrt(dx * dx + dy * dy);
31655
+ for (var i = 0; i < bodyValuesLength; i += 2) {
31656
+ var x = bodyValues[i + 0];
31657
+ var y = bodyValues[i + 1];
31658
+ values[i + 2] = cx_1 + (c * x - s * y) * l;
31659
+ values[i + 3] = cy_1 + (c * y + s * x) * l;
31660
+ }
31661
+ }
31662
+ // Tail
31663
+ values[0] = x0;
31664
+ values[1] = y0;
31665
+ if (tailMargin !== 0) {
31666
+ var dx = values[2] - x0;
31667
+ var dy = values[3] - y0;
31668
+ var d = dx * dx + dy * dy;
31669
+ if (threshold < d) {
31670
+ var f = tailMargin / Math.sqrt(dx * dx + dy * dy);
31671
+ values[0] = x0 + dx * f;
31672
+ values[1] = y0 + dy * f;
31673
+ }
31674
+ }
31675
+ // Head
31676
+ values[2 + bodyValuesLength] = x1;
31677
+ values[3 + bodyValuesLength] = y1;
31678
+ if (headMargin !== 0) {
31679
+ var dx = values[0 + bodyValuesLength] - x1;
31680
+ var dy = values[1 + bodyValuesLength] - y1;
31681
+ var d = dx * dx + dy * dy;
31682
+ if (threshold < d) {
31683
+ var f = headMargin / Math.sqrt(dx * dx + dy * dy);
31684
+ values[2 + bodyValuesLength] = x1 + dx * f;
31685
+ values[3 + bodyValuesLength] = y1 + dy * f;
31686
+ }
31687
+ }
31688
+ // Remove the rest
31689
+ values.length = bodyValuesLength + 4;
31456
31690
  // Center & size
31457
31691
  var boundary = ((_a = EShapeConnectorLine.WORK_BOUNDARY) !== null && _a !== void 0 ? _a : (EShapeConnectorLine.WORK_BOUNDARY = [0, 0, 0, 0]));
31458
31692
  toPointsBoundary(values, boundary);
@@ -31476,82 +31710,12 @@
31476
31710
  this.allowUploadedUpdate();
31477
31711
  }
31478
31712
  };
31479
- EShapeConnectorLine.prototype.toValues = function (x0, y0, x1, y1, margin0, margin1, result) {
31480
- var threshold = 0.000001;
31481
- var resultLength = result.length;
31482
- if (resultLength <= 4) {
31483
- if (margin0 !== 0 || margin1 !== 0) {
31484
- var dx = x1 - x0;
31485
- var dy = y1 - y0;
31486
- var d = dx * dx + dy * dy;
31487
- if (threshold < d) {
31488
- var f = 1 / Math.sqrt(dx * dx + dy * dy);
31489
- var nx = dx * f;
31490
- var ny = dy * f;
31491
- result[0] = x0 + margin0 * nx;
31492
- result[1] = y0 + margin0 * ny;
31493
- result[2] = x1 - margin1 * nx;
31494
- result[3] = y1 - margin1 * ny;
31495
- }
31496
- else {
31497
- result[0] = x0;
31498
- result[1] = y0;
31499
- result[2] = x1;
31500
- result[3] = y1;
31501
- }
31502
- }
31503
- else {
31504
- result[0] = x0;
31505
- result[1] = y0;
31506
- result[2] = x1;
31507
- result[3] = y1;
31508
- }
31509
- }
31510
- else {
31511
- if (margin0 !== 0) {
31512
- var dx = result[2] - x0;
31513
- var dy = result[3] - y0;
31514
- var d = dx * dx + dy * dy;
31515
- if (threshold < d) {
31516
- var f = 1 / Math.sqrt(dx * dx + dy * dy);
31517
- result[0] = x0 + margin0 * dx * f;
31518
- result[1] = y0 + margin0 * dy * f;
31519
- }
31520
- else {
31521
- result[0] = x0;
31522
- result[1] = y0;
31523
- }
31524
- }
31525
- else {
31526
- result[0] = x0;
31527
- result[1] = y0;
31528
- }
31529
- if (margin1 !== 0) {
31530
- var dx = result[resultLength - 4] - x1;
31531
- var dy = result[resultLength - 3] - y1;
31532
- var d = dx * dx + dy * dy;
31533
- if (threshold < d) {
31534
- var f = 1 / Math.sqrt(dx * dx + dy * dy);
31535
- result[resultLength - 2] = x1 + margin1 * dx * f;
31536
- result[resultLength - 1] = y1 + margin1 * dy * f;
31537
- }
31538
- else {
31539
- result[resultLength - 2] = x1;
31540
- result[resultLength - 1] = y1;
31541
- }
31542
- }
31543
- else {
31544
- result[resultLength - 2] = x1;
31545
- result[resultLength - 1] = y1;
31546
- }
31547
- }
31548
- return result;
31549
- };
31550
31713
  EShapeConnectorLine.prototype.copy = function (source, part) {
31551
31714
  if (part === void 0) { part = EShapeCopyPart.ALL; }
31552
31715
  _super.prototype.copy.call(this, source, part);
31553
31716
  if (source instanceof EShapeConnectorLine) {
31554
31717
  this._edge.copy(source.edge);
31718
+ this._body.copy(source.body);
31555
31719
  }
31556
31720
  return this;
31557
31721
  };
@@ -31560,7 +31724,10 @@
31560
31724
  };
31561
31725
  EShapeConnectorLine.prototype.serialize = function (manager) {
31562
31726
  var result = _super.prototype.serialize.call(this, manager);
31563
- result[15] = manager.addResource("[" + this._edge.serialize(manager) + "," + this._points.serialize(manager) + "]");
31727
+ var edgeId = this._edge.serialize(manager);
31728
+ var bodyId = this._body.serialize(manager);
31729
+ var pointsId = this._points.serialize(manager);
31730
+ result[15] = manager.addResource("[" + edgeId + "," + pointsId + "," + bodyId + "]");
31564
31731
  return result;
31565
31732
  };
31566
31733
  return EShapeConnectorLine;
@@ -31583,8 +31750,26 @@
31583
31750
  parsed = JSON.parse(resources[resourceId]);
31584
31751
  manager.setExtension(resourceId, parsed);
31585
31752
  }
31586
- shape.points.deserialize(parsed[1], manager);
31587
- shape.edge.deserialize(parsed[0], mapping, manager);
31753
+ // Lock
31754
+ shape.lock();
31755
+ // Points
31756
+ var points = shape.points;
31757
+ points.deserialize(parsed[1], manager);
31758
+ // Edge
31759
+ var edge = shape.edge;
31760
+ edge.deserialize(parsed[0], mapping, manager);
31761
+ // Body
31762
+ var body = shape.body;
31763
+ var bodyId = parsed[2];
31764
+ if (bodyId != null) {
31765
+ body.deserialize(bodyId, mapping, manager);
31766
+ }
31767
+ else {
31768
+ // The following is for backward compatibility.
31769
+ body.set(EShapeConnectorBodies.from(points.values, edge.tail.margin, edge.head.margin));
31770
+ }
31771
+ // Unlock
31772
+ shape.unlock();
31588
31773
  }
31589
31774
  }
31590
31775
  };
@@ -67477,6 +67662,8 @@
67477
67662
  EShapeBuffer: EShapeBuffer,
67478
67663
  EShapeCapabilities: EShapeCapabilities,
67479
67664
  EShapeCapability: EShapeCapability,
67665
+ EShapeConnectorBodies: EShapeConnectorBodies,
67666
+ EShapeConnectorBodyImpl: EShapeConnectorBodyImpl,
67480
67667
  EShapeConnectorContainerImpl: EShapeConnectorContainerImpl,
67481
67668
  EShapeConnectorEdgeAcceptorImpl: EShapeConnectorEdgeAcceptorImpl,
67482
67669
  EShapeConnectorEdgeContainerImpl: EShapeConnectorEdgeContainerImpl,