@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
 
@@ -30908,6 +30908,41 @@
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) {
30919
+ var result = [];
30920
+ var length = values.length;
30921
+ if (4 < length) {
30922
+ var x0 = values[0];
30923
+ var y0 = values[1];
30924
+ var x1 = values[length - 2];
30925
+ var y1 = values[length - 1];
30926
+ var cx = (x1 + x0) * 0.5;
30927
+ var cy = (y1 + y0) * 0.5;
30928
+ var dx = x1 - x0;
30929
+ var dy = y1 - y0;
30930
+ var a = Math.atan2(dy, dx);
30931
+ var c = Math.cos(a);
30932
+ var s = Math.sin(a);
30933
+ var l = dx * dx + dy * dy;
30934
+ var m = 0.000001 < l ? 1 / Math.sqrt(l) : 1;
30935
+ for (var i = 2, imax = length - 2; i < imax; i += 2) {
30936
+ var x = values[i + 0] - cx;
30937
+ var y = values[i + 1] - cy;
30938
+ result.push((c * x - s * y) * m, (c * y + s * x) * m);
30939
+ }
30940
+ }
30941
+ return result;
30942
+ };
30943
+ return EShapeConnectorBodies;
30944
+ }());
30945
+
30911
30946
  /*
30912
30947
  * Copyright (C) 2019 Toshiba Corporation
30913
30948
  * SPDX-License-Identifier: Apache-2.0
@@ -31375,6 +31410,93 @@
31375
31410
  return EShapeConnectorEdgeContainerImpl;
31376
31411
  }());
31377
31412
 
31413
+ /*
31414
+ * Copyright (C) 2019 Toshiba Corporation
31415
+ * SPDX-License-Identifier: Apache-2.0
31416
+ */
31417
+ var EShapeConnectorBodyImpl = /** @class */ (function () {
31418
+ function EShapeConnectorBodyImpl(parent, onChange) {
31419
+ this._parent = parent;
31420
+ this._id = 0;
31421
+ this._values = [];
31422
+ this._lockCount = 0;
31423
+ this._isChanged = false;
31424
+ this._onChange = onChange;
31425
+ }
31426
+ EShapeConnectorBodyImpl.prototype.lock = function () {
31427
+ this._lockCount += 1;
31428
+ if (this._lockCount === 1) {
31429
+ this._isChanged = false;
31430
+ }
31431
+ };
31432
+ EShapeConnectorBodyImpl.prototype.unlock = function () {
31433
+ this._lockCount -= 1;
31434
+ if (this._lockCount === 0) {
31435
+ if (this._isChanged) {
31436
+ this.onChange();
31437
+ }
31438
+ this._isChanged = false;
31439
+ }
31440
+ };
31441
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "id", {
31442
+ get: function () {
31443
+ return this._id;
31444
+ },
31445
+ enumerable: false,
31446
+ configurable: true
31447
+ });
31448
+ Object.defineProperty(EShapeConnectorBodyImpl.prototype, "values", {
31449
+ get: function () {
31450
+ return this._values;
31451
+ },
31452
+ set: function (newValues) {
31453
+ this.set(newValues);
31454
+ },
31455
+ enumerable: false,
31456
+ configurable: true
31457
+ });
31458
+ EShapeConnectorBodyImpl.prototype.set = function (newValues) {
31459
+ if (newValues != null) {
31460
+ this._id += 1;
31461
+ if (this._values !== newValues) {
31462
+ var length_1 = newValues.length;
31463
+ var values = this._values;
31464
+ for (var i = 0; i < length_1; ++i) {
31465
+ values[i] = newValues[i];
31466
+ }
31467
+ values.length = length_1;
31468
+ }
31469
+ this.onChange();
31470
+ }
31471
+ return this;
31472
+ };
31473
+ EShapeConnectorBodyImpl.prototype.copy = function (source) {
31474
+ return this.set(source.values);
31475
+ };
31476
+ EShapeConnectorBodyImpl.prototype.serialize = function (manager) {
31477
+ return manager.addResource(JSON.stringify(this._values));
31478
+ };
31479
+ EShapeConnectorBodyImpl.prototype.deserialize = function (resourceId, mapping, manager) {
31480
+ var resources = manager.resources;
31481
+ if (0 <= resourceId && resourceId < resources.length) {
31482
+ var parsed = manager.getExtension(resourceId);
31483
+ if (parsed == null) {
31484
+ parsed = JSON.parse(resources[resourceId]);
31485
+ manager.setExtension(resourceId, parsed);
31486
+ }
31487
+ this.set(parsed);
31488
+ }
31489
+ };
31490
+ EShapeConnectorBodyImpl.prototype.onChange = function () {
31491
+ if (0 < this._lockCount) {
31492
+ this._isChanged = true;
31493
+ return;
31494
+ }
31495
+ this._onChange();
31496
+ };
31497
+ return EShapeConnectorBodyImpl;
31498
+ }());
31499
+
31378
31500
  /*
31379
31501
  * Copyright (C) 2019 Toshiba Corporation
31380
31502
  * SPDX-License-Identifier: Apache-2.0
@@ -31388,16 +31510,36 @@
31388
31510
  _this._tailMargin = 0;
31389
31511
  _this._headLocalId = 0;
31390
31512
  _this._headMargin = 0;
31513
+ _this._bodyId = 0;
31514
+ _this._lockCount = 0;
31515
+ _this._isChanged = false;
31391
31516
  var sx = EShapeDefaults.SIZE_X;
31392
31517
  var sy = EShapeDefaults.SIZE_Y;
31393
31518
  var hx = sx * 0.5;
31394
31519
  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
- });
31520
+ _this._points = new EShapeLinePoints(_this).set([-hx, -hy, +hx, +hy]);
31521
+ var onChangeBound = function () {
31522
+ _this.onChange();
31523
+ };
31524
+ _this._edge = new EShapeConnectorEdgeContainerImpl(_this, onChangeBound);
31525
+ _this._body = new EShapeConnectorBodyImpl(_this, onChangeBound);
31399
31526
  return _this;
31400
31527
  }
31528
+ EShapeConnectorLine.prototype.lock = function () {
31529
+ this._lockCount += 1;
31530
+ if (this._lockCount === 1) {
31531
+ this._isChanged = false;
31532
+ }
31533
+ };
31534
+ EShapeConnectorLine.prototype.unlock = function () {
31535
+ this._lockCount -= 1;
31536
+ if (this._lockCount === 0) {
31537
+ if (this._isChanged) {
31538
+ this.onChange();
31539
+ }
31540
+ this._isChanged = false;
31541
+ }
31542
+ };
31401
31543
  Object.defineProperty(EShapeConnectorLine.prototype, "points", {
31402
31544
  get: function () {
31403
31545
  return this._points;
@@ -31412,6 +31554,13 @@
31412
31554
  enumerable: false,
31413
31555
  configurable: true
31414
31556
  });
31557
+ Object.defineProperty(EShapeConnectorLine.prototype, "body", {
31558
+ get: function () {
31559
+ return this._body;
31560
+ },
31561
+ enumerable: false,
31562
+ configurable: true
31563
+ });
31415
31564
  EShapeConnectorLine.prototype.onAttach = function () {
31416
31565
  _super.prototype.onAttach.call(this);
31417
31566
  this._edge.attach();
@@ -31420,8 +31569,12 @@
31420
31569
  this._edge.detach();
31421
31570
  _super.prototype.onDetach.call(this);
31422
31571
  };
31423
- EShapeConnectorLine.prototype.onEdgeChange = function () {
31572
+ EShapeConnectorLine.prototype.onChange = function () {
31424
31573
  var _a;
31574
+ if (0 < this._lockCount) {
31575
+ this._isChanged = true;
31576
+ return;
31577
+ }
31425
31578
  var edge = this._edge;
31426
31579
  var tail = edge.tail;
31427
31580
  var tailLocalId = tail.localId;
@@ -31429,22 +31582,29 @@
31429
31582
  var head = edge.head;
31430
31583
  var headLocalId = head.localId;
31431
31584
  var headMargin = head.margin;
31585
+ var body = this._body;
31586
+ var bodyId = body.id;
31432
31587
  if (this._tailLocalId !== tailLocalId ||
31433
31588
  this._tailMargin !== tailMargin ||
31434
31589
  this._headLocalId !== headLocalId ||
31435
- this._headMargin !== headMargin) {
31590
+ this._headMargin !== headMargin ||
31591
+ this._bodyId !== bodyId) {
31436
31592
  this._tailLocalId = tailLocalId;
31437
31593
  this._tailMargin = tailMargin;
31438
31594
  this._headLocalId = headLocalId;
31439
31595
  this._headMargin = headMargin;
31440
- // Left
31596
+ this._bodyId !== bodyId;
31597
+ // Tail
31441
31598
  var tailLocal = tail.local;
31442
31599
  var tailLocalX = tailLocal.x;
31443
31600
  var tailLocalY = tailLocal.y;
31444
- // Right
31601
+ // Head
31445
31602
  var headLocal = head.local;
31446
31603
  var headLocalX = headLocal.x;
31447
31604
  var headLocalY = headLocal.y;
31605
+ // Body
31606
+ var bodyValues = body.values;
31607
+ var bodyValuesLength = bodyValues.length;
31448
31608
  // Values
31449
31609
  var transform = this.transform;
31450
31610
  var transformPosition = transform.position;
@@ -31452,7 +31612,58 @@
31452
31612
  var py = transformPosition.y;
31453
31613
  var points = this._points;
31454
31614
  var values = points.values;
31455
- this.toValues(tailLocalX - px, tailLocalY - py, headLocalX - px, headLocalY - py, tailMargin, headMargin, values);
31615
+ if (values.length < 4) {
31616
+ values[0] = 0;
31617
+ values[1] = 0;
31618
+ }
31619
+ var threshold = 0.000001;
31620
+ var x0 = tailLocalX - px;
31621
+ var y0 = tailLocalY - py;
31622
+ var x1 = headLocalX - px;
31623
+ var y1 = headLocalY - py;
31624
+ // Body
31625
+ if (0 < bodyValuesLength) {
31626
+ var cx_1 = (x1 + x0) * 0.5;
31627
+ var cy_1 = (y1 + y0) * 0.5;
31628
+ var dx = x1 - x0;
31629
+ var dy = y1 - y0;
31630
+ var a = Math.atan2(dy, dx);
31631
+ var c = Math.cos(a);
31632
+ var s = Math.sin(a);
31633
+ var l = Math.sqrt(dx * dx + dy * dy);
31634
+ for (var i = 0; i < bodyValuesLength; i += 2) {
31635
+ var x = bodyValues[i + 0];
31636
+ var y = bodyValues[i + 1];
31637
+ values[i + 2] = cx_1 + (c * x - s * y) * l;
31638
+ values[i + 3] = cy_1 + (c * y + s * x) * l;
31639
+ }
31640
+ }
31641
+ // Tail
31642
+ values[0] = x0;
31643
+ values[1] = y0;
31644
+ if (tailMargin !== 0) {
31645
+ var dx = values[2] - x0;
31646
+ var dy = values[3] - y0;
31647
+ var d = dx * dx + dy * dy;
31648
+ if (threshold < d) {
31649
+ var f = tailMargin / Math.sqrt(dx * dx + dy * dy);
31650
+ values[0] = x0 + dx * f;
31651
+ values[1] = y0 + dy * f;
31652
+ }
31653
+ }
31654
+ // Head
31655
+ values[2 + bodyValuesLength] = x1;
31656
+ values[3 + bodyValuesLength] = y1;
31657
+ if (headMargin !== 0) {
31658
+ var dx = values[0 + bodyValuesLength] - x1;
31659
+ var dy = values[1 + bodyValuesLength] - y1;
31660
+ var d = dx * dx + dy * dy;
31661
+ if (threshold < d) {
31662
+ var f = headMargin / Math.sqrt(dx * dx + dy * dy);
31663
+ values[2 + bodyValuesLength] = x1 + dx * f;
31664
+ values[3 + bodyValuesLength] = y1 + dy * f;
31665
+ }
31666
+ }
31456
31667
  // Center & size
31457
31668
  var boundary = ((_a = EShapeConnectorLine.WORK_BOUNDARY) !== null && _a !== void 0 ? _a : (EShapeConnectorLine.WORK_BOUNDARY = [0, 0, 0, 0]));
31458
31669
  toPointsBoundary(values, boundary);
@@ -31476,82 +31687,12 @@
31476
31687
  this.allowUploadedUpdate();
31477
31688
  }
31478
31689
  };
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
31690
  EShapeConnectorLine.prototype.copy = function (source, part) {
31551
31691
  if (part === void 0) { part = EShapeCopyPart.ALL; }
31552
31692
  _super.prototype.copy.call(this, source, part);
31553
31693
  if (source instanceof EShapeConnectorLine) {
31554
31694
  this._edge.copy(source.edge);
31695
+ this._body.copy(source.body);
31555
31696
  }
31556
31697
  return this;
31557
31698
  };
@@ -31560,7 +31701,10 @@
31560
31701
  };
31561
31702
  EShapeConnectorLine.prototype.serialize = function (manager) {
31562
31703
  var result = _super.prototype.serialize.call(this, manager);
31563
- result[15] = manager.addResource("[" + this._edge.serialize(manager) + "," + this._points.serialize(manager) + "]");
31704
+ var edgeId = this._edge.serialize(manager);
31705
+ var bodyId = this._body.serialize(manager);
31706
+ var pointsId = this._points.serialize(manager);
31707
+ result[15] = manager.addResource("[" + edgeId + "," + pointsId + "," + bodyId + "]");
31564
31708
  return result;
31565
31709
  };
31566
31710
  return EShapeConnectorLine;
@@ -31583,8 +31727,25 @@
31583
31727
  parsed = JSON.parse(resources[resourceId]);
31584
31728
  manager.setExtension(resourceId, parsed);
31585
31729
  }
31586
- shape.points.deserialize(parsed[1], manager);
31730
+ // Lock
31731
+ shape.lock();
31732
+ // Points
31733
+ var points = shape.points;
31734
+ points.deserialize(parsed[1], manager);
31735
+ // Edge
31587
31736
  shape.edge.deserialize(parsed[0], mapping, manager);
31737
+ // Body
31738
+ var body = shape.body;
31739
+ var bodyId = parsed[2];
31740
+ if (bodyId != null) {
31741
+ body.deserialize(bodyId, mapping, manager);
31742
+ }
31743
+ else {
31744
+ // The following is for backward compatibility.
31745
+ body.set(EShapeConnectorBodies.from(points.values));
31746
+ }
31747
+ // Unlock
31748
+ shape.unlock();
31588
31749
  }
31589
31750
  }
31590
31751
  };
@@ -67477,6 +67638,8 @@
67477
67638
  EShapeBuffer: EShapeBuffer,
67478
67639
  EShapeCapabilities: EShapeCapabilities,
67479
67640
  EShapeCapability: EShapeCapability,
67641
+ EShapeConnectorBodies: EShapeConnectorBodies,
67642
+ EShapeConnectorBodyImpl: EShapeConnectorBodyImpl,
67480
67643
  EShapeConnectorContainerImpl: EShapeConnectorContainerImpl,
67481
67644
  EShapeConnectorEdgeAcceptorImpl: EShapeConnectorEdgeAcceptorImpl,
67482
67645
  EShapeConnectorEdgeContainerImpl: EShapeConnectorEdgeContainerImpl,