@wcardinal/wcardinal-ui 0.148.0 → 0.149.0

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 (29) hide show
  1. package/dist/types/wcardinal/ui/shape/e-shape-connector-bodies.d.ts +3 -0
  2. package/dist/types/wcardinal/ui/shape/e-shape-connector-body-impl.d.ts +24 -0
  3. package/dist/types/wcardinal/ui/shape/e-shape-connector-body.d.ts +14 -0
  4. package/dist/types/wcardinal/ui/shape/e-shape-connector-edge-container.d.ts +3 -0
  5. package/dist/types/wcardinal/ui/shape/index.d.ts +3 -0
  6. package/dist/types/wcardinal/ui/shape/variant/e-shape-connector-line.d.ts +9 -2
  7. package/dist/wcardinal/ui/shape/e-shape-connector-bodies.js +36 -0
  8. package/dist/wcardinal/ui/shape/e-shape-connector-bodies.js.map +1 -0
  9. package/dist/wcardinal/ui/shape/e-shape-connector-body-impl.js +88 -0
  10. package/dist/wcardinal/ui/shape/e-shape-connector-body-impl.js.map +1 -0
  11. package/dist/wcardinal/ui/shape/e-shape-connector-body.js +6 -0
  12. package/dist/wcardinal/ui/shape/e-shape-connector-body.js.map +1 -0
  13. package/dist/wcardinal/ui/shape/e-shape-connector-edge-container-impl.js.map +1 -1
  14. package/dist/wcardinal/ui/shape/e-shape-connector-edge-container.js.map +1 -1
  15. package/dist/wcardinal/ui/shape/index.js +3 -0
  16. package/dist/wcardinal/ui/shape/index.js.map +1 -1
  17. package/dist/wcardinal/ui/shape/variant/deserialize-connector-line.js +19 -1
  18. package/dist/wcardinal/ui/shape/variant/deserialize-connector-line.js.map +1 -1
  19. package/dist/wcardinal/ui/shape/variant/e-shape-connector-line.js +104 -81
  20. package/dist/wcardinal/ui/shape/variant/e-shape-connector-line.js.map +1 -1
  21. package/dist/wcardinal-ui-theme-dark.js +1 -1
  22. package/dist/wcardinal-ui-theme-dark.min.js +1 -1
  23. package/dist/wcardinal-ui-theme-white.js +1 -1
  24. package/dist/wcardinal-ui-theme-white.min.js +1 -1
  25. package/dist/wcardinal-ui.cjs.js +246 -83
  26. package/dist/wcardinal-ui.js +246 -83
  27. package/dist/wcardinal-ui.min.js +2 -2
  28. package/dist/wcardinal-ui.min.js.map +1 -1
  29. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.148.0
2
+ Winter Cardinal UI v0.149.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -30911,6 +30911,41 @@ 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) {
30922
+ var result = [];
30923
+ var length = values.length;
30924
+ if (4 < length) {
30925
+ var x0 = values[0];
30926
+ var y0 = values[1];
30927
+ var x1 = values[length - 2];
30928
+ var y1 = values[length - 1];
30929
+ var cx = (x1 + x0) * 0.5;
30930
+ var cy = (y1 + y0) * 0.5;
30931
+ var dx = x1 - x0;
30932
+ var dy = y1 - y0;
30933
+ var a = Math.atan2(dy, dx);
30934
+ var c = Math.cos(a);
30935
+ var s = Math.sin(a);
30936
+ var l = dx * dx + dy * dy;
30937
+ var m = 0.000001 < l ? 1 / Math.sqrt(l) : 1;
30938
+ for (var i = 2, imax = length - 2; i < imax; i += 2) {
30939
+ var x = values[i + 0] - cx;
30940
+ var y = values[i + 1] - cy;
30941
+ result.push((c * x - s * y) * m, (c * y + s * x) * m);
30942
+ }
30943
+ }
30944
+ return result;
30945
+ };
30946
+ return EShapeConnectorBodies;
30947
+ }());
30948
+
30914
30949
  /*
30915
30950
  * Copyright (C) 2019 Toshiba Corporation
30916
30951
  * SPDX-License-Identifier: Apache-2.0
@@ -31378,6 +31413,93 @@ var EShapeConnectorEdgeContainerImpl = /** @class */ (function () {
31378
31413
  return EShapeConnectorEdgeContainerImpl;
31379
31414
  }());
31380
31415
 
