@kdcloudjs/kdesign 1.7.59 → 1.7.61

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 (105) hide show
  1. package/CHANGELOG.md +21 -8
  2. package/dist/kdesign-complete.less +131 -3
  3. package/dist/kdesign.css +223 -5
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +2313 -258
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +16 -12
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/domUtil.d.ts +2 -0
  11. package/es/_utils/domUtil.js +15 -0
  12. package/es/cascader/cascader.js +41 -10
  13. package/es/city-picker/style/index.css +7 -0
  14. package/es/city-picker/style/index.less +3 -0
  15. package/es/config-provider/compDefaultProps.d.ts +7 -0
  16. package/es/config-provider/compDefaultProps.js +7 -0
  17. package/es/date-picker/date-panel.js +2 -2
  18. package/es/date-picker/date-picker.d.ts +2 -1
  19. package/es/date-picker/date-picker.js +44 -18
  20. package/es/date-picker/hooks/use-range-view-dates.js +8 -2
  21. package/es/date-picker/interface.d.ts +6 -2
  22. package/es/date-picker/locale/zh_CN.js +1 -22
  23. package/es/date-picker/panel/month/month.js +1 -3
  24. package/es/date-picker/range-picker.js +7 -3
  25. package/es/index.d.ts +1 -0
  26. package/es/index.js +2 -1
  27. package/es/locale/locale.d.ts +7 -1
  28. package/es/locale/zh-CN.d.ts +7 -1
  29. package/es/locale/zh-CN.js +6 -1
  30. package/es/modal/modal.js +3 -1
  31. package/es/popconfirm/popconfirm.js +1 -1
  32. package/es/select/select.js +1 -1
  33. package/es/select/style/index.css +4 -4
  34. package/es/select/style/token.less +2 -2
  35. package/es/signature/drawingBoard.d.ts +15 -0
  36. package/es/signature/drawingBoard.js +163 -0
  37. package/es/signature/index.d.ts +3 -0
  38. package/es/signature/index.js +3 -0
  39. package/es/signature/signature.d.ts +32 -0
  40. package/es/signature/signature.js +268 -0
  41. package/es/signature/style/css.js +2 -0
  42. package/es/signature/style/index.css +210 -0
  43. package/es/signature/style/index.d.ts +2 -0
  44. package/es/signature/style/index.js +2 -0
  45. package/es/signature/style/index.less +95 -0
  46. package/es/signature/style/mixin.less +6 -0
  47. package/es/signature/style/token.less +22 -0
  48. package/es/signature/utils/signature_pad.d.ts +106 -0
  49. package/es/signature/utils/signature_pad.js +690 -0
  50. package/es/style/themes/default.less +1 -1
  51. package/lib/_utils/domUtil.d.ts +2 -0
  52. package/lib/_utils/domUtil.js +23 -0
  53. package/lib/cascader/cascader.js +41 -10
  54. package/lib/city-picker/style/index.css +7 -0
  55. package/lib/city-picker/style/index.less +3 -0
  56. package/lib/config-provider/compDefaultProps.d.ts +7 -0
  57. package/lib/config-provider/compDefaultProps.js +7 -0
  58. package/lib/date-picker/date-panel.js +2 -2
  59. package/lib/date-picker/date-picker.d.ts +2 -1
  60. package/lib/date-picker/date-picker.js +47 -20
  61. package/lib/date-picker/hooks/use-range-view-dates.js +7 -1
  62. package/lib/date-picker/interface.d.ts +6 -2
  63. package/lib/date-picker/locale/zh_CN.js +1 -22
  64. package/lib/date-picker/panel/month/month.js +3 -5
  65. package/lib/date-picker/range-picker.js +7 -3
  66. package/lib/index.d.ts +1 -0
  67. package/lib/index.js +7 -0
  68. package/lib/locale/locale.d.ts +7 -1
  69. package/lib/locale/zh-CN.d.ts +7 -1
  70. package/lib/locale/zh-CN.js +6 -1
  71. package/lib/modal/modal.js +3 -1
  72. package/lib/popconfirm/popconfirm.js +1 -1
  73. package/lib/select/select.js +1 -1
  74. package/lib/select/style/index.css +4 -4
  75. package/lib/select/style/token.less +2 -2
  76. package/lib/signature/drawingBoard.d.ts +15 -0
  77. package/lib/signature/drawingBoard.js +176 -0
  78. package/lib/signature/index.d.ts +3 -0
  79. package/lib/signature/index.js +27 -0
  80. package/lib/signature/signature.d.ts +32 -0
  81. package/lib/signature/signature.js +282 -0
  82. package/lib/signature/style/css.js +4 -0
  83. package/lib/signature/style/index.css +210 -0
  84. package/lib/signature/style/index.d.ts +2 -0
  85. package/lib/signature/style/index.js +4 -0
  86. package/lib/signature/style/index.less +95 -0
  87. package/lib/signature/style/mixin.less +6 -0
  88. package/lib/signature/style/token.less +22 -0
  89. package/lib/signature/utils/signature_pad.d.ts +106 -0
  90. package/lib/signature/utils/signature_pad.js +697 -0
  91. package/lib/style/components.less +1 -0
  92. package/lib/style/themes/default.less +1 -1
  93. package/package.json +3 -2
  94. package/es/date-picker/locale/en_GB.d.ts +0 -1
  95. package/es/date-picker/locale/en_GB.js +0 -33
  96. package/es/date-picker/locale/en_US.d.ts +0 -1
  97. package/es/date-picker/locale/en_US.js +0 -33
  98. package/es/date-picker/locale/zh_TW.d.ts +0 -1
  99. package/es/date-picker/locale/zh_TW.js +0 -33
  100. package/lib/date-picker/locale/en_GB.d.ts +0 -1
  101. package/lib/date-picker/locale/en_GB.js +0 -33
  102. package/lib/date-picker/locale/en_US.d.ts +0 -1
  103. package/lib/date-picker/locale/en_US.js +0 -33
  104. package/lib/date-picker/locale/zh_TW.d.ts +0 -1
  105. package/lib/date-picker/locale/zh_TW.js +0 -33
