@verbb/formie-vue 1.0.13 → 1.0.14
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.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/definition-form.d.ts +53 -41
- package/dist/definition-form.d.ts.map +1 -1
- package/dist/index.d.ts +53 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +403 -307
- package/dist/{signature_pad-D-mX46zR.js → signature_pad-dbpVgfTh.js} +32 -18
- package/package.json +3 -3
|
@@ -21,6 +21,12 @@ var e = class {
|
|
|
21
21
|
constructor(e, t, n, r, i, a) {
|
|
22
22
|
this.startPoint = e, this.control2 = t, this.control1 = n, this.endPoint = r, this.startWidth = i, this.endWidth = a;
|
|
23
23
|
}
|
|
24
|
+
startPoint;
|
|
25
|
+
control2;
|
|
26
|
+
control1;
|
|
27
|
+
endPoint;
|
|
28
|
+
startWidth;
|
|
29
|
+
endWidth;
|
|
24
30
|
static fromPoints(e, n) {
|
|
25
31
|
let r = this.calculateControlPoints(e[0], e[1], e[2]).c2, i = this.calculateControlPoints(e[1], e[2], e[3]).c1;
|
|
26
32
|
return new t(e[1], r, i, e[2], n.start, n.end);
|
|
@@ -88,6 +94,7 @@ var i = class i extends n {
|
|
|
88
94
|
constructor(e, t = {}) {
|
|
89
95
|
super(), this.canvas = e, this.velocityFilterWeight = t.velocityFilterWeight || .7, this.minWidth = t.minWidth || .5, this.maxWidth = t.maxWidth || 2.5, this.throttle = t.throttle ?? 16, this.minDistance = t.minDistance ?? 5, this.dotSize = t.dotSize || 0, this.penColor = t.penColor || "black", this.backgroundColor = t.backgroundColor || "rgba(0,0,0,0)", this.compositeOperation = t.compositeOperation || "source-over", this.canvasContextOptions = t.canvasContextOptions ?? {}, this._strokeMoveUpdate = this.throttle ? r(i.prototype._strokeUpdate, this.throttle) : i.prototype._strokeUpdate, this._handleMouseDown = this._handleMouseDown.bind(this), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this._handleTouchStart = this._handleTouchStart.bind(this), this._handleTouchMove = this._handleTouchMove.bind(this), this._handleTouchEnd = this._handleTouchEnd.bind(this), this._handlePointerDown = this._handlePointerDown.bind(this), this._handlePointerMove = this._handlePointerMove.bind(this), this._handlePointerUp = this._handlePointerUp.bind(this), this._handlePointerCancel = this._handlePointerCancel.bind(this), this._handleTouchCancel = this._handleTouchCancel.bind(this), this._ctx = e.getContext("2d", this.canvasContextOptions), this.clear(), this.on();
|
|
90
96
|
}
|
|
97
|
+
canvas;
|
|
91
98
|
dotSize;
|
|
92
99
|
minWidth;
|
|
93
100
|
maxWidth;
|
|
@@ -156,7 +163,7 @@ var i = class i extends n {
|
|
|
156
163
|
return this._isEmpty;
|
|
157
164
|
}
|
|
158
165
|
fromData(e, { clear: t = !0 } = {}) {
|
|
159
|
-
t && this.clear(), this._fromData(e, this._drawCurve.bind(this), this._drawDot.bind(this)), this._data = this._data.concat(e);
|
|
166
|
+
t && this.clear(), this._fromData(e, this._drawCurve.bind(this), this._drawDot.bind(this), this._drawLine.bind(this)), this._data = this._data.concat(e);
|
|
160
167
|
}
|
|
161
168
|
toData() {
|
|
162
169
|
return this._data;
|
|
@@ -184,7 +191,7 @@ var i = class i extends n {
|
|
|
184
191
|
};
|
|
185
192
|
}
|
|
186
193
|
_handleMouseDown(e) {
|
|
187
|
-
|
|
194
|
+
this._isLeftButtonPressed(e, !0) && !this._drawingStroke && this._strokeBegin(this._pointerEventToSignatureEvent(e));
|
|
188
195
|
}
|
|
189
196
|
_handleMouseMove(e) {
|
|
190
197
|
if (!this._isLeftButtonPressed(e, !0) || !this._drawingStroke) {
|
|
@@ -224,7 +231,7 @@ var i = class i extends n {
|
|
|
224
231
|
return this._strokePointerId === void 0 ? t : this._getPointerId(e) === this._strokePointerId;
|
|
225
232
|
}
|
|
226
233
|
_handlePointerDown(e) {
|
|
227
|
-
this._drawingStroke
|
|
234
|
+
!this._drawingStroke && this._isLeftButtonPressed(e) && this._allowPointerId(e, !0) && (this._strokePointerId = this._getPointerId(e), e.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(e)));
|
|
228
235
|
}
|
|
229
236
|
_handlePointerMove(e) {
|
|
230
237
|
if (this._allowPointerId(e)) {
|
|
@@ -236,7 +243,7 @@ var i = class i extends n {
|
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
_handlePointerUp(e) {
|
|
239
|
-
this._isLeftButtonPressed(e)
|
|
246
|
+
!this._isLeftButtonPressed(e) && this._allowPointerId(e) && (e.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(e)));
|
|
240
247
|
}
|
|
241
248
|
_getPointGroupOptions(e) {
|
|
242
249
|
return {
|
|
@@ -261,10 +268,7 @@ var i = class i extends n {
|
|
|
261
268
|
case "touchstart":
|
|
262
269
|
t("touchmove", this._handleTouchMove, { passive: !1 }), t("touchend", this._handleTouchEnd, { passive: !1 }), t("touchcancel", this._handleTouchCancel, { passive: !1 });
|
|
263
270
|
break;
|
|
264
|
-
case "pointerdown":
|
|
265
|
-
t("pointermove", this._handlePointerMove, { passive: !1 }), t("pointerup", this._handlePointerUp, { passive: !1 }), t("pointercancel", this._handlePointerCancel, { passive: !1 });
|
|
266
|
-
break;
|
|
267
|
-
default:
|
|
271
|
+
case "pointerdown": t("pointermove", this._handlePointerMove, { passive: !1 }), t("pointerup", this._handlePointerUp, { passive: !1 }), t("pointercancel", this._handlePointerCancel, { passive: !1 });
|
|
268
272
|
}
|
|
269
273
|
this._drawingStroke = !0;
|
|
270
274
|
let n = this._getPointGroupOptions(), r = {
|
|
@@ -347,20 +351,27 @@ var i = class i extends n {
|
|
|
347
351
|
}
|
|
348
352
|
n.closePath(), n.fill();
|
|
349
353
|
}
|
|
354
|
+
_getDotSize(e) {
|
|
355
|
+
return e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
|
|
356
|
+
}
|
|
350
357
|
_drawDot(e, t) {
|
|
351
|
-
let n = this._ctx, r =
|
|
358
|
+
let n = this._ctx, r = this._getDotSize(t);
|
|
352
359
|
n.beginPath(), this._drawCurveSegment(e.x, e.y, r), n.closePath(), n.fillStyle = t.penColor, n.fill();
|
|
353
360
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
361
|
+
_drawLine(e, t, n) {
|
|
362
|
+
let r = this._ctx;
|
|
363
|
+
r.save(), r.beginPath(), r.moveTo(e.x, e.y), r.lineTo(t.x, t.y), r.lineWidth = this._getDotSize(n) * 2, r.lineCap = "round", r.strokeStyle = n.penColor, r.stroke(), r.restore(), this._isEmpty = !1;
|
|
364
|
+
}
|
|
365
|
+
_fromData(t, n, r, i) {
|
|
366
|
+
for (let a of t) {
|
|
367
|
+
let { points: t } = a, o = this._getPointGroupOptions(a);
|
|
368
|
+
if (t.length > 2) for (let r = 0; r < t.length; r += 1) {
|
|
369
|
+
let i = t[r], a = new e(i.x, i.y, i.pressure, i.time);
|
|
370
|
+
r === 0 && this._reset(o);
|
|
371
|
+
let s = this._addPoint(a, o);
|
|
372
|
+
s && n(s, o);
|
|
362
373
|
}
|
|
363
|
-
else this._reset(
|
|
374
|
+
else t.length === 2 ? (this._reset(o), i(t[0], t[1], o)) : (this._reset(o), r(t[0], o));
|
|
364
375
|
}
|
|
365
376
|
}
|
|
366
377
|
toSVG({ includeBackgroundColor: e = !1, includeDataUrl: t = !1 } = {}) {
|
|
@@ -382,6 +393,9 @@ var i = class i extends n {
|
|
|
382
393
|
}, (e, { penColor: t, dotSize: n, minWidth: r, maxWidth: i }) => {
|
|
383
394
|
let a = document.createElement("circle"), s = n > 0 ? n : (r + i) / 2;
|
|
384
395
|
a.setAttribute("r", s.toString()), a.setAttribute("cx", e.x.toString()), a.setAttribute("cy", e.y.toString()), a.setAttribute("fill", t), o.appendChild(a);
|
|
396
|
+
}, (e, t, n) => {
|
|
397
|
+
let r = document.createElement("line");
|
|
398
|
+
r.setAttribute("x1", e.x.toString()), r.setAttribute("y1", e.y.toString()), r.setAttribute("x2", t.x.toString()), r.setAttribute("y2", t.y.toString()), r.setAttribute("stroke", n.penColor), r.setAttribute("stroke-width", (this._getDotSize(n) * 2).toString()), r.setAttribute("stroke-linecap", "round"), o.appendChild(r);
|
|
385
399
|
}), o.outerHTML;
|
|
386
400
|
}
|
|
387
401
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbb/formie-vue",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"vue": "^3.5.33"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@verbb/formie-browser": "1.0.
|
|
44
|
-
"@verbb/formie-core": "1.0.
|
|
43
|
+
"@verbb/formie-browser": "1.0.14",
|
|
44
|
+
"@verbb/formie-core": "1.0.14",
|
|
45
45
|
"signature_pad": "^5.1.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|