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