@syncfusion/ej2-inputs 19.3.48 → 19.4.41

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 (153) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/common.d.ts +4 -0
  4. package/common.js +4 -0
  5. package/dist/ej2-inputs.umd.min.js +2 -2
  6. package/dist/ej2-inputs.umd.min.js.map +1 -1
  7. package/dist/es6/ej2-inputs.es2015.js +1115 -8
  8. package/dist/es6/ej2-inputs.es2015.js.map +1 -1
  9. package/dist/es6/ej2-inputs.es5.js +1149 -7
  10. package/dist/es6/ej2-inputs.es5.js.map +1 -1
  11. package/dist/global/ej2-inputs.min.js +2 -2
  12. package/dist/global/ej2-inputs.min.js.map +1 -1
  13. package/dist/global/index.d.ts +1 -1
  14. package/package.json +9 -9
  15. package/signature.d.ts +4 -0
  16. package/signature.js +4 -0
  17. package/src/common/index.d.ts +4 -0
  18. package/src/common/index.js +4 -0
  19. package/src/common/signature-base.d.ts +320 -0
  20. package/src/common/signature-base.js +946 -0
  21. package/src/index.d.ts +2 -0
  22. package/src/index.js +2 -0
  23. package/src/input/input.js +10 -6
  24. package/src/numerictextbox/numerictextbox.js +9 -0
  25. package/src/signature/index.d.ts +5 -0
  26. package/src/signature/index.js +4 -0
  27. package/src/signature/signature-model.d.ts +131 -0
  28. package/src/signature/signature.d.ts +167 -0
  29. package/src/signature/signature.js +171 -0
  30. package/src/slider/slider.d.ts +1 -0
  31. package/src/slider/slider.js +9 -0
  32. package/styles/bootstrap-dark.css +43 -16
  33. package/styles/bootstrap-dark.scss +1 -0
  34. package/styles/bootstrap.css +43 -16
  35. package/styles/bootstrap.scss +1 -0
  36. package/styles/bootstrap4.css +43 -16
  37. package/styles/bootstrap4.scss +1 -0
  38. package/styles/bootstrap5-dark.css +46 -41
  39. package/styles/bootstrap5-dark.scss +1 -0
  40. package/styles/bootstrap5.css +46 -41
  41. package/styles/bootstrap5.scss +1 -0
  42. package/styles/color-picker/_fabric-dark-definition.scss +1 -1
  43. package/styles/color-picker/_fluent-definition.scss +134 -0
  44. package/styles/color-picker/_layout.scss +5 -5
  45. package/styles/color-picker/_theme.scss +16 -15
  46. package/styles/color-picker/bootstrap-dark.css +20 -0
  47. package/styles/color-picker/bootstrap.css +20 -0
  48. package/styles/color-picker/bootstrap4.css +20 -0
  49. package/styles/color-picker/bootstrap5-dark.css +22 -20
  50. package/styles/color-picker/bootstrap5.css +22 -20
  51. package/styles/color-picker/fabric-dark.css +23 -3
  52. package/styles/color-picker/fabric.css +20 -0
  53. package/styles/color-picker/highcontrast-light.css +20 -0
  54. package/styles/color-picker/highcontrast.css +20 -0
  55. package/styles/color-picker/icons/_fluent.scss +10 -0
  56. package/styles/color-picker/material-dark.css +20 -0
  57. package/styles/color-picker/material.css +20 -0
  58. package/styles/color-picker/tailwind-dark.css +20 -0
  59. package/styles/color-picker/tailwind.css +20 -0
  60. package/styles/fabric-dark.css +46 -19
  61. package/styles/fabric-dark.scss +1 -0
  62. package/styles/fabric.css +43 -16
  63. package/styles/fabric.scss +1 -0
  64. package/styles/highcontrast-light.css +43 -16
  65. package/styles/highcontrast-light.scss +1 -0
  66. package/styles/highcontrast.css +43 -16
  67. package/styles/highcontrast.scss +1 -0
  68. package/styles/input/_fluent-definition.scss +321 -0
  69. package/styles/input/_layout.scss +138 -37
  70. package/styles/input/_theme.scss +42 -24
  71. package/styles/input/bootstrap-dark.css +13 -16
  72. package/styles/input/bootstrap.css +13 -16
  73. package/styles/input/bootstrap4.css +13 -16
  74. package/styles/input/bootstrap5-dark.css +13 -16
  75. package/styles/input/bootstrap5.css +13 -16
  76. package/styles/input/fabric-dark.css +13 -16
  77. package/styles/input/fabric.css +13 -16
  78. package/styles/input/highcontrast-light.css +13 -16
  79. package/styles/input/highcontrast.css +13 -16
  80. package/styles/input/icons/_fluent.scss +17 -0
  81. package/styles/input/material-dark.css +13 -16
  82. package/styles/input/material.css +13 -16
  83. package/styles/input/tailwind-dark.css +13 -16
  84. package/styles/input/tailwind.css +13 -16
  85. package/styles/maskedtextbox/_fluent-definition.scss +7 -0
  86. package/styles/maskedtextbox/_theme.scss +2 -2
  87. package/styles/material-dark.css +43 -16
  88. package/styles/material-dark.scss +1 -0
  89. package/styles/material.css +43 -16
  90. package/styles/material.scss +1 -0
  91. package/styles/numerictextbox/_fluent-definition.scss +5 -0
  92. package/styles/numerictextbox/_theme.scss +18 -0
  93. package/styles/numerictextbox/icons/_fluent.scss +12 -0
  94. package/styles/signature/_all.scss +2 -0
  95. package/styles/signature/_bootstrap-dark-definition.scss +3 -0
  96. package/styles/signature/_bootstrap-definition.scss +3 -0
  97. package/styles/signature/_bootstrap4-definition.scss +3 -0
  98. package/styles/signature/_bootstrap5-dark-definition.scss +1 -0
  99. package/styles/signature/_bootstrap5-definition.scss +3 -0
  100. package/styles/signature/_fabric-dark-definition.scss +3 -0
  101. package/styles/signature/_fabric-definition.scss +3 -0
  102. package/styles/signature/_fluent-definition.scss +3 -0
  103. package/styles/signature/_highcontrast-definition.scss +3 -0
  104. package/styles/signature/_highcontrast-light-definition.scss +3 -0
  105. package/styles/signature/_layout.scss +5 -0
  106. package/styles/signature/_material-dark-definition.scss +3 -0
  107. package/styles/signature/_material-definition.scss +3 -0
  108. package/styles/signature/_tailwind-dark-definition.scss +1 -0
  109. package/styles/signature/_tailwind-definition.scss +3 -0
  110. package/styles/signature/_theme.scss +7 -0
  111. package/styles/signature/bootstrap-dark.css +9 -0
  112. package/styles/signature/bootstrap-dark.scss +3 -0
  113. package/styles/signature/bootstrap.css +9 -0
  114. package/styles/signature/bootstrap.scss +3 -0
  115. package/styles/signature/bootstrap4.css +9 -0
  116. package/styles/signature/bootstrap4.scss +3 -0
  117. package/styles/signature/bootstrap5-dark.css +9 -0
  118. package/styles/signature/bootstrap5-dark.scss +3 -0
  119. package/styles/signature/bootstrap5.css +9 -0
  120. package/styles/signature/bootstrap5.scss +3 -0
  121. package/styles/signature/fabric-dark.css +9 -0
  122. package/styles/signature/fabric-dark.scss +3 -0
  123. package/styles/signature/fabric.css +9 -0
  124. package/styles/signature/fabric.scss +3 -0
  125. package/styles/signature/highcontrast-light.css +9 -0
  126. package/styles/signature/highcontrast-light.scss +3 -0
  127. package/styles/signature/highcontrast.css +9 -0
  128. package/styles/signature/highcontrast.scss +3 -0
  129. package/styles/signature/material-dark.css +10 -0
  130. package/styles/signature/material-dark.scss +3 -0
  131. package/styles/signature/material.css +10 -0
  132. package/styles/signature/material.scss +3 -0
  133. package/styles/signature/tailwind-dark.css +10 -0
  134. package/styles/signature/tailwind-dark.scss +3 -0
  135. package/styles/signature/tailwind.css +10 -0
  136. package/styles/signature/tailwind.scss +3 -0
  137. package/styles/slider/_bootstrap5-definition.scss +2 -2
  138. package/styles/slider/_fluent-definition.scss +94 -0
  139. package/styles/slider/_layout.scss +7 -2
  140. package/styles/slider/_tailwind-definition.scss +2 -2
  141. package/styles/slider/bootstrap5-dark.css +1 -5
  142. package/styles/slider/bootstrap5.css +1 -5
  143. package/styles/slider/tailwind-dark.css +1 -5
  144. package/styles/slider/tailwind.css +1 -5
  145. package/styles/tailwind-dark.css +45 -21
  146. package/styles/tailwind-dark.scss +1 -0
  147. package/styles/tailwind.css +45 -21
  148. package/styles/tailwind.scss +1 -0
  149. package/styles/textbox/_fluent-definition.scss +0 -0
  150. package/styles/uploader/_fluent-definition.scss +234 -0
  151. package/styles/uploader/_layout.scss +99 -8
  152. package/styles/uploader/_theme.scss +5 -2
  153. package/styles/uploader/icons/_fluent.scss +34 -0
