@syncfusion/ej2-inputs 23.1.36 → 23.1.38

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.
@@ -9188,6 +9188,7 @@ var Uploader = /** @__PURE__ @class */ (function (_super) {
9188
9188
  var fileData = [];
9189
9189
  if (!this.multiple) {
9190
9190
  this.clearData(true);
9191
+ this.actionCompleteCount = 0;
9191
9192
  targetFiles = [targetFiles[0]];
9192
9193
  }
9193
9194
  for (var i = 0; i < targetFiles.length; i++) {
@@ -14211,20 +14212,28 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14211
14212
  }
14212
14213
  };
14213
14214
  SignatureBase.prototype.setHTMLProperties = function () {
14214
- if (this.element.height === 150 && this.element.width === 300) {
14215
+ if (this.element.height === 150 && this.element.width === 300 && this.element.offsetHeight !== 0 && this.element.offsetWidth !== 0) {
14215
14216
  this.element.height = this.element.offsetHeight;
14216
14217
  this.element.width = this.element.offsetWidth;
14217
14218
  this.isResponsive = true;
14218
14219
  }
14219
- else if (this.element.height !== this.element.offsetHeight - 1 || this.element.width !== this.element.offsetWidth - 1) {
14220
+ else if ((this.element.height !== this.element.offsetHeight - 1 || this.element.width !== this.element.offsetWidth - 1)
14221
+ && this.element.offsetHeight !== 0 && this.element.offsetWidth !== 0) {
14220
14222
  this.element.height = this.element.offsetHeight;
14221
14223
  this.element.width = this.element.offsetWidth;
14222
14224
  }
14223
14225
  this.canvasContext.scale(1, 1);
14224
14226
  this.canvasContext.fillStyle = this.strokeColor;
14227
+ this.tempCanvas = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-temp' });
14228
+ this.tempContext = this.tempCanvas.getContext('2d');
14229
+ this.tempCanvas.width = this.element.width;
14230
+ this.tempCanvas.height = this.element.height;
14225
14231
  if (this.backgroundImage) {
14226
14232
  this.canvasContext.canvas.style.backgroundImage = 'url(' + this.backgroundImage + ')';
14227
14233
  this.canvasContext.canvas.style.backgroundRepeat = 'no-repeat';
14234
+ if (this.saveWithBackground) {
14235
+ this.setBackgroundImage(this.backgroundImage, 'temp');
14236
+ }
14228
14237
  }
14229
14238
  else if (this.backgroundColor) {
14230
14239
  this.canvasContext.canvas.style.backgroundColor = this.backgroundColor;
@@ -14331,7 +14340,7 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14331
14340
  }
14332
14341
  };
14333
14342
  SignatureBase.prototype.beginStroke = function (e) {
14334
- this.refresh();
14343
+ this.internalRefresh();
14335
14344
  this.updateStroke(e);
14336
14345
  };
14337
14346
  SignatureBase.prototype.updateStroke = function (e) {
@@ -14582,19 +14591,27 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14582
14591
  this.clearArray.push(this.incStep);
14583
14592
  }
14584
14593
  };
14585
- SignatureBase.prototype.setBackgroundImage = function (imageSrc) {
14594
+ SignatureBase.prototype.setBackgroundImage = function (imageSrc, type) {
14586
14595
  // eslint-disable-next-line @typescript-eslint/no-this-alias
14587
14596
  var proxy = this;
14588
14597
  var imageObj = new Image();
14589
14598
  imageObj.crossOrigin = 'anonymous';
14590
14599
  imageObj.src = imageSrc;
14591
- imageObj.onload = function () {
14592
- proxy.canvasContext.globalCompositeOperation = 'source-over';
14593
- proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
14594
- proxy.updateSnapCollection();
14595
- proxy.saveBackground(true);
14596
- };
14597
- this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
14600
+ if (type == 'temp') {
14601
+ imageObj.onload = function () {
14602
+ proxy.tempContext.globalCompositeOperation = 'source-over';
14603
+ proxy.tempContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
14604
+ };
14605
+ }
14606
+ else {
14607
+ imageObj.onload = function () {
14608
+ proxy.canvasContext.globalCompositeOperation = 'source-over';
14609
+ proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
14610
+ proxy.updateSnapCollection();
14611
+ proxy.saveBackground(true);
14612
+ };
14613
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
14614
+ }
14598
14615
  };
14599
14616
  SignatureBase.prototype.setBackgroundColor = function (color) {
14600
14617
  var canvasEle = this.canvasContext;
@@ -14650,16 +14667,21 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14650
14667
  a.click();
14651
14668
  a.parentNode.removeChild(a);
14652
14669
  };
14670
+ SignatureBase.prototype.internalRefresh = function () {
14671
+ this.pointColl = [];
14672
+ this.lastVelocity = 0;
14673
+ this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
14674
+ };
14653
14675
  /**
14654
14676
  * To refresh the signature.
14655
14677
  *
14656
- * @private
14657
14678
  * @returns {void}.
14658
14679
  */
14659
14680
  SignatureBase.prototype.refresh = function () {
14660
- this.pointColl = [];
14661
- this.lastVelocity = 0;
14662
- this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
14681
+ this.isResponsive = false;
14682
+ this.setHTMLProperties();
14683
+ this.resizeHandler();
14684
+ this.internalRefresh();
14663
14685
  };
14664
14686
  /**
14665
14687
  * Erases all the signature strokes signed by user.
@@ -14669,7 +14691,7 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14669
14691
  SignatureBase.prototype.clear = function () {
14670
14692
  var args = { actionName: 'clear' };
14671
14693
  this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
14672
- this.refresh();
14694
+ this.internalRefresh();
14673
14695
  this.signRatioPointsColl = [];
14674
14696
  this.updateSnapCollection(true);
14675
14697
  this.isSignatureEmpty = true;
@@ -14944,8 +14966,7 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14944
14966
  this.snapColl.pop();
14945
14967
  this.incStep--;
14946
14968
  };
14947
- SignatureBase.prototype.toSVG = function (fileName) {
14948
- var dataUrl = this.canvasContext.canvas.toDataURL();
14969
+ SignatureBase.prototype.toSVG = function (fileName, dataUrl) {
14949
14970
  var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
14950
14971
  svg.setAttribute('width', this.canvasContext.canvas.width.toString());
14951
14972
  svg.setAttribute('height', this.canvasContext.canvas.height.toString());
@@ -14986,27 +15007,23 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
14986
15007
  * @returns {string}.
14987
15008
  */
14988
15009
  SignatureBase.prototype.getSignature = function (type) {
15010
+ if (this.saveWithBackground && this.backgroundColor && !this.backgroundImage) {
15011
+ this.tempContext.fillStyle = this.backgroundColor;
15012
+ this.tempContext.fillRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
15013
+ }
15014
+ else if (!this.backgroundColor && !this.backgroundImage && type === 'Jpeg') {
15015
+ this.tempContext.fillStyle = "#fff";
15016
+ this.tempContext.fillRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
15017
+ }
15018
+ this.tempContext.drawImage(this.element, 0, 0);
14989
15019
  if (type === 'Jpeg') {
14990
- var imgData = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
14991
- var data = imgData.data;
14992
- for (var i = 0; i < data.length; i += 4) {
14993
- if (data[i + 3] < 255) {
14994
- data[i] = 255 - data[i];
14995
- data[i + 1] = 255 - data[i + 1];
14996
- data[i + 2] = 255 - data[i + 2];
14997
- data[i + 3] = 255 - data[i + 3];
14998
- }
14999
- }
15000
- this.canvasContext.putImageData(imgData, 0, 0);
15001
- var dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
15002
- this.resizeHandler();
15003
- return dataURL;
15020
+ return this.tempCanvas.toDataURL('image/jpeg');
15004
15021
  }
15005
15022
  else if (type === 'Svg') {
15006
- return this.toSVG(null);
15023
+ return this.toSVG(null, this.tempCanvas.toDataURL('image/png'));
15007
15024
  }
15008
15025
  else {
15009
- return this.canvasContext.canvas.toDataURL('image/png');
15026
+ return this.tempCanvas.toDataURL('image/png');
15010
15027
  }
15011
15028
  };
15012
15029
  /**
@@ -15061,6 +15078,9 @@ var SignatureBase = /** @__PURE__ @class */ (function (_super) {
15061
15078
  case 'backgroundImage':
15062
15079
  canvasNew.canvas.style.backgroundImage = 'url(' + value + ')';
15063
15080
  this.backgroundImage = value;
15081
+ if (this.saveWithBackground) {
15082
+ this.setBackgroundImage(this.backgroundImage, 'temp');
15083
+ }
15064
15084
  break;
15065
15085
  case 'strokeColor':
15066
15086
  canvasNew.fillStyle = value;