31416
+ /*
31417
+ * Copyright (C) 2019 Toshiba Corporation
31418
+ * SPDX-License-Identifier: Apache-2.0
31419
+ */
31420
+ var EShapeConnectorBodyImpl = /** @class */ (function () {
31421
+ function EShapeConnectorBodyImpl(parent, onChange) {
31422
+ this._parent = parent;
31423
+ this._id = 0;
31424
+ this._values = [];
31425
+ this._lockCount = 0;
31426
+ this._isChanged = false;
31427
+ this._onChange = onChange;
31428
+ }
31429
+ EShapeConnectorBodyImpl.prototype.lock = function () {
31430
+ this._lockCount += 1;
31431
+ if (this._lockCount === 1) {
31432
+ this._isChanged = false;
31433
+ }
31434
+ };
31435
+ EShapeConnectorBodyImpl.prototype.unlock = function () {
31436
+ this._lockCount -= 1;
31437
+ if (this._lockCount === 0) {
31438
+ if (this._isChanged) {
31439
+ this.onChange();
31440
+ }
31441
+ this._isChanged = false;
31442
+ }
31443
+ };
31444
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "id", {
31445
+ get: function () {
31446
+ return this._id;
31447
+ },
31448
+ enumerable: false,
31449
+ configurable: true
31450
+ });
31451
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "values", {
31452
+ get: function () {
31453
+ return this._values;
31454
+ },
31455
+ set: function (newValues) {
31456
+ this.set(newValues);
31457
+ },
31458
+ enumerable: false,
31459
+ configurable: true
31460
+ });
31461
+ EShapeConnectorBodyImpl.prototype.set = function (newValues) {
31462
+ if (newValues != null) {
31463
+ this._id += 1;
31464
+ if (this._values !== newValues) {
31465
+ var length_1 = newValues.length;
31466
+ var values = this._values;
31467
+ for (var i = 0; i < length_1; ++i) {
31468
+ values[i] = newValues[i];
31469
+ }
31470
+ values.length = length_1;
31471
+ }
31472
+ this.onChange();
31473
+ }
31474
+ return this;
31475
+ };
31476
+ EShapeConnectorBodyImpl.prototype.copy = function (source) {
31477
+ return this.set(source.values);
31478
+ };
31479
+ EShapeConnectorBodyImpl.prototype.serialize = function (manager) {
31480
+ return manager.addResource(JSON.stringify(this._values));
31481
+ };
31482
+ EShapeConnectorBodyImpl.prototype.deserialize = function (resourceId, mapping, manager) {
31483
+ var resources = manager.resources;
31484
+ if (0 <= resourceId && resourceId < resources.length) {
31485
+ var parsed = manager.getExtension(resourceId);
31486
+ if (parsed == null) {
31487
+ parsed = JSON.parse(resources[resourceId]);
31488
+ manager.setExtension(resourceId, parsed);
31489
+ }
31490
+ this.set(parsed);
31491
+ }
31492
+ };
31493
+ EShapeConnectorBodyImpl.prototype.onChange = function () {
31494
+ if (0 < this._lockCount) {
31495
+ this._isChanged = true;
31496
+ return;
31497
+ }
31498
+ this._onChange();
31499
+ };
31500
+ return EShapeConnectorBodyImpl;
31501
+ }());
31502
+
31381
31503
  /*
31382
31504
  * Copyright (C) 2019 Toshiba Corporation
31383
31505
  * SPDX-License-Identifier: Apache-2.0
@@ -31391,16 +31513,36 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31391
31513
  _this._tailMargin = 0;
31392
31514
  _this._headLocalId = 0;
31393
31515
  _this._headMargin = 0;
31516
+ _this._bodyId = 0;
31517
+ _this._lockCount = 0;
31518
+ _this._isChanged = false;
31394
31519
  var sx = EShapeDefaults.SIZE_X;
31395
31520
  var sy = EShapeDefaults.SIZE_Y;
31396
31521
  var hx = sx * 0.5;
31397
31522
  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
- });
31523
+ _this._points = new EShapeLinePoints(_this).set([-hx, -hy, +hx, +hy]);
31524
+ var onChangeBound = function () {
31525
+ _this.onChange();
31526
+ };
31527
+ _this._edge = new EShapeConnectorEdgeContainerImpl(_this, onChangeBound);
31528
+ _this._body = new EShapeConnectorBodyImpl(_this, onChangeBound);
31402
31529
  return _this;
31403
31530
  }
31531
+ EShapeConnectorLine.prototype.lock = function () {
31532
+ this._lockCount += 1;
31533
+ if (this._lockCount === 1) {
31534
+ this._isChanged = false;
31535
+ }
31536
+ };
31537
+ EShapeConnectorLine.prototype.unlock = function () {
31538
+ this._lockCount -= 1;
31539
+ if (this._lockCount === 0) {
31540
+ if (this._isChanged) {
31541
+ this.onChange();
31542
+ }
31543
+ this._isChanged = false;
31544
+ }
31545
+ };
31404
31546
  Object.defineProperty(EShapeConnectorLine.prototype, "points", {
31405
31547
  get: function () {
31406
31548
  return this._points;
@@ -31415,6 +31557,13 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31415
31557
  enumerable: false,
31416
31558
  configurable: true
31417
31559
  });
31560
+ Object.defineProperty(EShapeConnectorLine.prototype, "body", {
31561
+ get: function () {
31562
+ return this._body;
31563
+ },
31564
+ enumerable: false,
31565
+ configurable: true
31566
+ });
31418
31567
  EShapeConnectorLine.prototype.onAttach = function () {
31419
31568
  _super.prototype.onAttach.call(this);
31420
31569
  this._edge.attach();
@@ -31423,8 +31572,12 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31423
31572
  this._edge.detach();
31424
31573
  _super.prototype.onDetach.call(this);
31425
31574
  };
31426
- EShapeConnectorLine.prototype.onEdgeChange = function () {
31575
+ EShapeConnectorLine.prototype.onChange = function () {
31427
31576
  var _a;
31577
+ if (0 < this._lockCount) {
31578
+ this._isChanged = true;
31579
+ return;
31580
+ }
31428
31581
  var edge = this._edge;
31429
31582
  var tail = edge.tail;
31430
31583
  var tailLocalId = tail.localId;
@@ -31432,22 +31585,29 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31432
31585
  var head = edge.head;
31433
31586
  var headLocalId = head.localId;
31434
31587
  var headMargin = head.margin;
31588
+ var body = this._body;
31589
+ var bodyId = body.id;
31435
31590
  if (this._tailLocalId !== tailLocalId ||
31436
31591
  this._tailMargin !== tailMargin ||
31437
31592
  this._headLocalId !== headLocalId ||
31438
- this._headMargin !== headMargin) {
31593
+ this._headMargin !== headMargin ||
31594
+ this._bodyId !== bodyId) {
31439
31595
  this._tailLocalId = tailLocalId;
31440
31596
  this._tailMargin = tailMargin;
31441
31597
  this._headLocalId = headLocalId;
31442
31598
  this._headMargin = headMargin;
31443
- // Left
31599
+ this._bodyId !== bodyId;
31600
+ // Tail
31444
31601
  var tailLocal = tail.local;
31445
31602
  var tailLocalX = tailLocal.x;
31446
31603
  var tailLocalY = tailLocal.y;
31447
- // Right
31604
+ // Head
31448
31605
  var headLocal = head.local;
31449
31606
  var headLocalX = headLocal.x;
31450
31607
  var headLocalY = headLocal.y;
31608
+ // Body
31609
+ var bodyValues = body.values;
31610
+ var bodyValuesLength = bodyValues.length;
31451
31611
  // Values
31452
31612
  var transform = this.transform;
31453
31613
  var transformPosition = transform.position;
@@ -31455,7 +31615,58 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31455
31615
  var py = transformPosition.y;
31456
31616
  var points = this._points;
31457
31617
  var values = points.values;
31458
- this.toValues(tailLocalX - px, tailLocalY - py, headLocalX - px, headLocalY - py, tailMargin, headMargin, values);
31618
+ if (values.length < 4) {
31619
+ values[0] = 0;
31620
+ values[1] = 0;
31621
+ }
31622
+ var threshold = 0.000001;
31623
+ var x0 = tailLocalX - px;
31624
+ var y0 = tailLocalY - py;
31625
+ var x1 = headLocalX - px;
31626
+ var y1 = headLocalY - py;
31627
+ // Body
31628
+ if (0 < bodyValuesLength) {
31629
+ var cx_1 = (x1 + x0) * 0.5;
31630
+ var cy_1 = (y1 + y0) * 0.5;
31631
+ var dx = x1 - x0;
31632
+ var dy = y1 - y0;
31633
+ var a = Math.atan2(dy, dx);
31634
+ var c = Math.cos(a);
31635
+ var s = Math.sin(a);
31636
+ var l = Math.sqrt(dx * dx + dy * dy);
31637
+ for (var i = 0; i < bodyValuesLength; i += 2) {
31638
+ var x = bodyValues[i + 0];
31639
+ var y = bodyValues[i + 1];
31640
+ values[i + 2] = cx_1 + (c * x - s * y) * l;
31641
+ values[i + 3] = cy_1 + (c * y + s * x) * l;
31642
+ }
31643
+ }
31644
+ // Tail
31645
+ values[0] = x0;
31646
+ values[1] = y0;
31647
+ if (tailMargin !== 0) {
31648
+ var dx = values[2] - x0;
31649
+ var dy = values[3] - y0;
31650
+ var d = dx * dx + dy * dy;
31651
+ if (threshold < d) {
31652
+ var f = tailMargin / Math.sqrt(dx * dx + dy * dy);
31653
+ values[0] = x0 + dx * f;
31654
+ values[1] = y0 + dy * f;
31655
+ }
31656
+ }
31657
+ // Head
31658
+ values[2 + bodyValuesLength] = x1;
31659
+ values[3 + bodyValuesLength] = y1;
31660
+ if (headMargin !== 0) {
31661
+ var dx = values[0 + bodyValuesLength] - x1;
31662
+ var dy = values[1 + bodyValuesLength] - y1;
31663
+ var d = dx * dx + dy * dy;
31664
+ if (threshold < d) {
31665
+ var f = headMargin / Math.sqrt(dx * dx + dy * dy);
31666
+ values[2 + bodyValuesLength] = x1 + dx * f;
31667
+ values[3 + bodyValuesLength] = y1 + dy * f;
31668
+ }
31669
+ }
31459
31670
  // Center & size
31460
31671
  var boundary = ((_a = EShapeConnectorLine.WORK_BOUNDARY) !== null && _a !== void 0 ? _a : (EShapeConnectorLine.WORK_BOUNDARY = [0, 0, 0, 0]));
31461
31672
  toPointsBoundary(values, boundary);
@@ -31479,82 +31690,12 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31479
31690
  this.allowUploadedUpdate();
31480
31691
  }
31481
31692
  };
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
31693
  EShapeConnectorLine.prototype.copy = function (source, part) {
31554
31694
  if (part === void 0) { part = EShapeCopyPart.ALL; }
31555
31695
  _super.prototype.copy.call(this, source, part);
31556
31696
  if (source instanceof EShapeConnectorLine) {
31557
31697
  this._edge.copy(source.edge);
31698
+ this._body.copy(source.body);
31558
31699
  }
31559
31700
  return this;
31560
31701
  };
@@ -31563,7 +31704,10 @@ var EShapeConnectorLine = /** @class */ (function (_super) {
31563
31704
  };
31564
31705
  EShapeConnectorLine.prototype.serialize = function (manager) {
31565
31706
  var result = _super.prototype.serialize.call(this, manager);
31566
- result[15] = manager.addResource("[" + this._edge.serialize(manager) + "," + this._points.serialize(manager) + "]");
31707
+ var edgeId = this._edge.serialize(manager);
31708
+ var bodyId = this._body.serialize(manager);
31709
+ var pointsId = this._points.serialize(manager);
31710
+ result[15] = manager.addResource("[" + edgeId + "," + pointsId + "," + bodyId + "]");
31567
31711
  return result;
31568
31712
  };
31569
31713
  return EShapeConnectorLine;
@@ -31586,8 +31730,25 @@ var onConnectorLineDeserialized = function (item, shape, mapping, manager) {
31586
31730
  parsed = JSON.parse(resources[resourceId]);
31587
31731
  manager.setExtension(resourceId, parsed);
31588
31732
  }
31589
- shape.points.deserialize(parsed[1], manager);
31733
+ // Lock
31734
+ shape.lock();
31735
+ // Points
31736
+ var points = shape.points;
31737
+ points.deserialize(parsed[1], manager);
31738
+ // Edge
31590
31739
  shape.edge.deserialize(parsed[0], mapping, manager);
31740
+ // Body
31741
+ var body = shape.body;
31742
+ var bodyId = parsed[2];
31743
+ if (bodyId != null) {
31744
+ body.deserialize(bodyId, mapping, manager);
31745
+ }
31746
+ else {
31747
+ // The following is for backward compatibility.
31748
+ body.set(EShapeConnectorBodies.from(points.values));
31749
+ }
31750
+ // Unlock
31751
+ shape.unlock();
31591
31752
  }
31592
31753
  }
31593
31754
  };
@@ -84944,6 +85105,8 @@ exports.EShapeButtonRuntimeActionToggle = EShapeButtonRuntimeActionToggle;
84944
85105
  exports.EShapeCapabilities = EShapeCapabilities;
84945
85106
  exports.EShapeCapability = EShapeCapability;
84946
85107
  exports.EShapeCircle = EShapeCircle;
85108
+ exports.EShapeConnectorBodies = EShapeConnectorBodies;
85109
+ exports.EShapeConnectorBodyImpl = EShapeConnectorBodyImpl;
84947
85110
  exports.EShapeConnectorContainerImpl = EShapeConnectorContainerImpl;
84948
85111
  exports.EShapeConnectorEdgeAcceptorImpl = EShapeConnectorEdgeAcceptorImpl;
84949
85112
  exports.EShapeConnectorEdgeContainerImpl = EShapeConnectorEdgeContainerImpl;