@@ -0,0 +1,690 @@
1
+ import _Reflect$construct from "@babel/runtime-corejs3/core-js-stable/reflect/construct";
2
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
3
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
4
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
5
+ import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
6
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
7
+ import _typeof from "@babel/runtime-corejs3/helpers/typeof";
8
+ import _inherits from "@babel/runtime-corejs3/helpers/inherits";
9
+ import _possibleConstructorReturn from "@babel/runtime-corejs3/helpers/possibleConstructorReturn";
10
+ import _getPrototypeOf from "@babel/runtime-corejs3/helpers/getPrototypeOf";
11
+ import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
12
+ import _createClass from "@babel/runtime-corejs3/helpers/createClass";
13
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
+ function _unsupportedIterableToArray(o, minLen) { var _context9; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context9 = Object.prototype.toString.call(o)).call(_context9, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
19
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
20
+ import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
21
+ /*!
22
+ * Signature Pad v4.1.7 | https://github.com/szimek/signature_pad
23
+ * (c) 2023 Szymon Nowak | Released under the MIT license
24
+ */
25
+ var Point = /*#__PURE__*/function () {
26
+ function Point(x, y, pressure, time) {
27
+ _classCallCheck(this, Point);
28
+ if (isNaN(x) || isNaN(y)) {
29
+ var _context;
30
+ throw new Error(_concatInstanceProperty(_context = "Point is invalid: (".concat(x, ", ")).call(_context, y, ")"));
31
+ }
32
+ this.x = +x;
33
+ this.y = +y;
34
+ this.pressure = pressure || 0;
35
+ this.time = time || Date.now();
36
+ }
37
+ _createClass(Point, [{
38
+ key: "distanceTo",
39
+ value: function distanceTo(start) {
40
+ return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
41
+ }
42
+ }, {
43
+ key: "equals",
44
+ value: function equals(other) {
45
+ return this.x === other.x && this.y === other.y && this.pressure === other.pressure && this.time === other.time;
46
+ }
47
+ }, {
48
+ key: "velocityFrom",
49
+ value: function velocityFrom(start) {
50
+ return this.time !== start.time ? this.distanceTo(start) / (this.time - start.time) : 0;
51
+ }
52
+ }]);
53
+ return Point;
54
+ }();
55
+ var Bezier = /*#__PURE__*/function () {
56
+ function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
57
+ _classCallCheck(this, Bezier);
58
+ this.startPoint = startPoint;
59
+ this.control2 = control2;
60
+ this.control1 = control1;
61
+ this.endPoint = endPoint;
62
+ this.startWidth = startWidth;
63
+ this.endWidth = endWidth;
64
+ }
65
+ _createClass(Bezier, [{
66
+ key: "length",
67
+ value: function length() {
68
+ var steps = 10;
69
+ var length = 0;
70
+ var px;
71
+ var py;
72
+ for (var i = 0; i <= steps; i += 1) {
73
+ var t = i / steps;
74
+ var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
75
+ var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
76
+ if (i > 0) {
77
+ var xdiff = cx - px;
78
+ var ydiff = cy - py;
79
+ length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
80
+ }
81
+ px = cx;
82
+ py = cy;
83
+ }
84
+ return length;
85
+ }
86
+ }, {
87
+ key: "point",
88
+ value: function point(t, start, c1, c2, end) {
89
+ return start * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * c1 * (1.0 - t) * (1.0 - t) * t + 3.0 * c2 * (1.0 - t) * t * t + end * t * t * t;
90
+ }
91
+ }], [{
92
+ key: "fromPoints",
93
+ value: function fromPoints(points, widths) {
94
+ var c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
95
+ var c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
96
+ return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
97
+ }
98
+ }, {
99
+ key: "calculateControlPoints",
100
+ value: function calculateControlPoints(s1, s2, s3) {
101
+ var dx1 = s1.x - s2.x;
102
+ var dy1 = s1.y - s2.y;
103
+ var dx2 = s2.x - s3.x;
104
+ var dy2 = s2.y - s3.y;
105
+ var m1 = {
106
+ x: (s1.x + s2.x) / 2.0,
107
+ y: (s1.y + s2.y) / 2.0
108
+ };
109
+ var m2 = {
110
+ x: (s2.x + s3.x) / 2.0,
111
+ y: (s2.y + s3.y) / 2.0
112
+ };
113
+ var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
114
+ var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
115
+ var dxm = m1.x - m2.x;
116
+ var dym = m1.y - m2.y;
117
+ var k = l2 / (l1 + l2);
118
+ var cm = {
119
+ x: m2.x + dxm * k,
120
+ y: m2.y + dym * k
121
+ };
122
+ var tx = s2.x - cm.x;
123
+ var ty = s2.y - cm.y;
124
+ return {
125
+ c1: new Point(m1.x + tx, m1.y + ty),
126
+ c2: new Point(m2.x + tx, m2.y + ty)
127
+ };
128
+ }
129
+ }]);
130
+ return Bezier;
131
+ }();
132
+ var SignatureEventTarget = /*#__PURE__*/function () {
133
+ function SignatureEventTarget() {
134
+ _classCallCheck(this, SignatureEventTarget);
135
+ try {
136
+ this._et = new EventTarget();
137
+ } catch (error) {
138
+ this._et = document;
139
+ }
140
+ }
141
+ _createClass(SignatureEventTarget, [{
142
+ key: "addEventListener",
143
+ value: function addEventListener(type, listener) {
144
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
145
+ this._et.addEventListener(type, listener, options);
146
+ }
147
+ }, {
148
+ key: "dispatchEvent",
149
+ value: function dispatchEvent(event) {
150
+ return this._et.dispatchEvent(event);
151
+ }
152
+ }, {
153
+ key: "removeEventListener",
154
+ value: function removeEventListener(type, callback) {
155
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
156
+ this._et.removeEventListener(type, callback, options);
157
+ }
158
+ }]);
159
+ return SignatureEventTarget;
160
+ }();
161
+ function throttle(fn) {
162
+ var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
163
+ var previous = 0;
164
+ var timeout = null;
165
+ var result;
166
+ var storedContext;
167
+ var storedArgs;
168
+ var later = function later() {
169
+ previous = Date.now();
170
+ timeout = null;
171
+ result = fn.apply(storedContext, storedArgs);
172
+ if (!timeout) {
173
+ storedContext = null;
174
+ storedArgs = [];
175
+ }
176
+ };
177
+ return function wrapper() {
178
+ var now = Date.now();
179
+ var remaining = wait - (now - previous);
180
+ storedContext = this;
181
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
182
+ args[_key] = arguments[_key];
183
+ }
184
+ storedArgs = args;
185
+ if (remaining <= 0 || remaining > wait) {
186
+ if (timeout) {
187
+ clearTimeout(timeout);
188
+ timeout = null;
189
+ }
190
+ previous = now;
191
+ result = fn.apply(storedContext, storedArgs);
192
+ if (!timeout) {
193
+ storedContext = null;
194
+ storedArgs = [];
195
+ }
196
+ } else if (!timeout) {
197
+ timeout = window.setTimeout(later, remaining);
198
+ }
199
+ return result;
200
+ };
201
+ }
202
+ var SignaturePad = /*#__PURE__*/function (_SignatureEventTarget) {
203
+ _inherits(SignaturePad, _SignatureEventTarget);
204
+ var _super = _createSuper(SignaturePad);
205
+ function SignaturePad(canvas) {
206
+ var _this;
207
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
208
+ _classCallCheck(this, SignaturePad);
209
+ _this = _super.call(this);
210
+ _this.canvas = canvas;
211
+ _this._drawingStroke = false;
212
+ _this._isEmpty = true;
213
+ _this._lastPoints = [];
214
+ _this._data = [];
215
+ _this._lastVelocity = 0;
216
+ _this._lastWidth = 0;
217
+ _this._handleMouseDown = function (event) {
218
+ if (event.buttons === 1) {
219
+ _this._strokeBegin(event);
220
+ }
221
+ };
222
+ _this._handleMouseMove = function (event) {
223
+ _this._strokeMoveUpdate(event);
224
+ };
225
+ _this._handleMouseUp = function (event) {
226
+ if (event.buttons === 1) {
227
+ _this._strokeEnd(event);
228
+ }
229
+ };
230
+ _this._handleTouchStart = function (event) {
231
+ if (event.cancelable) {
232
+ event.preventDefault();
233
+ }
234
+ if (event.targetTouches.length === 1) {
235
+ var touch = event.changedTouches[0];
236
+ _this._strokeBegin(touch);
237
+ }
238
+ };
239
+ _this._handleTouchMove = function (event) {
240
+ if (event.cancelable) {
241
+ event.preventDefault();
242
+ }
243
+ var touch = event.targetTouches[0];
244
+ _this._strokeMoveUpdate(touch);
245
+ };
246
+ _this._handleTouchEnd = function (event) {
247
+ var wasCanvasTouched = event.target === _this.canvas;
248
+ if (wasCanvasTouched) {
249
+ if (event.cancelable) {
250
+ event.preventDefault();
251
+ }
252
+ var touch = event.changedTouches[0];
253
+ _this._strokeEnd(touch);
254
+ }
255
+ };
256
+ _this._handlePointerStart = function (event) {
257
+ event.preventDefault();
258
+ _this._strokeBegin(event);
259
+ };
260
+ _this._handlePointerMove = function (event) {
261
+ _this._strokeMoveUpdate(event);
262
+ };
263
+ _this._handlePointerEnd = function (event) {
264
+ if (_this._drawingStroke) {
265
+ event.preventDefault();
266
+ _this._strokeEnd(event);
267
+ }
268
+ };
269
+ _this.velocityFilterWeight = options.velocityFilterWeight || 0.7;
270
+ _this.minWidth = options.minWidth || 0.5;
271
+ _this.maxWidth = options.maxWidth || 2.5;
272
+ _this.throttle = 'throttle' in options ? options.throttle : 16;
273
+ _this.minDistance = 'minDistance' in options ? options.minDistance : 5;
274
+ _this.dotSize = options.dotSize || 0;
275
+ _this.penColor = options.penColor || 'black';
276
+ _this.backgroundColor = options.backgroundColor || 'rgba(0,0,0,0)';
277
+ _this.compositeOperation = options.compositeOperation || 'source-over';
278
+ _this._strokeMoveUpdate = _this.throttle ? throttle(SignaturePad.prototype._strokeUpdate, _this.throttle) : SignaturePad.prototype._strokeUpdate;
279
+ _this._ctx = canvas.getContext('2d');
280
+ _this.clear();
281
+ _this.on();
282
+ return _this;
283
+ }
284
+ _createClass(SignaturePad, [{
285
+ key: "clear",
286
+ value: function clear() {
287
+ var ctx = this._ctx,
288
+ canvas = this.canvas;
289
+ ctx.fillStyle = this.backgroundColor;
290
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
291
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
292
+ this._data = [];
293
+ this._reset(this._getPointGroupOptions());
294
+ this._isEmpty = true;
295
+ }
296
+ }, {
297
+ key: "fromDataURL",
298
+ value: function fromDataURL(dataUrl) {
299
+ var _this2 = this;
300
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
301
+ return new _Promise(function (resolve, reject) {
302
+ var image = new Image();
303
+ var ratio = options.ratio || window.devicePixelRatio || 1;
304
+ var width = options.width || _this2.canvas.width / ratio;
305
+ var height = options.height || _this2.canvas.height / ratio;
306
+ var xOffset = options.xOffset || 0;
307
+ var yOffset = options.yOffset || 0;
308
+ _this2._reset(_this2._getPointGroupOptions());
309
+ image.onload = function () {
310
+ _this2._ctx.drawImage(image, xOffset, yOffset, width, height);
311
+ resolve();
312
+ };
313
+ image.onerror = function (error) {
314
+ reject(error);
315
+ };
316
+ image.crossOrigin = 'anonymous';
317
+ image.src = dataUrl;
318
+ _this2._isEmpty = false;
319
+ });
320
+ }
321
+ }, {
322
+ key: "toDataURL",
323
+ value: function toDataURL() {
324
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
325
+ var encoderOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
326
+ switch (type) {
327
+ case 'image/svg+xml':
328
+ if (_typeof(encoderOptions) !== 'object') {
329
+ encoderOptions = undefined;
330
+ }
331
+ return "data:image/svg+xml;base64,".concat(btoa(this.toSVG(encoderOptions)));
332
+ default:
333
+ if (typeof encoderOptions !== 'number') {
334
+ encoderOptions = undefined;
335
+ }
336
+ return this.canvas.toDataURL(type, encoderOptions);
337
+ }
338
+ }
339
+ }, {
340
+ key: "on",
341
+ value: function on() {
342
+ this.canvas.style.touchAction = 'none';
343
+ this.canvas.style.msTouchAction = 'none';
344
+ this.canvas.style.userSelect = 'none';
345
+ var isIOS = /Macintosh/.test(navigator.userAgent) && 'ontouchstart' in document;
346
+ if (window.PointerEvent && !isIOS) {
347
+ this._handlePointerEvents();
348
+ } else {
349
+ this._handleMouseEvents();
350
+ if ('ontouchstart' in window) {
351
+ this._handleTouchEvents();
352
+ }
353
+ }
354
+ }
355
+ }, {
356
+ key: "off",
357
+ value: function off() {
358
+ this.canvas.style.touchAction = 'auto';
359
+ this.canvas.style.msTouchAction = 'auto';
360
+ this.canvas.style.userSelect = 'auto';
361
+ this.canvas.removeEventListener('pointerdown', this._handlePointerStart);
362
+ this.canvas.removeEventListener('pointermove', this._handlePointerMove);
363
+ this.canvas.ownerDocument.removeEventListener('pointerup', this._handlePointerEnd);
364
+ this.canvas.removeEventListener('mousedown', this._handleMouseDown);
365
+ this.canvas.removeEventListener('mousemove', this._handleMouseMove);
366
+ this.canvas.ownerDocument.removeEventListener('mouseup', this._handleMouseUp);
367
+ this.canvas.removeEventListener('touchstart', this._handleTouchStart);
368
+ this.canvas.removeEventListener('touchmove', this._handleTouchMove);
369
+ this.canvas.removeEventListener('touchend', this._handleTouchEnd);
370
+ }
371
+ }, {
372
+ key: "isEmpty",
373
+ value: function isEmpty() {
374
+ return this._isEmpty;
375
+ }
376
+ }, {
377
+ key: "fromData",
378
+ value: function fromData(pointGroups) {
379
+ var _context2;
380
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
381
+ _ref$clear = _ref.clear,
382
+ clear = _ref$clear === void 0 ? true : _ref$clear;
383
+ if (clear) {
384
+ this.clear();
385
+ }
386
+ this._fromData(pointGroups, this._drawCurve.bind(this), this._drawDot.bind(this));
387
+ this._data = _concatInstanceProperty(_context2 = this._data).call(_context2, pointGroups);
388
+ }
389
+ }, {
390
+ key: "toData",
391
+ value: function toData() {
392
+ return this._data;
393
+ }
394
+ }, {
395
+ key: "_getPointGroupOptions",
396
+ value: function _getPointGroupOptions(group) {
397
+ return {
398
+ penColor: group && 'penColor' in group ? group.penColor : this.penColor,
399
+ dotSize: group && 'dotSize' in group ? group.dotSize : this.dotSize,
400
+ minWidth: group && 'minWidth' in group ? group.minWidth : this.minWidth,
401
+ maxWidth: group && 'maxWidth' in group ? group.maxWidth : this.maxWidth,
402
+ velocityFilterWeight: group && 'velocityFilterWeight' in group ? group.velocityFilterWeight : this.velocityFilterWeight,
403
+ compositeOperation: group && 'compositeOperation' in group ? group.compositeOperation : this.compositeOperation
404
+ };
405
+ }
406
+ }, {
407
+ key: "_strokeBegin",
408
+ value: function _strokeBegin(event) {
409
+ // const cancelled = !this.dispatchEvent(new CustomEvent('beginStroke', { detail: event, cancelable: true }));
410
+ var customEvent = document.createEvent('CustomEvent');
411
+ customEvent.initCustomEvent('beginStroke', true, true, event);
412
+ var cancelled = !this.dispatchEvent(customEvent);
413
+ if (cancelled) {
414
+ return;
415
+ }
416
+ this._drawingStroke = true;
417
+ var pointGroupOptions = this._getPointGroupOptions();
418
+ var newPointGroup = _extends(_extends({}, pointGroupOptions), {
419
+ points: []
420
+ });
421
+ this._data.push(newPointGroup);
422
+ this._reset(pointGroupOptions);
423
+ this._strokeUpdate(event);
424
+ }
425
+ }, {
426
+ key: "_strokeUpdate",
427
+ value: function _strokeUpdate(event) {
428
+ if (!this._drawingStroke) {
429
+ return;
430
+ }
431
+ if (this._data.length === 0) {
432
+ this._strokeBegin(event);
433
+ return;
434
+ }
435
+ // this.dispatchEvent(new CustomEvent('beforeUpdateStroke', { detail: event }));
436
+ var customEvent_one = document.createEvent('CustomEvent');
437
+ customEvent_one.initCustomEvent('beforeUpdateStroke', true, true, event);
438
+ this.dispatchEvent(customEvent_one);
439
+ var x = event.clientX;
440
+ var y = event.clientY;
441
+ var pressure = event.pressure !== undefined ? event.pressure : event.force !== undefined ? event.force : 0;
442
+ var point = this._createPoint(x, y, pressure);
443
+ var lastPointGroup = this._data[this._data.length - 1];
444
+ var lastPoints = lastPointGroup.points;
445
+ var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
446
+ var isLastPointTooClose = lastPoint ? point.distanceTo(lastPoint) <= this.minDistance : false;
447
+ var pointGroupOptions = this._getPointGroupOptions(lastPointGroup);
448
+ if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
449
+ var curve = this._addPoint(point, pointGroupOptions);
450
+ if (!lastPoint) {
451
+ this._drawDot(point, pointGroupOptions);
452
+ } else if (curve) {
453
+ this._drawCurve(curve, pointGroupOptions);
454
+ }
455
+ lastPoints.push({
456
+ time: point.time,
457
+ x: point.x,
458
+ y: point.y,
459
+ pressure: point.pressure
460
+ });
461
+ }
462
+ // this.dispatchEvent(new CustomEvent('afterUpdateStroke', { detail: event }));
463
+ var customEvent_two = document.createEvent('CustomEvent');
464
+ customEvent_two.initCustomEvent('afterUpdateStroke', true, true, event);
465
+ this.dispatchEvent(customEvent_two);
466
+ }
467
+ }, {
468
+ key: "_strokeEnd",
469
+ value: function _strokeEnd(event) {
470
+ if (!this._drawingStroke) {
471
+ return;
472
+ }
473
+ this._strokeUpdate(event);
474
+ this._drawingStroke = false;
475
+ // this.dispatchEvent(new CustomEvent('endStroke', { detail: event }));
476
+ var customEvent = document.createEvent('CustomEvent');
477
+ customEvent.initCustomEvent('endStroke', true, true, event);
478
+ this.dispatchEvent(customEvent);
479
+ }
480
+ }, {
481
+ key: "_handlePointerEvents",
482
+ value: function _handlePointerEvents() {
483
+ this._drawingStroke = false;
484
+ this.canvas.addEventListener('pointerdown', this._handlePointerStart);
485
+ this.canvas.addEventListener('pointermove', this._handlePointerMove);
486
+ this.canvas.ownerDocument.addEventListener('pointerup', this._handlePointerEnd);
487
+ }
488
+ }, {
489
+ key: "_handleMouseEvents",
490
+ value: function _handleMouseEvents() {
491
+ this._drawingStroke = false;
492
+ this.canvas.addEventListener('mousedown', this._handleMouseDown);
493
+ this.canvas.addEventListener('mousemove', this._handleMouseMove);
494
+ this.canvas.ownerDocument.addEventListener('mouseup', this._handleMouseUp);
495
+ }
496
+ }, {
497
+ key: "_handleTouchEvents",
498
+ value: function _handleTouchEvents() {
499
+ this.canvas.addEventListener('touchstart', this._handleTouchStart);
500
+ this.canvas.addEventListener('touchmove', this._handleTouchMove);
501
+ this.canvas.addEventListener('touchend', this._handleTouchEnd);
502
+ }
503
+ }, {
504
+ key: "_reset",
505
+ value: function _reset(options) {
506
+ this._lastPoints = [];
507
+ this._lastVelocity = 0;
508
+ this._lastWidth = (options.minWidth + options.maxWidth) / 2;
509
+ this._ctx.fillStyle = options.penColor;
510
+ this._ctx.globalCompositeOperation = options.compositeOperation;
511
+ }
512
+ }, {
513
+ key: "_createPoint",
514
+ value: function _createPoint(x, y, pressure) {
515
+ var rect = this.canvas.getBoundingClientRect();
516
+ return new Point(x - rect.left, y - rect.top, pressure, new Date().getTime());
517
+ }
518
+ }, {
519
+ key: "_addPoint",
520
+ value: function _addPoint(point, options) {
521
+ var _lastPoints = this._lastPoints;
522
+ _lastPoints.push(point);
523
+ if (_lastPoints.length > 2) {
524
+ if (_lastPoints.length === 3) {
525
+ _lastPoints.unshift(_lastPoints[0]);
526
+ }
527
+ var widths = this._calculateCurveWidths(_lastPoints[1], _lastPoints[2], options);
528
+ var curve = Bezier.fromPoints(_lastPoints, widths);
529
+ _lastPoints.shift();
530
+ return curve;
531
+ }
532
+ return null;
533
+ }
534
+ }, {
535
+ key: "_calculateCurveWidths",
536
+ value: function _calculateCurveWidths(startPoint, endPoint, options) {
537
+ var velocity = options.velocityFilterWeight * endPoint.velocityFrom(startPoint) + (1 - options.velocityFilterWeight) * this._lastVelocity;
538
+ var newWidth = this._strokeWidth(velocity, options);
539
+ var widths = {
540
+ end: newWidth,
541
+ start: this._lastWidth
542
+ };
543
+ this._lastVelocity = velocity;
544
+ this._lastWidth = newWidth;
545
+ return widths;
546
+ }
547
+ }, {
548
+ key: "_strokeWidth",
549
+ value: function _strokeWidth(velocity, options) {
550
+ return Math.max(options.maxWidth / (velocity + 1), options.minWidth);
551
+ }
552
+ }, {
553
+ key: "_drawCurveSegment",
554
+ value: function _drawCurveSegment(x, y, width) {
555
+ var ctx = this._ctx;
556
+ ctx.moveTo(x, y);
557
+ ctx.arc(x, y, width, 0, 2 * Math.PI, false);
558
+ this._isEmpty = false;
559
+ }
560
+ }, {
561
+ key: "_drawCurve",
562
+ value: function _drawCurve(curve, options) {
563
+ var ctx = this._ctx;
564
+ var widthDelta = curve.endWidth - curve.startWidth;
565
+ var drawSteps = Math.ceil(curve.length()) * 2;
566
+ ctx.beginPath();
567
+ ctx.fillStyle = options.penColor;
568
+ for (var i = 0; i < drawSteps; i += 1) {
569
+ var t = i / drawSteps;
570
+ var tt = t * t;
571
+ var ttt = tt * t;
572
+ var u = 1 - t;
573
+ var uu = u * u;
574
+ var uuu = uu * u;
575
+ var x = uuu * curve.startPoint.x;
576
+ x += 3 * uu * t * curve.control1.x;
577
+ x += 3 * u * tt * curve.control2.x;
578
+ x += ttt * curve.endPoint.x;
579
+ var y = uuu * curve.startPoint.y;
580
+ y += 3 * uu * t * curve.control1.y;
581
+ y += 3 * u * tt * curve.control2.y;
582
+ y += ttt * curve.endPoint.y;
583
+ var width = Math.min(curve.startWidth + ttt * widthDelta, options.maxWidth);
584
+ this._drawCurveSegment(x, y, width);
585
+ }
586
+ ctx.closePath();
587
+ _fillInstanceProperty(ctx).call(ctx);
588
+ }
589
+ }, {
590
+ key: "_drawDot",
591
+ value: function _drawDot(point, options) {
592
+ var ctx = this._ctx;
593
+ var width = options.dotSize > 0 ? options.dotSize : (options.minWidth + options.maxWidth) / 2;
594
+ ctx.beginPath();
595
+ this._drawCurveSegment(point.x, point.y, width);
596
+ ctx.closePath();
597
+ ctx.fillStyle = options.penColor;
598
+ _fillInstanceProperty(ctx).call(ctx);
599
+ }
600
+ }, {
601
+ key: "_fromData",
602
+ value: function _fromData(pointGroups, drawCurve, drawDot) {
603
+ var _iterator = _createForOfIteratorHelper(pointGroups),
604
+ _step;
605
+ try {
606
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
607
+ var group = _step.value;
608
+ var points = group.points;
609
+ var pointGroupOptions = this._getPointGroupOptions(group);
610
+ if (points.length > 1) {
611
+ for (var j = 0; j < points.length; j += 1) {
612
+ var basicPoint = points[j];
613
+ var point = new Point(basicPoint.x, basicPoint.y, basicPoint.pressure, basicPoint.time);
614
+ if (j === 0) {
615
+ this._reset(pointGroupOptions);
616
+ }
617
+ var curve = this._addPoint(point, pointGroupOptions);
618
+ if (curve) {
619
+ drawCurve(curve, pointGroupOptions);
620
+ }
621
+ }
622
+ } else {
623
+ this._reset(pointGroupOptions);
624
+ drawDot(points[0], pointGroupOptions);
625
+ }
626
+ }
627
+ } catch (err) {
628
+ _iterator.e(err);
629
+ } finally {
630
+ _iterator.f();
631
+ }
632
+ }
633
+ }, {
634
+ key: "toSVG",
635
+ value: function toSVG() {
636
+ var _context3, _context4;
637
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
638
+ _ref2$includeBackgrou = _ref2.includeBackgroundColor,
639
+ includeBackgroundColor = _ref2$includeBackgrou === void 0 ? false : _ref2$includeBackgrou;
640
+ var pointGroups = this._data;
641
+ var ratio = Math.max(window.devicePixelRatio || 1, 1);
642
+ var minX = 0;
643
+ var minY = 0;
644
+ var maxX = this.canvas.width / ratio;
645
+ var maxY = this.canvas.height / ratio;
646
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
647
+ svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
648
+ svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
649
+ svg.setAttribute('viewBox', _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(minX, " ").concat(minY, " ")).call(_context4, maxX, " ")).call(_context3, maxY));
650
+ svg.setAttribute('width', maxX.toString());
651
+ svg.setAttribute('height', maxY.toString());
652
+ if (includeBackgroundColor && this.backgroundColor) {
653
+ var rect = document.createElement('rect');
654
+ rect.setAttribute('width', '100%');
655
+ rect.setAttribute('height', '100%');
656
+ rect.setAttribute('fill', this.backgroundColor);
657
+ svg.appendChild(rect);
658
+ }
659
+ this._fromData(pointGroups, function (curve, _ref3) {
660
+ var penColor = _ref3.penColor;
661
+ var path = document.createElement('path');
662
+ if (!isNaN(curve.control1.x) && !isNaN(curve.control1.y) && !isNaN(curve.control2.x) && !isNaN(curve.control2.y)) {
663
+ var _context5, _context6, _context7, _context8;
664
+ var attr = _concatInstanceProperty(_context5 = "M ".concat(curve.startPoint.x.toFixed(3), ",")).call(_context5, curve.startPoint.y.toFixed(3), " ") + _concatInstanceProperty(_context6 = "C ".concat(curve.control1.x.toFixed(3), ",")).call(_context6, curve.control1.y.toFixed(3), " ") + _concatInstanceProperty(_context7 = "".concat(curve.control2.x.toFixed(3), ",")).call(_context7, curve.control2.y.toFixed(3), " ") + _concatInstanceProperty(_context8 = "".concat(curve.endPoint.x.toFixed(3), ",")).call(_context8, curve.endPoint.y.toFixed(3));
665
+ path.setAttribute('d', attr);
666
+ path.setAttribute('stroke-width', (curve.endWidth * 2.25).toFixed(3));
667
+ path.setAttribute('stroke', penColor);
668
+ path.setAttribute('fill', 'none');
669
+ path.setAttribute('stroke-linecap', 'round');
670
+ svg.appendChild(path);
671
+ }
672
+ }, function (point, _ref4) {
673
+ var penColor = _ref4.penColor,
674
+ dotSize = _ref4.dotSize,
675
+ minWidth = _ref4.minWidth,
676
+ maxWidth = _ref4.maxWidth;
677
+ var circle = document.createElement('circle');
678
+ var size = dotSize > 0 ? dotSize : (minWidth + maxWidth) / 2;
679
+ circle.setAttribute('r', size.toString());
680
+ circle.setAttribute('cx', point.x.toString());
681
+ circle.setAttribute('cy', point.y.toString());
682
+ circle.setAttribute('fill', penColor);
683
+ svg.appendChild(circle);
684
+ });
685
+ return svg.outerHTML;
686
+ }
687
+ }]);
688
+ return SignaturePad;
689
+ }(SignatureEventTarget);
690
+ export { SignaturePad as default };
@@ -706,4 +706,4 @@
706
706
  @advancedSelector-dropdown-options-height: 32px;
707
707
  @advancedSelector-hover-bg: @hover-color;
708
708
 
709
- /* ----------- AdvancedSelector ——————---- end */
709
+ /* ----------- AdvancedSelector ——————---- end */