@@ -0,0 +1,946 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { Component, removeClass } from '@syncfusion/ej2-base';
15
+ import { EventHandler, isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ var SignatureBase = /** @class */ (function (_super) {
17
+ __extends(SignatureBase, _super);
18
+ function SignatureBase() {
19
+ var _this = _super !== null && _super.apply(this, arguments) || this;
20
+ /* minDistance(distance between the two point) was calaculated for smoothness.*/
21
+ _this.minDistance = 5;
22
+ _this.previous = 0;
23
+ /* interval handles for the smoothness in the mouse move event.*/
24
+ _this.interval = 30;
25
+ _this.timeout = null;
26
+ _this.isSignatureEmpty = true;
27
+ _this.backgroundLoaded = null;
28
+ _this.clearArray = [];
29
+ _this.isBlazor = false;
30
+ return _this;
31
+ }
32
+ /**
33
+ * To Initialize the component rendering
34
+ *
35
+ * @private
36
+ * @param {HTMLCanvasElement} element - Specifies the canvas element.
37
+ * @param {parameter} parameter - Specifies only for the blazor parameter.
38
+ * @param {BlazorDotnetObject} dotnetRef - Specifies for blazor client to server communication.
39
+ * @returns {void}
40
+ */
41
+ SignatureBase.prototype.initialize = function (element, parameter, dotnetRef) {
42
+ this.element = element;
43
+ this.canvasContext = this.element.getContext('2d');
44
+ this.canvasContext.canvas.tabIndex = 0;
45
+ if (parameter) {
46
+ this.setBlazorParameter(parameter);
47
+ this.dotnetRef = dotnetRef;
48
+ }
49
+ this.setHTMLProperties();
50
+ if (isNullOrUndefined(this.signatureValue)) {
51
+ this.updateSnapCollection(true);
52
+ }
53
+ this.wireEvents();
54
+ this.isSignatureEmpty = true;
55
+ if (!this.isBlazor) {
56
+ this.trigger('created', null);
57
+ }
58
+ };
59
+ SignatureBase.prototype.setBlazorParameter = function (parameter) {
60
+ this.isBlazor = true;
61
+ this.backgroundColor = parameter.backgroundColor;
62
+ this.backgroundImage = parameter.backgroundImage;
63
+ this.disabled = parameter.disabled;
64
+ this.isReadOnly = parameter.isReadOnly;
65
+ this.maxStrokeWidth = parameter.maxStrokeWidth || 2;
66
+ this.minStrokeWidth = parameter.minStrokeWidth || 0.5;
67
+ this.velocity = parameter.velocity || 0.7;
68
+ this.strokeColor = parameter.strokeColor || '#000000';
69
+ this.saveWithBackground = parameter.saveWithBackground;
70
+ this.interval = 30;
71
+ this.previous = 0;
72
+ this.minDistance = 5;
73
+ this.signatureValue = parameter.signatureValue;
74
+ if (this.signatureValue) {
75
+ this.loadPersistedSignature();
76
+ }
77
+ };
78
+ SignatureBase.prototype.wireEvents = function () {
79
+ if (isNullOrUndefined(this.pointColl) && !this.isReadOnly && !this.disabled) {
80
+ EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
81
+ EventHandler.add(this.canvasContext.canvas, 'keydown', this.keyboardHandler, this);
82
+ window.addEventListener('resize', this.resizeHandler.bind(this));
83
+ }
84
+ else if (this.pointColl) {
85
+ EventHandler.add(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler, this);
86
+ EventHandler.add(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler, this);
87
+ EventHandler.add(document, 'mouseup', this.mouseUpHandler, this);
88
+ }
89
+ };
90
+ SignatureBase.prototype.unwireEvents = function (type) {
91
+ if (type === 'mouseup' || type === 'touchend') {
92
+ EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
93
+ EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
94
+ EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
95
+ }
96
+ else {
97
+ EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
98
+ EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
99
+ EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
100
+ EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
101
+ EventHandler.remove(this.canvasContext.canvas, 'keydown', this.keyboardHandler);
102
+ window.removeEventListener('resize', this.resizeHandler);
103
+ }
104
+ };
105
+ SignatureBase.prototype.setHTMLProperties = function () {
106
+ if (this.element.height === 150) {
107
+ this.element.height = this.element.offsetHeight;
108
+ }
109
+ if (this.element.width === 300) {
110
+ this.element.width = this.element.offsetWidth;
111
+ }
112
+ this.canvasContext.scale(1, 1);
113
+ this.canvasContext.fillStyle = this.strokeColor;
114
+ if (this.backgroundImage) {
115
+ this.canvasContext.canvas.style.backgroundImage = 'url(' + this.backgroundImage + ')';
116
+ }
117
+ else if (this.backgroundColor) {
118
+ this.canvasContext.canvas.style.backgroundColor = this.backgroundColor;
119
+ }
120
+ };
121
+ SignatureBase.prototype.mouseDownHandler = function (e) {
122
+ if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchstart') {
123
+ if (e.type === 'touchstart') {
124
+ e.preventDefault();
125
+ e.stopPropagation();
126
+ }
127
+ this.beginStroke(e);
128
+ this.wireEvents();
129
+ }
130
+ };
131
+ SignatureBase.prototype.mouseMoveHandler = function (e) {
132
+ if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchmove') {
133
+ if (e.type === 'touchmove') {
134
+ e.preventDefault();
135
+ e.stopPropagation();
136
+ }
137
+ if (this.interval) {
138
+ this.updateStrokeWithThrottle(e);
139
+ }
140
+ else {
141
+ this.updateStroke(e);
142
+ }
143
+ }
144
+ };
145
+ SignatureBase.prototype.mouseUpHandler = function (e) {
146
+ var args = { actionName: 'strokeUpdate' };
147
+ if (e.type === 'touchstart') {
148
+ e.preventDefault();
149
+ e.stopPropagation();
150
+ }
151
+ this.endDraw();
152
+ this.updateSnapCollection();
153
+ this.unwireEvents(e.type);
154
+ if (!this.isBlazor) {
155
+ this.trigger('change', args);
156
+ }
157
+ else {
158
+ this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'mouseUp');
159
+ }
160
+ this.signatureValue = this.snapColl[this.incStep];
161
+ };
162
+ SignatureBase.prototype.keyboardHandler = function (e) {
163
+ var _this = this;
164
+ var args = { fileName: 'Signature', type: 'Png', cancel: false };
165
+ switch (e.key) {
166
+ case 'Delete':
167
+ this.clear();
168
+ break;
169
+ case (e.ctrlKey && 's'):
170
+ if (!this.isBlazor) {
171
+ this.trigger('beforeSave', args, function (observableSaveArgs) {
172
+ if (!args.cancel) {
173
+ _this.save(observableSaveArgs.type, observableSaveArgs.fileName);
174
+ }
175
+ });
176
+ }
177
+ else {
178
+ this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'beforeSave');
179
+ }
180
+ e.preventDefault();
181
+ e.stopImmediatePropagation();
182
+ break;
183
+ case (e.ctrlKey && 'z'):
184
+ this.undo();
185
+ break;
186
+ case (e.ctrlKey && 'y'):
187
+ this.redo();
188
+ break;
189
+ }
190
+ };
191
+ SignatureBase.prototype.resizeHandler = function () {
192
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
193
+ var proxy = this;
194
+ this.canvasContext.canvas.width = this.element.offsetWidth;
195
+ this.canvasContext.canvas.height = this.element.offsetHeight;
196
+ this.canvasContext.scale(1, 1);
197
+ var restoreImg = new Image();
198
+ restoreImg.src = this.snapColl[this.incStep];
199
+ restoreImg.onload = function () {
200
+ proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
201
+ proxy.canvasContext.drawImage(restoreImg, 0, 0, proxy.element.width, proxy.element.height);
202
+ };
203
+ };
204
+ SignatureBase.prototype.beginStroke = function (e) {
205
+ this.refresh();
206
+ this.updateStroke(e);
207
+ };
208
+ SignatureBase.prototype.updateStroke = function (e) {
209
+ var point = this.createPoint(e);
210
+ this.addPoint(point);
211
+ };
212
+ SignatureBase.prototype.updateStrokeWithThrottle = function (args) {
213
+ var now = Date.now();
214
+ var remaining = this.interval - (now - this.previous);
215
+ this.storedArgs = args;
216
+ if (remaining <= 0 || remaining > this.interval) {
217
+ if (this.timeout) {
218
+ clearTimeout(this.timeout);
219
+ this.timeout = null;
220
+ }
221
+ this.previous = now;
222
+ this.updateStroke(this.storedArgs);
223
+ if (!this.timeout) {
224
+ this.storedArgs = null;
225
+ }
226
+ }
227
+ else if (!this.timeout) {
228
+ this.timeout = window.setTimeout(this.delay.bind(this), remaining);
229
+ }
230
+ };
231
+ SignatureBase.prototype.delay = function () {
232
+ this.previous = Date.now();
233
+ this.timeout = null;
234
+ this.updateStroke(this.storedArgs);
235
+ if (!this.timeout) {
236
+ this.storedArgs = null;
237
+ }
238
+ };
239
+ SignatureBase.prototype.createPoint = function (e) {
240
+ var rect = this.canvasContext.canvas.getBoundingClientRect();
241
+ if (e.type === 'mousedown' || e.type === 'mousemove') {
242
+ return this.point(e.clientX - rect.left, e.clientY - rect.top, new Date().getTime());
243
+ }
244
+ else {
245
+ return this.point(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top, new Date().getTime());
246
+ }
247
+ };
248
+ /* Returns the current point corrdinates(x, y) and time.*/
249
+ SignatureBase.prototype.point = function (pointX, pointY, time) {
250
+ this.pointX = pointX;
251
+ this.pointY = pointY;
252
+ this.time = time || new Date().getTime();
253
+ return { x: this.pointX, y: this.pointY, time: this.time };
254
+ };
255
+ SignatureBase.prototype.addPoint = function (point) {
256
+ var points = this.pointColl;
257
+ var controlPoint1;
258
+ var controlPoint2;
259
+ var lastPoint = points.length > 0 && points[points.length - 1];
260
+ var isLastPointTooClose = lastPoint ? this.distanceTo(lastPoint) <= this.minDistance : false;
261
+ if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
262
+ points.push(point);
263
+ if (points.length > 2) {
264
+ if (points.length === 3) {
265
+ points.unshift(points[0]);
266
+ }
267
+ controlPoint1 = (this.calculateCurveControlPoints(points[0], points[1], points[2])).controlPoint2;
268
+ controlPoint2 = (this.calculateCurveControlPoints(points[1], points[2], points[3])).controlPoint1;
269
+ this.startPoint = points[1];
270
+ this.controlPoint1 = controlPoint1;
271
+ this.controlPoint2 = controlPoint2;
272
+ this.endPoint = points[2];
273
+ this.startDraw();
274
+ points.shift();
275
+ }
276
+ }
277
+ };
278
+ SignatureBase.prototype.startDraw = function () {
279
+ var velocity;
280
+ velocity = this.pointVelocityCalc(this.startPoint);
281
+ velocity = this.velocity * velocity + (1 - this.velocity) * this.lastVelocity;
282
+ var newWidth = Math.max(this.maxStrokeWidth / (velocity + 1), this.minStrokeWidth);
283
+ this.curveDraw(this.lastWidth, newWidth);
284
+ this.lastVelocity = velocity;
285
+ this.lastWidth = newWidth;
286
+ };
287
+ SignatureBase.prototype.endDraw = function () {
288
+ var canDrawCurve = this.pointColl.length > 2;
289
+ var point = this.pointColl[0];
290
+ if (!canDrawCurve && point) {
291
+ this.strokeDraw(point);
292
+ }
293
+ };
294
+ /* Calculate the Bezier (x, y) coordinate of the curve. */
295
+ SignatureBase.prototype.curveDraw = function (startWidth, endWidth) {
296
+ var context = this.canvasContext;
297
+ var width;
298
+ var i;
299
+ var t1;
300
+ var t2;
301
+ var t3;
302
+ var u1;
303
+ var u2;
304
+ var u3;
305
+ var x;
306
+ var y;
307
+ var widthValue = endWidth - startWidth;
308
+ var bezierLength = this.bezierLengthCalc();
309
+ var drawSteps = Math.ceil(bezierLength) * 2;
310
+ context.beginPath();
311
+ for (i = 0; i < drawSteps; i++) {
312
+ t1 = i / drawSteps;
313
+ t2 = t1 * t1;
314
+ t3 = t2 * t1;
315
+ u1 = 1 - t1;
316
+ u2 = u1 * u1;
317
+ u3 = u2 * u1;
318
+ x = u3 * this.startPoint.x;
319
+ x += 3 * u2 * t1 * this.controlPoint1.x;
320
+ x += 3 * u1 * t2 * this.controlPoint2.x;
321
+ x += t3 * this.endPoint.x;
322
+ y = u3 * this.startPoint.y;
323
+ y += 3 * u2 * t1 * this.controlPoint1.y;
324
+ y += 3 * u1 * t2 * this.controlPoint2.y;
325
+ y += t3 * this.endPoint.y;
326
+ width = Math.min(startWidth + t3 * widthValue, this.maxStrokeWidth);
327
+ this.arcDraw(x, y, width);
328
+ }
329
+ context.closePath();
330
+ context.fill();
331
+ this.isSignatureEmpty = false;
332
+ };
333
+ SignatureBase.prototype.strokeDraw = function (point) {
334
+ var context = this.canvasContext;
335
+ var pointSize = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
336
+ context.beginPath();
337
+ this.arcDraw(point.x, point.y, pointSize);
338
+ context.closePath();
339
+ context.fill();
340
+ this.isSignatureEmpty = false;
341
+ };
342
+ SignatureBase.prototype.arcDraw = function (x, y, size) {
343
+ var context = this.canvasContext;
344
+ context.moveTo(x, y);
345
+ context.arc(x, y, size, 0, 2 * Math.PI, false);
346
+ };
347
+ /* Utility functions for Bezier algorithm*/
348
+ SignatureBase.prototype.calculateCurveControlPoints = function (p1, p2, p3) {
349
+ var dx1 = p1.x - p2.x;
350
+ var dy1 = p1.y - p2.y;
351
+ var dx2 = p2.x - p3.x;
352
+ var dy2 = p2.y - p3.y;
353
+ var m1 = { x: (p1.x + p2.x) / 2.0, y: (p1.y + p2.y) / 2.0 };
354
+ var m2 = { x: (p2.x + p3.x) / 2.0, y: (p2.y + p3.y) / 2.0 };
355
+ var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
356
+ var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
357
+ var dxm = (m1.x - m2.x);
358
+ var dym = (m1.y - m2.y);
359
+ var k = l2 / (l1 + l2);
360
+ var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
361
+ var tx = p2.x - cm.x;
362
+ var ty = p2.y - cm.y;
363
+ return {
364
+ controlPoint1: this.point(m1.x + tx, m1.y + ty, 0),
365
+ controlPoint2: this.point(m2.x + tx, m2.y + ty, 0)
366
+ };
367
+ };
368
+ /* Returns approximated bezier length of the curuve.*/
369
+ SignatureBase.prototype.bezierLengthCalc = function () {
370
+ var steps = 10;
371
+ var length = 0;
372
+ var i;
373
+ var t;
374
+ var pointx1;
375
+ var pointy1;
376
+ var pointx2;
377
+ var pointy2;
378
+ var pointx3;
379
+ var pointy3;
380
+ for (i = 0; i <= steps; i++) {
381
+ t = i / steps;
382
+ pointx1 = this.bezierPointCalc(t, this.startPoint.x, this.controlPoint1.x, this.controlPoint2.x, this.endPoint.x);
383
+ pointy1 = this.bezierPointCalc(t, this.startPoint.y, this.controlPoint1.y, this.controlPoint2.y, this.endPoint.y);
384
+ if (i > 0) {
385
+ pointx3 = pointx1 - pointx2;
386
+ pointy3 = pointy1 - pointy2;
387
+ length += Math.sqrt(pointx3 * pointx3 + pointy3 * pointy3);
388
+ }
389
+ pointx2 = pointx1;
390
+ pointy2 = pointy1;
391
+ }
392
+ return length;
393
+ };
394
+ /* Calculate parametric value of x or y given t and the
395
+ four point(startpoint, controlpoint1, controlpoint2, endpoint) coordinates of a cubic bezier curve.*/
396
+ SignatureBase.prototype.bezierPointCalc = function (t, startpoint, cp1, cp2, endpoint) {
397
+ return startpoint * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * cp1 * (1.0 - t) * (1.0 - t) * t + 3.0 *
398
+ cp2 * (1.0 - t) * t * t + endpoint * t * t * t;
399
+ };
400
+ /* Velocity between the current point and last point.*/
401
+ SignatureBase.prototype.pointVelocityCalc = function (startPoint) {
402
+ return (this.time !== startPoint.time) ? this.distanceTo(startPoint) / (this.time - startPoint.time) : 0;
403
+ };
404
+ /* Distance between the current point and last point.*/
405
+ SignatureBase.prototype.distanceTo = function (start) {
406
+ return Math.sqrt(Math.pow(this.pointX - start.x, 2) + Math.pow(this.pointY - start.y, 2));
407
+ };
408
+ SignatureBase.prototype.isRead = function (isRead) {
409
+ if (isRead) {
410
+ EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
411
+ }
412
+ else if (!this.disabled) {
413
+ EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
414
+ }
415
+ };
416
+ SignatureBase.prototype.enableOrDisable = function (isDisable) {
417
+ this.disabled = isDisable;
418
+ if (isDisable) {
419
+ this.reDraw('0.5');
420
+ this.isRead(true);
421
+ }
422
+ else {
423
+ this.reDraw('1');
424
+ this.isRead(false);
425
+ }
426
+ };
427
+ SignatureBase.prototype.reDraw = function (opacity) {
428
+ var data = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
429
+ this.canvasContext.clearRect(0, 0, this.element.width, this.element.height);
430
+ this.element.style.opacity = opacity;
431
+ this.canvasContext.putImageData(data, 0, 0);
432
+ };
433
+ SignatureBase.prototype.updateSnapCollection = function (isClear) {
434
+ if (isNullOrUndefined(this.incStep)) {
435
+ this.incStep = -1;
436
+ this.incStep++;
437
+ this.snapColl = [];
438
+ this.clearArray = [];
439
+ }
440
+ else {
441
+ this.incStep++;
442
+ }
443
+ if (this.incStep < this.snapColl.length) {
444
+ this.snapColl.length = this.incStep;
445
+ }
446
+ if (this.incStep > 0) {
447
+ var canvasNew = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-wrapper' });
448
+ var canvasContextNew = canvasNew.getContext('2d');
449
+ canvasNew.width = this.canvasContext.canvas.width;
450
+ canvasNew.height = this.canvasContext.canvas.height;
451
+ canvasContextNew.drawImage(this.canvasContext.canvas, 0, 0, canvasNew.width, canvasNew.height);
452
+ this.snapColl.push(canvasNew.toDataURL());
453
+ }
454
+ else {
455
+ this.snapColl.push(this.canvasContext.canvas.toDataURL());
456
+ }
457
+ if (isClear) {
458
+ this.clearArray.push(this.incStep);
459
+ }
460
+ };
461
+ SignatureBase.prototype.setBackgroundImage = function (imageSrc) {
462
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
463
+ var proxy = this;
464
+ var imageObj = new Image();
465
+ imageObj.crossOrigin = 'anonymous';
466
+ imageObj.src = imageSrc;
467
+ imageObj.onload = function () {
468
+ proxy.canvasContext.globalCompositeOperation = 'source-over';
469
+ proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
470
+ proxy.updateSnapCollection();
471
+ proxy.saveBackground(true);
472
+ };
473
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
474
+ };
475
+ SignatureBase.prototype.setBackgroundColor = function (color) {
476
+ var canvasEle = this.canvasContext;
477
+ canvasEle.strokeStyle = color;
478
+ var i;
479
+ var j;
480
+ for (i = 1; i <= canvasEle.canvas.width; i++) {
481
+ for (j = 1; j <= canvasEle.canvas.height; j++) {
482
+ canvasEle.strokeRect(0, 0, i, j);
483
+ }
484
+ }
485
+ this.updateSnapCollection();
486
+ };
487
+ SignatureBase.prototype.loadPersistedSignature = function () {
488
+ if (isNullOrUndefined(this.signatureValue)) {
489
+ return;
490
+ }
491
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
492
+ var proxy = this;
493
+ var lastImage = new Image();
494
+ lastImage.src = this.signatureValue;
495
+ lastImage.onload = function () {
496
+ proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
497
+ proxy.canvasContext.drawImage(lastImage, 0, 0);
498
+ proxy.updateSnapCollection();
499
+ };
500
+ this.isSignatureEmpty = false;
501
+ };
502
+ /**
503
+ * To get the signature as Blob.
504
+ *
505
+ * @param {string} url - specify the url/base 64 string to get blob of the signature.
506
+ * @returns {Blob}.
507
+ */
508
+ SignatureBase.prototype.getBlob = function (url) {
509
+ var arr = url.split(',');
510
+ var type = arr[0].match(/:(.*?);/)[1];
511
+ var bstr = atob(arr[1]);
512
+ var n = bstr.length;
513
+ var u8arr = new Uint8Array(n);
514
+ while (n--) {
515
+ u8arr[n] = bstr.charCodeAt(n);
516
+ }
517
+ return new Blob([u8arr], { type: type });
518
+ };
519
+ SignatureBase.prototype.download = function (blob, fileName) {
520
+ var blobUrl = URL.createObjectURL(blob);
521
+ var a = document.createElement('a');
522
+ a.href = blobUrl;
523
+ a.target = '_parent';
524
+ a.download = fileName;
525
+ (document.body || document.documentElement).appendChild(a);
526
+ a.click();
527
+ a.parentNode.removeChild(a);
528
+ };
529
+ /**
530
+ * To refresh the signature.
531
+ *
532
+ * @private
533
+ * @returns {void}.
534
+ */
535
+ SignatureBase.prototype.refresh = function () {
536
+ this.pointColl = [];
537
+ this.lastVelocity = 0;
538
+ this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
539
+ };
540
+ /**
541
+ * Erases all the signature strokes signed by user.
542
+ *
543
+ * @returns {void}.
544
+ */
545
+ SignatureBase.prototype.clear = function () {
546
+ var args = { actionName: 'clear' };
547
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
548
+ this.refresh();
549
+ this.updateSnapCollection(true);
550
+ this.isSignatureEmpty = true;
551
+ if (!this.isBlazor) {
552
+ this.trigger('change', args);
553
+ }
554
+ else {
555
+ this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Clear');
556
+ }
557
+ };
558
+ /**
559
+ * Undo the last user action.
560
+ *
561
+ * @returns {void}.
562
+ */
563
+ SignatureBase.prototype.undo = function () {
564
+ var args = { actionName: 'undo' };
565
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
566
+ var proxy = this;
567
+ if (this.incStep > 0) {
568
+ this.incStep--;
569
+ var undoImg_1 = new Image();
570
+ undoImg_1.src = this.snapColl[this.incStep];
571
+ undoImg_1.onload = function () {
572
+ proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
573
+ proxy.canvasContext.drawImage(undoImg_1, 0, 0, proxy.element.width, proxy.element.height);
574
+ };
575
+ }
576
+ this.isClear();
577
+ if (!this.isBlazor) {
578
+ this.trigger('change', args);
579
+ }
580
+ else {
581
+ this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Undo');
582
+ }
583
+ };
584
+ /**
585
+ * Redo the last user action.
586
+ *
587
+ * @returns {void}.
588
+ */
589
+ SignatureBase.prototype.redo = function () {
590
+ var args = { actionName: 'redo' };
591
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
592
+ var proxy = this;
593
+ if (this.incStep < this.snapColl.length - 1) {
594
+ this.incStep++;
595
+ var redoImg_1 = new Image();
596
+ redoImg_1.src = this.snapColl[this.incStep];
597
+ redoImg_1.onload = function () {
598
+ proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
599
+ proxy.canvasContext.drawImage(redoImg_1, 0, 0, proxy.element.width, proxy.element.height);
600
+ };
601
+ }
602
+ this.isClear();
603
+ if (!this.isBlazor) {
604
+ this.trigger('change', args);
605
+ }
606
+ else {
607
+ this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Redo');
608
+ }
609
+ };
610
+ SignatureBase.prototype.isClear = function () {
611
+ if (this.clearArray) {
612
+ var empty = false;
613
+ for (var i = 0; i < this.clearArray.length; i++) {
614
+ if (this.clearArray[i] === this.incStep) {
615
+ this.isSignatureEmpty = true;
616
+ empty = true;
617
+ }
618
+ }
619
+ if (!empty) {
620
+ this.isSignatureEmpty = false;
621
+ }
622
+ }
623
+ };
624
+ /**
625
+ * To check whether the signature is empty or not.
626
+ *
627
+ * @returns {boolean}.
628
+ */
629
+ SignatureBase.prototype.isEmpty = function () {
630
+ return this.isSignatureEmpty;
631
+ };
632
+ /**
633
+ * To check whether the undo collection is empty or not.
634
+ *
635
+ * @returns {boolean}.
636
+ */
637
+ SignatureBase.prototype.canUndo = function () {
638
+ return this.incStep > 0;
639
+ };
640
+ /**
641
+ * To check whether the redo collection is empty or not.
642
+ *
643
+ * @returns {boolean}.
644
+ */
645
+ SignatureBase.prototype.canRedo = function () {
646
+ return this.incStep < this.snapColl.length - 1;
647
+ };
648
+ /**
649
+ * To draw the signature based on the given text, with the font family and font size.
650
+ *
651
+ * @param {string} text - specify text to be drawn as signature.
652
+ * @param {string} fontFamily - specify font family of a signature.
653
+ * @param {number} fontSize - specify font size of a signature.
654
+ *
655
+ * @returns {void}.
656
+ */
657
+ SignatureBase.prototype.draw = function (text, fontFamily, fontSize) {
658
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
659
+ fontFamily = fontFamily || 'Arial';
660
+ fontSize = fontSize || 30;
661
+ this.canvasContext.font = fontSize + 'px ' + fontFamily;
662
+ this.canvasContext.textAlign = 'center';
663
+ this.canvasContext.textBaseline = 'middle';
664
+ this.canvasContext.fillText(text, this.element.width / 2, this.element.height / 2);
665
+ this.updateSnapCollection();
666
+ this.isSignatureEmpty = false;
667
+ };
668
+ /**
669
+ * To load the signature with the given base 64 string, height and width.
670
+ *
671
+ * @param {string} signature - specify the url/base 64 string to be drawn as signature.
672
+ * @param {number} width - specify the width of the loaded signature image.
673
+ * @param {number} height - specify the height of the loaded signature image.
674
+ * @returns {void}.
675
+ */
676
+ SignatureBase.prototype.load = function (signature, width, height) {
677
+ height = height || this.element.height;
678
+ width = width || this.element.width;
679
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
680
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
681
+ var proxy = this;
682
+ var bitmapImage = new Image();
683
+ bitmapImage.src = signature;
684
+ bitmapImage.onload = function () {
685
+ Promise.all([
686
+ createImageBitmap(bitmapImage, 0, 0, width, height)
687
+ ]).then(function (results) {
688
+ var tempCanvas = document.createElement('canvas');
689
+ tempCanvas.width = width;
690
+ tempCanvas.height = height;
691
+ tempCanvas.getContext('2d').drawImage(results[0], 0, 0);
692
+ proxy.canvasContext.drawImage(tempCanvas, 0, 0, width, height, 0, 0, proxy.element.width, proxy.element.height);
693
+ proxy.updateSnapCollection();
694
+ });
695
+ };
696
+ this.isSignatureEmpty = false;
697
+ };
698
+ SignatureBase.prototype.saveBackground = function (savebg) {
699
+ var imageSrc;
700
+ if (savebg && this.backgroundImage) {
701
+ imageSrc = this.snapColl[this.incStep - 1];
702
+ }
703
+ else {
704
+ imageSrc = this.snapColl[this.incStep];
705
+ }
706
+ if (!savebg) {
707
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
708
+ if (this.backgroundImage) {
709
+ this.setBackgroundImage(this.backgroundImage);
710
+ }
711
+ else if (this.backgroundColor) {
712
+ this.setBackgroundColor(this.backgroundColor);
713
+ savebg = true;
714
+ }
715
+ }
716
+ if (savebg) {
717
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
718
+ var proxy_1 = this;
719
+ var imageObj_1 = new Image();
720
+ imageObj_1.crossOrigin = 'anonymous';
721
+ imageObj_1.src = imageSrc;
722
+ imageObj_1.onload = function () {
723
+ proxy_1.backgroundLoaded = true;
724
+ proxy_1.canvasContext.globalCompositeOperation = 'source-over';
725
+ proxy_1.canvasContext.drawImage(imageObj_1, 0, 0, proxy_1.element.width, proxy_1.element.height);
726
+ proxy_1.save(proxy_1.fileType, proxy_1.fileName);
727
+ };
728
+ }
729
+ };
730
+ /**
731
+ * To save the signature with the given file type and file name.
732
+ *
733
+ * @param {SignatureFileType} type - specify type of the file to be saved a signature.
734
+ * @param {string} fileName - specify name of the file to be saved a signature.
735
+ *
736
+ * @returns {void}.
737
+ */
738
+ SignatureBase.prototype.save = function (type, fileName) {
739
+ if (this.saveWithBackground && this.backgroundLoaded == null && (this.backgroundImage || this.backgroundColor)) {
740
+ this.backgroundLoaded = false;
741
+ this.fileType = type;
742
+ this.fileName = fileName;
743
+ this.saveBackground(false);
744
+ }
745
+ else if (type === 'Svg') {
746
+ fileName = fileName || 'Signature';
747
+ this.toSVG(fileName);
748
+ }
749
+ else if (type === 'Jpeg') {
750
+ fileName = fileName || 'Signature';
751
+ if (!this.saveWithBackground || this.saveWithBackground && !(this.backgroundImage || this.backgroundColor)) {
752
+ this.toJPEG(fileName);
753
+ }
754
+ else {
755
+ var dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
756
+ this.download(this.getBlob(dataURL), fileName + '.' + 'jpeg');
757
+ }
758
+ }
759
+ else {
760
+ fileName = fileName || 'Signature';
761
+ var dataURL = this.canvasContext.canvas.toDataURL('image/png');
762
+ this.download(this.getBlob(dataURL), fileName + '.' + 'png');
763
+ }
764
+ if (this.saveWithBackground && this.backgroundLoaded) {
765
+ this.resetSnap();
766
+ }
767
+ };
768
+ SignatureBase.prototype.resetSnap = function () {
769
+ this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
770
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
771
+ var proxy = this;
772
+ var restoreObj = new Image();
773
+ restoreObj.src = this.snapColl[this.incStep - 1];
774
+ restoreObj.onload = function () {
775
+ proxy.canvasContext.drawImage(restoreObj, 0, 0, proxy.element.width, proxy.element.height);
776
+ proxy.updateSnapCollection();
777
+ };
778
+ this.backgroundLoaded = null;
779
+ this.snapColl.pop();
780
+ this.incStep--;
781
+ this.snapColl.pop();
782
+ this.incStep--;
783
+ };
784
+ SignatureBase.prototype.toJPEG = function (fileName) {
785
+ var _this = this;
786
+ var imageSrc = this.snapColl[this.incStep];
787
+ this.setBackgroundColor('#ffffff');
788
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
789
+ var proxy = this;
790
+ var imageObj = new Image();
791
+ imageObj.crossOrigin = 'anonymous';
792
+ imageObj.src = imageSrc;
793
+ imageObj.onload = function () {
794
+ proxy.canvasContext.globalCompositeOperation = 'source-over';
795
+ proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
796
+ var dataURL = proxy.canvasContext.canvas.toDataURL('image/jpeg');
797
+ proxy.download(proxy.getBlob(dataURL), fileName + '.' + 'jpeg');
798
+ proxy.canvasContext.clearRect(0, 0, proxy.canvasContext.canvas.width, proxy.canvasContext.canvas.height);
799
+ _this.resizeHandler();
800
+ };
801
+ this.snapColl.pop();
802
+ this.incStep--;
803
+ };
804
+ SignatureBase.prototype.toSVG = function (fileName) {
805
+ var dataUrl = this.canvasContext.canvas.toDataURL();
806
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
807
+ svg.setAttribute('width', this.canvasContext.canvas.width.toString());
808
+ svg.setAttribute('height', this.canvasContext.canvas.height.toString());
809
+ var XLinkNS = 'http://www.w3.org/1999/xlink';
810
+ var img = document.createElementNS('http://www.w3.org/2000/svg', 'image');
811
+ img.setAttributeNS(null, 'height', this.canvasContext.canvas.height.toString());
812
+ img.setAttributeNS(null, 'width', this.canvasContext.canvas.width.toString());
813
+ img.setAttributeNS(XLinkNS, 'xlink:href', dataUrl);
814
+ svg.appendChild(img);
815
+ var prefix = 'data:image/svg+xml;base64,';
816
+ var header = '<svg' + ' xmlns="http://www.w3.org/2000/svg"' + ' xmlns:xlink="http://www.w3.org/1999/xlink"'
817
+ + (" width=\"" + this.canvasContext.canvas.width + "\"") + (" height=\"" + this.canvasContext.canvas.height + "\"") + '>';
818
+ var footer = '</svg>';
819
+ var body = svg.innerHTML;
820
+ var data = header + body + footer;
821
+ var svgDataUrl = prefix + btoa(data);
822
+ if (fileName == null) {
823
+ return svgDataUrl;
824
+ }
825
+ else {
826
+ this.download(this.getBlob(svgDataUrl), fileName + '.' + 'svg');
827
+ return null;
828
+ }
829
+ };
830
+ /**
831
+ * To save the signature as Blob.
832
+ *
833
+ * @returns {Blob}.
834
+ */
835
+ SignatureBase.prototype.saveAsBlob = function () {
836
+ return this.getBlob(this.canvasContext.canvas.toDataURL('image/png'));
837
+ };
838
+ /**
839
+ * To get the signature as Base 64.
840
+ *
841
+ * @private
842
+ * @param {SignatureFileType} type - Specifies the type of the image format.
843
+ * @returns {string}.
844
+ */
845
+ SignatureBase.prototype.getSignature = function (type) {
846
+ if (type === 'Jpeg') {
847
+ var imgData = this.canvasContext.getImageData(0, 0, this.element.width, this.element.height);
848
+ var data = imgData.data;
849
+ for (var i = 0; i < data.length; i += 4) {
850
+ if (data[i + 3] < 255) {
851
+ data[i] = 255 - data[i];
852
+ data[i + 1] = 255 - data[i + 1];
853
+ data[i + 2] = 255 - data[i + 2];
854
+ data[i + 3] = 255 - data[i + 3];
855
+ }
856
+ }
857
+ this.canvasContext.putImageData(imgData, 0, 0);
858
+ var dataURL = this.canvasContext.canvas.toDataURL('image/jpeg');
859
+ this.resizeHandler();
860
+ return dataURL;
861
+ }
862
+ else if (type === 'Svg') {
863
+ return this.toSVG(null);
864
+ }
865
+ else {
866
+ return this.canvasContext.canvas.toDataURL('image/png');
867
+ }
868
+ };
869
+ /**
870
+ * Get component name.
871
+ *
872
+ * @returns {string} - Module Name
873
+ * @private
874
+ */
875
+ SignatureBase.prototype.getModuleName = function () {
876
+ return 'signature';
877
+ };
878
+ /**
879
+ * To get the properties to be maintained in the persisted state.
880
+ *
881
+ * @returns {string} - Persist data
882
+ */
883
+ SignatureBase.prototype.getPersistData = function () {
884
+ this.signatureValue = this.snapColl[this.incStep];
885
+ return this.addOnPersist(['signatureValue']);
886
+ };
887
+ /**
888
+ * Removes the component from the DOM and detaches all its related event handlers.
889
+ * Also it maintains the initial input element from the DOM.
890
+ *
891
+ * @method destroy
892
+ * @returns {void}
893
+ */
894
+ SignatureBase.prototype.destroy = function () {
895
+ this.unwireEvents(null);
896
+ removeClass([this.element], 'e-' + this.getModuleName());
897
+ this.element.removeAttribute('tabindex');
898
+ this.pointColl = null;
899
+ _super.prototype.destroy.call(this);
900
+ };
901
+ /**
902
+ * Modified onPropertyChanged method for both blazor and EJ2 signature component.
903
+ *
904
+ * @private
905
+ * @param {string} key - Specifies the property, which changed.
906
+ * @param {string} value - Specifies the property value changed.
907
+ * @returns {void}
908
+ */
909
+ SignatureBase.prototype.propertyChanged = function (key, value) {
910
+ var canvasNew = this.canvasContext;
911
+ switch (key) {
912
+ case 'backgroundColor':
913
+ canvasNew.canvas.style.backgroundColor = value;
914
+ this.backgroundColor = value;
915
+ break;
916
+ case 'backgroundImage':
917
+ canvasNew.canvas.style.backgroundImage = 'url(' + value + ')';
918
+ this.backgroundImage = value;
919
+ break;
920
+ case 'strokeColor':
921
+ canvasNew.fillStyle = value;
922
+ this.strokeColor = value;
923
+ break;
924
+ case 'saveWithBackground':
925
+ this.saveWithBackground = value;
926
+ break;
927
+ case 'maxStrokeWidth':
928
+ this.maxStrokeWidth = value;
929
+ break;
930
+ case 'minStrokeWidth':
931
+ this.minStrokeWidth = value;
932
+ break;
933
+ case 'velocity':
934
+ this.velocity = value;
935
+ break;
936
+ case 'isReadOnly':
937
+ this.isRead(value);
938
+ break;
939
+ case 'disabled':
940
+ this.enableOrDisable(value);
941
+ break;
942
+ }
943
+ };
944
+ return SignatureBase;
945
+ }(Component));
946
+ export { SignatureBase };