@smileid/web-components 11.4.0 → 11.4.2
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/dist/esm/DocumentCaptureScreens-zEVFc_Kr.js +4147 -0
- package/dist/esm/DocumentCaptureScreens-zEVFc_Kr.js.map +1 -0
- package/dist/esm/{EndUserConsent-BGO3oZ-m.js → EndUserConsent-BXvS7t8z.js} +4 -4
- package/dist/esm/{EndUserConsent-BGO3oZ-m.js.map → EndUserConsent-BXvS7t8z.js.map} +1 -1
- package/dist/esm/Navigation-BRFmg7s1.js +138 -0
- package/dist/esm/Navigation-BRFmg7s1.js.map +1 -0
- package/dist/esm/{SelfieCaptureScreens-bmwnmeS9.js → SelfieCaptureScreens-DsFp21uW.js} +2520 -2906
- package/dist/esm/SelfieCaptureScreens-DsFp21uW.js.map +1 -0
- package/dist/esm/{TotpConsent-V3_Ip2Kw.js → TotpConsent-Cn2DkVza.js} +2 -2
- package/dist/esm/{TotpConsent-V3_Ip2Kw.js.map → TotpConsent-Cn2DkVza.js.map} +1 -1
- package/dist/esm/combobox.js +14 -16
- package/dist/esm/combobox.js.map +1 -1
- package/dist/esm/document.js +1 -1
- package/dist/esm/end-user-consent.js +1 -1
- package/dist/esm/{index-Dnpp-kwk.js → index-DBUdxnp9.js} +57 -57
- package/dist/esm/{index-Dnpp-kwk.js.map → index-DBUdxnp9.js.map} +1 -1
- package/dist/esm/localisation.js +1 -1
- package/dist/esm/main.js +6 -6
- package/dist/esm/navigation.js +1 -1
- package/dist/esm/package-Do9oHVnx.js +565 -0
- package/dist/esm/package-Do9oHVnx.js.map +1 -0
- package/dist/esm/selfie.js +1 -1
- package/dist/esm/smart-camera-web.js +16 -11
- package/dist/esm/smart-camera-web.js.map +1 -1
- package/dist/esm/{styles-BOEZtbuc.js → styles-BTEClL7R.js} +2 -2
- package/dist/esm/{styles-BOEZtbuc.js.map → styles-BTEClL7R.js.map} +1 -1
- package/dist/esm/totp-consent.js +1 -1
- package/dist/smart-camera-web.js +445 -178
- package/dist/smart-camera-web.js.map +1 -1
- package/dist/types/main.d.ts +186 -33
- package/lib/components/combobox/src/Combobox.js +14 -12
- package/lib/components/document/src/DocumentCaptureScreens.js +15 -5
- package/lib/components/document/src/assets/icons/guidelines/greenbook/good.svg +77 -0
- package/lib/components/document/src/assets/icons/guidelines/greenbook/not-blurry.svg +84 -0
- package/lib/components/document/src/assets/icons/guidelines/greenbook/not-cropped.svg +83 -0
- package/lib/components/document/src/assets/icons/guidelines/greenbook/not-reflective.svg +89 -0
- package/lib/components/document/src/assets/icons/guidelines/id-card/good.svg +87 -0
- package/lib/components/document/src/assets/icons/guidelines/id-card/not-blurry.svg +100 -0
- package/lib/components/document/src/assets/icons/guidelines/id-card/not-cropped.svg +93 -0
- package/lib/components/document/src/assets/icons/guidelines/id-card/not-reflective.svg +98 -0
- package/lib/components/document/src/assets/icons/guidelines/passport/good.svg +91 -0
- package/lib/components/document/src/assets/icons/guidelines/passport/not-blurry.svg +109 -0
- package/lib/components/document/src/assets/icons/guidelines/passport/not-cropped.svg +102 -0
- package/lib/components/document/src/assets/icons/guidelines/passport/not-reflective.svg +207 -0
- package/lib/components/document/src/assets/lottie/taking photo of ID FLIP 2D.lottie +0 -0
- package/lib/components/document/src/assets/lottie/taking photo of ID.lottie +0 -0
- package/lib/components/document/src/assets/lottie/taking photo of green book passport.lottie +0 -0
- package/lib/components/document/src/assets/lottie/taking photo of passport 2.lottie +0 -0
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +123 -12
- package/lib/components/document/src/document-capture-instructions/DocumentCaptureInstructions.tsx +808 -0
- package/lib/components/document/src/document-capture-instructions/index.js +1 -0
- package/lib/components/navigation/src/Navigation.js +57 -56
- package/lib/components/navigation/src/Navigation.stories.js +7 -0
- package/lib/components/selfie/src/selfie-capture-wrapper/SelfieCaptureWrapper.tsx +113 -8
- package/lib/components/selfie/src/smartselfie-capture/utils/mediapipeManager.ts +65 -0
- package/lib/components/signature-pad/package-lock.json +11 -9
- package/lib/components/signature-pad/package.json +2 -2
- package/lib/components/smart-camera-web/src/SmartCameraWeb.js +7 -1
- package/lib/styles/src/styles.js +1 -1
- package/package.json +4 -3
- package/dist/README.md +0 -15
- package/dist/components/README.md +0 -14
- package/dist/components/document/src/README.md +0 -111
- package/dist/components/document/src/document-capture/README.md +0 -90
- package/dist/components/document/src/document-capture-instructions/README.md +0 -56
- package/dist/components/document/src/document-capture-review/README.md +0 -79
- package/dist/components/selfie/README.md +0 -225
- package/dist/components/smart-camera-web/src/README.md +0 -206
- package/dist/domain/camera/src/README.md +0 -38
- package/dist/domain/file-upload/README.md +0 -35
- package/dist/esm/DocumentCaptureScreens-DbU8ZxMx.js +0 -1580
- package/dist/esm/DocumentCaptureScreens-DbU8ZxMx.js.map +0 -1
- package/dist/esm/Navigation-DH44dkMT.js +0 -144
- package/dist/esm/Navigation-DH44dkMT.js.map +0 -1
- package/dist/esm/SelfieCaptureScreens-bmwnmeS9.js.map +0 -1
- package/dist/esm/package-7J5h4EOW.js +0 -90
- package/dist/esm/package-7J5h4EOW.js.map +0 -1
- package/dist/package-lock.json +0 -4948
- package/dist/package.json +0 -59
- package/dist/smart-camera-web.js.gz +0 -0
- package/dist/src/components/combobox/src/index.js +0 -425
- package/dist/src/components/combobox/src/index.js.map +0 -7
- package/dist/src/components/document/src/index.js +0 -1423
- package/dist/src/components/document/src/index.js.map +0 -7
- package/dist/src/components/end-user-consent/src/index.js +0 -1586
- package/dist/src/components/end-user-consent/src/index.js.map +0 -7
- package/dist/src/components/selfie/src/index.js +0 -1221
- package/dist/src/components/selfie/src/index.js.map +0 -7
- package/dist/src/components/signature-pad/src/index.js +0 -796
- package/dist/src/components/signature-pad/src/index.js.map +0 -7
- package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js +0 -2754
- package/dist/src/components/smart-camera-web/src/SmartCameraWeb.js.map +0 -7
- package/dist/src/components/totp-consent/src/index.js +0 -1305
- package/dist/src/components/totp-consent/src/index.js.map +0 -7
- package/dist/src/index.js.map +0 -7
- package/dist/styles/README.md +0 -3
- package/dist/types/document-auto-capture.d.ts +0 -34
- package/dist/types/locale.d.ts +0 -19
|
@@ -1,796 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var C = Object.defineProperty;
|
|
3
|
-
var M = (u, t, e) =>
|
|
4
|
-
t in u
|
|
5
|
-
? C(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e })
|
|
6
|
-
: (u[t] = e);
|
|
7
|
-
var x = (u, t, e) => M(u, typeof t != 'symbol' ? t + '' : t, e);
|
|
8
|
-
var w = class {
|
|
9
|
-
constructor(t, e, i, s) {
|
|
10
|
-
if (isNaN(t) || isNaN(e))
|
|
11
|
-
throw new Error('Point is invalid: ('.concat(t, ', ').concat(e, ')'));
|
|
12
|
-
((this.x = +t),
|
|
13
|
-
(this.y = +e),
|
|
14
|
-
(this.pressure = i || 0),
|
|
15
|
-
(this.time = s || Date.now()));
|
|
16
|
-
}
|
|
17
|
-
distanceTo(t) {
|
|
18
|
-
return Math.sqrt(Math.pow(this.x - t.x, 2) + Math.pow(this.y - t.y, 2));
|
|
19
|
-
}
|
|
20
|
-
equals(t) {
|
|
21
|
-
return (
|
|
22
|
-
this.x === t.x &&
|
|
23
|
-
this.y === t.y &&
|
|
24
|
-
this.pressure === t.pressure &&
|
|
25
|
-
this.time === t.time
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
velocityFrom(t) {
|
|
29
|
-
return this.time !== t.time
|
|
30
|
-
? this.distanceTo(t) / (this.time - t.time)
|
|
31
|
-
: 0;
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
y = class u {
|
|
35
|
-
static fromPoints(t, e) {
|
|
36
|
-
let i = this.calculateControlPoints(t[0], t[1], t[2]).c2,
|
|
37
|
-
s = this.calculateControlPoints(t[1], t[2], t[3]).c1;
|
|
38
|
-
return new u(t[1], i, s, t[2], e.start, e.end);
|
|
39
|
-
}
|
|
40
|
-
static calculateControlPoints(t, e, i) {
|
|
41
|
-
let s = t.x - e.x,
|
|
42
|
-
o = t.y - e.y,
|
|
43
|
-
n = e.x - i.x,
|
|
44
|
-
h = e.y - i.y,
|
|
45
|
-
a = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 },
|
|
46
|
-
r = { x: (e.x + i.x) / 2, y: (e.y + i.y) / 2 },
|
|
47
|
-
c = Math.sqrt(s * s + o * o),
|
|
48
|
-
l = Math.sqrt(n * n + h * h),
|
|
49
|
-
m = a.x - r.x,
|
|
50
|
-
p = a.y - r.y,
|
|
51
|
-
d = l / (c + l),
|
|
52
|
-
v = { x: r.x + m * d, y: r.y + p * d },
|
|
53
|
-
S = e.x - v.x,
|
|
54
|
-
k = e.y - v.y;
|
|
55
|
-
return { c1: new w(a.x + S, a.y + k), c2: new w(r.x + S, r.y + k) };
|
|
56
|
-
}
|
|
57
|
-
constructor(t, e, i, s, o, n) {
|
|
58
|
-
((this.startPoint = t),
|
|
59
|
-
(this.control2 = e),
|
|
60
|
-
(this.control1 = i),
|
|
61
|
-
(this.endPoint = s),
|
|
62
|
-
(this.startWidth = o),
|
|
63
|
-
(this.endWidth = n));
|
|
64
|
-
}
|
|
65
|
-
length() {
|
|
66
|
-
let e = 0,
|
|
67
|
-
i,
|
|
68
|
-
s;
|
|
69
|
-
for (let o = 0; o <= 10; o += 1) {
|
|
70
|
-
let n = o / 10,
|
|
71
|
-
h = this.point(
|
|
72
|
-
n,
|
|
73
|
-
this.startPoint.x,
|
|
74
|
-
this.control1.x,
|
|
75
|
-
this.control2.x,
|
|
76
|
-
this.endPoint.x,
|
|
77
|
-
),
|
|
78
|
-
a = this.point(
|
|
79
|
-
n,
|
|
80
|
-
this.startPoint.y,
|
|
81
|
-
this.control1.y,
|
|
82
|
-
this.control2.y,
|
|
83
|
-
this.endPoint.y,
|
|
84
|
-
);
|
|
85
|
-
if (o > 0) {
|
|
86
|
-
let r = h - i,
|
|
87
|
-
c = a - s;
|
|
88
|
-
e += Math.sqrt(r * r + c * c);
|
|
89
|
-
}
|
|
90
|
-
((i = h), (s = a));
|
|
91
|
-
}
|
|
92
|
-
return e;
|
|
93
|
-
}
|
|
94
|
-
point(t, e, i, s, o) {
|
|
95
|
-
return (
|
|
96
|
-
e * (1 - t) * (1 - t) * (1 - t) +
|
|
97
|
-
3 * i * (1 - t) * (1 - t) * t +
|
|
98
|
-
3 * s * (1 - t) * t * t +
|
|
99
|
-
o * t * t * t
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
b = class {
|
|
104
|
-
constructor() {
|
|
105
|
-
try {
|
|
106
|
-
this._et = new EventTarget();
|
|
107
|
-
} catch (t) {
|
|
108
|
-
this._et = document;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
addEventListener(t, e, i) {
|
|
112
|
-
this._et.addEventListener(t, e, i);
|
|
113
|
-
}
|
|
114
|
-
dispatchEvent(t) {
|
|
115
|
-
return this._et.dispatchEvent(t);
|
|
116
|
-
}
|
|
117
|
-
removeEventListener(t, e, i) {
|
|
118
|
-
this._et.removeEventListener(t, e, i);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
function L(u, t = 250) {
|
|
122
|
-
let e = 0,
|
|
123
|
-
i = null,
|
|
124
|
-
s,
|
|
125
|
-
o,
|
|
126
|
-
n,
|
|
127
|
-
h = () => {
|
|
128
|
-
((e = Date.now()),
|
|
129
|
-
(i = null),
|
|
130
|
-
(s = u.apply(o, n)),
|
|
131
|
-
i || ((o = null), (n = [])));
|
|
132
|
-
};
|
|
133
|
-
return function (...r) {
|
|
134
|
-
let c = Date.now(),
|
|
135
|
-
l = t - (c - e);
|
|
136
|
-
return (
|
|
137
|
-
(o = this),
|
|
138
|
-
(n = r),
|
|
139
|
-
l <= 0 || l > t
|
|
140
|
-
? (i && (clearTimeout(i), (i = null)),
|
|
141
|
-
(e = c),
|
|
142
|
-
(s = u.apply(o, n)),
|
|
143
|
-
i || ((o = null), (n = [])))
|
|
144
|
-
: i || (i = window.setTimeout(h, l)),
|
|
145
|
-
s
|
|
146
|
-
);
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
var f = class u extends b {
|
|
150
|
-
constructor(t, e = {}) {
|
|
151
|
-
var i, s, o;
|
|
152
|
-
(super(),
|
|
153
|
-
(this.canvas = t),
|
|
154
|
-
(this._drawingStroke = !1),
|
|
155
|
-
(this._isEmpty = !0),
|
|
156
|
-
(this._lastPoints = []),
|
|
157
|
-
(this._data = []),
|
|
158
|
-
(this._lastVelocity = 0),
|
|
159
|
-
(this._lastWidth = 0),
|
|
160
|
-
(this._handleMouseDown = (n) => {
|
|
161
|
-
!this._isLeftButtonPressed(n, !0) ||
|
|
162
|
-
this._drawingStroke ||
|
|
163
|
-
this._strokeBegin(this._pointerEventToSignatureEvent(n));
|
|
164
|
-
}),
|
|
165
|
-
(this._handleMouseMove = (n) => {
|
|
166
|
-
if (!this._isLeftButtonPressed(n, !0) || !this._drawingStroke) {
|
|
167
|
-
this._strokeEnd(this._pointerEventToSignatureEvent(n), !1);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n));
|
|
171
|
-
}),
|
|
172
|
-
(this._handleMouseUp = (n) => {
|
|
173
|
-
this._isLeftButtonPressed(n) ||
|
|
174
|
-
this._strokeEnd(this._pointerEventToSignatureEvent(n));
|
|
175
|
-
}),
|
|
176
|
-
(this._handleTouchStart = (n) => {
|
|
177
|
-
n.targetTouches.length !== 1 ||
|
|
178
|
-
this._drawingStroke ||
|
|
179
|
-
(n.cancelable && n.preventDefault(),
|
|
180
|
-
this._strokeBegin(this._touchEventToSignatureEvent(n)));
|
|
181
|
-
}),
|
|
182
|
-
(this._handleTouchMove = (n) => {
|
|
183
|
-
if (n.targetTouches.length === 1) {
|
|
184
|
-
if ((n.cancelable && n.preventDefault(), !this._drawingStroke)) {
|
|
185
|
-
this._strokeEnd(this._touchEventToSignatureEvent(n), !1);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
this._strokeMoveUpdate(this._touchEventToSignatureEvent(n));
|
|
189
|
-
}
|
|
190
|
-
}),
|
|
191
|
-
(this._handleTouchEnd = (n) => {
|
|
192
|
-
n.targetTouches.length === 0 &&
|
|
193
|
-
(n.cancelable && n.preventDefault(),
|
|
194
|
-
this.canvas.removeEventListener('touchmove', this._handleTouchMove),
|
|
195
|
-
this._strokeEnd(this._touchEventToSignatureEvent(n)));
|
|
196
|
-
}),
|
|
197
|
-
(this._handlePointerDown = (n) => {
|
|
198
|
-
!this._isLeftButtonPressed(n) ||
|
|
199
|
-
this._drawingStroke ||
|
|
200
|
-
(n.preventDefault(),
|
|
201
|
-
this._strokeBegin(this._pointerEventToSignatureEvent(n)));
|
|
202
|
-
}),
|
|
203
|
-
(this._handlePointerMove = (n) => {
|
|
204
|
-
if (!this._isLeftButtonPressed(n, !0) || !this._drawingStroke) {
|
|
205
|
-
this._strokeEnd(this._pointerEventToSignatureEvent(n), !1);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
(n.preventDefault(),
|
|
209
|
-
this._strokeMoveUpdate(this._pointerEventToSignatureEvent(n)));
|
|
210
|
-
}),
|
|
211
|
-
(this._handlePointerUp = (n) => {
|
|
212
|
-
this._isLeftButtonPressed(n) ||
|
|
213
|
-
(n.preventDefault(),
|
|
214
|
-
this._strokeEnd(this._pointerEventToSignatureEvent(n)));
|
|
215
|
-
}),
|
|
216
|
-
(this.velocityFilterWeight = e.velocityFilterWeight || 0.7),
|
|
217
|
-
(this.minWidth = e.minWidth || 0.5),
|
|
218
|
-
(this.maxWidth = e.maxWidth || 2.5),
|
|
219
|
-
(this.throttle = (i = e.throttle) !== null && i !== void 0 ? i : 16),
|
|
220
|
-
(this.minDistance =
|
|
221
|
-
(s = e.minDistance) !== null && s !== void 0 ? s : 5),
|
|
222
|
-
(this.dotSize = e.dotSize || 0),
|
|
223
|
-
(this.penColor = e.penColor || 'black'),
|
|
224
|
-
(this.backgroundColor = e.backgroundColor || 'rgba(0,0,0,0)'),
|
|
225
|
-
(this.compositeOperation = e.compositeOperation || 'source-over'),
|
|
226
|
-
(this.canvasContextOptions =
|
|
227
|
-
(o = e.canvasContextOptions) !== null && o !== void 0 ? o : {}),
|
|
228
|
-
(this._strokeMoveUpdate = this.throttle
|
|
229
|
-
? L(u.prototype._strokeUpdate, this.throttle)
|
|
230
|
-
: u.prototype._strokeUpdate),
|
|
231
|
-
(this._ctx = t.getContext('2d', this.canvasContextOptions)),
|
|
232
|
-
this.clear(),
|
|
233
|
-
this.on());
|
|
234
|
-
}
|
|
235
|
-
clear() {
|
|
236
|
-
let { _ctx: t, canvas: e } = this;
|
|
237
|
-
((t.fillStyle = this.backgroundColor),
|
|
238
|
-
t.clearRect(0, 0, e.width, e.height),
|
|
239
|
-
t.fillRect(0, 0, e.width, e.height),
|
|
240
|
-
(this._data = []),
|
|
241
|
-
this._reset(this._getPointGroupOptions()),
|
|
242
|
-
(this._isEmpty = !0));
|
|
243
|
-
}
|
|
244
|
-
fromDataURL(t, e = {}) {
|
|
245
|
-
return new Promise((i, s) => {
|
|
246
|
-
let o = new Image(),
|
|
247
|
-
n = e.ratio || window.devicePixelRatio || 1,
|
|
248
|
-
h = e.width || this.canvas.width / n,
|
|
249
|
-
a = e.height || this.canvas.height / n,
|
|
250
|
-
r = e.xOffset || 0,
|
|
251
|
-
c = e.yOffset || 0;
|
|
252
|
-
(this._reset(this._getPointGroupOptions()),
|
|
253
|
-
(o.onload = () => {
|
|
254
|
-
(this._ctx.drawImage(o, r, c, h, a), i());
|
|
255
|
-
}),
|
|
256
|
-
(o.onerror = (l) => {
|
|
257
|
-
s(l);
|
|
258
|
-
}),
|
|
259
|
-
(o.crossOrigin = 'anonymous'),
|
|
260
|
-
(o.src = t),
|
|
261
|
-
(this._isEmpty = !1));
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
toDataURL(t = 'image/png', e) {
|
|
265
|
-
switch (t) {
|
|
266
|
-
case 'image/svg+xml':
|
|
267
|
-
return (
|
|
268
|
-
typeof e != 'object' && (e = void 0),
|
|
269
|
-
'data:image/svg+xml;base64,'.concat(btoa(this.toSVG(e)))
|
|
270
|
-
);
|
|
271
|
-
default:
|
|
272
|
-
return (
|
|
273
|
-
typeof e != 'number' && (e = void 0),
|
|
274
|
-
this.canvas.toDataURL(t, e)
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
on() {
|
|
279
|
-
((this.canvas.style.touchAction = 'none'),
|
|
280
|
-
(this.canvas.style.msTouchAction = 'none'),
|
|
281
|
-
(this.canvas.style.userSelect = 'none'));
|
|
282
|
-
let t =
|
|
283
|
-
/Macintosh/.test(navigator.userAgent) && 'ontouchstart' in document;
|
|
284
|
-
window.PointerEvent && !t
|
|
285
|
-
? this._handlePointerEvents()
|
|
286
|
-
: (this._handleMouseEvents(),
|
|
287
|
-
'ontouchstart' in window && this._handleTouchEvents());
|
|
288
|
-
}
|
|
289
|
-
off() {
|
|
290
|
-
((this.canvas.style.touchAction = 'auto'),
|
|
291
|
-
(this.canvas.style.msTouchAction = 'auto'),
|
|
292
|
-
(this.canvas.style.userSelect = 'auto'),
|
|
293
|
-
this.canvas.removeEventListener('pointerdown', this._handlePointerDown),
|
|
294
|
-
this.canvas.removeEventListener('mousedown', this._handleMouseDown),
|
|
295
|
-
this.canvas.removeEventListener('touchstart', this._handleTouchStart),
|
|
296
|
-
this._removeMoveUpEventListeners());
|
|
297
|
-
}
|
|
298
|
-
_getListenerFunctions() {
|
|
299
|
-
var t;
|
|
300
|
-
let e =
|
|
301
|
-
window.document === this.canvas.ownerDocument
|
|
302
|
-
? window
|
|
303
|
-
: (t = this.canvas.ownerDocument.defaultView) !== null && t !== void 0
|
|
304
|
-
? t
|
|
305
|
-
: this.canvas.ownerDocument;
|
|
306
|
-
return {
|
|
307
|
-
addEventListener: e.addEventListener.bind(e),
|
|
308
|
-
removeEventListener: e.removeEventListener.bind(e),
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
_removeMoveUpEventListeners() {
|
|
312
|
-
let { removeEventListener: t } = this._getListenerFunctions();
|
|
313
|
-
(t('pointermove', this._handlePointerMove),
|
|
314
|
-
t('pointerup', this._handlePointerUp),
|
|
315
|
-
t('mousemove', this._handleMouseMove),
|
|
316
|
-
t('mouseup', this._handleMouseUp),
|
|
317
|
-
t('touchmove', this._handleTouchMove),
|
|
318
|
-
t('touchend', this._handleTouchEnd));
|
|
319
|
-
}
|
|
320
|
-
isEmpty() {
|
|
321
|
-
return this._isEmpty;
|
|
322
|
-
}
|
|
323
|
-
fromData(t, { clear: e = !0 } = {}) {
|
|
324
|
-
(e && this.clear(),
|
|
325
|
-
this._fromData(t, this._drawCurve.bind(this), this._drawDot.bind(this)),
|
|
326
|
-
(this._data = this._data.concat(t)));
|
|
327
|
-
}
|
|
328
|
-
toData() {
|
|
329
|
-
return this._data;
|
|
330
|
-
}
|
|
331
|
-
_isLeftButtonPressed(t, e) {
|
|
332
|
-
return e ? t.buttons === 1 : (t.buttons & 1) === 1;
|
|
333
|
-
}
|
|
334
|
-
_pointerEventToSignatureEvent(t) {
|
|
335
|
-
return {
|
|
336
|
-
event: t,
|
|
337
|
-
type: t.type,
|
|
338
|
-
x: t.clientX,
|
|
339
|
-
y: t.clientY,
|
|
340
|
-
pressure: 'pressure' in t ? t.pressure : 0,
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
_touchEventToSignatureEvent(t) {
|
|
344
|
-
let e = t.changedTouches[0];
|
|
345
|
-
return {
|
|
346
|
-
event: t,
|
|
347
|
-
type: t.type,
|
|
348
|
-
x: e.clientX,
|
|
349
|
-
y: e.clientY,
|
|
350
|
-
pressure: e.force,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
_getPointGroupOptions(t) {
|
|
354
|
-
return {
|
|
355
|
-
penColor: t && 'penColor' in t ? t.penColor : this.penColor,
|
|
356
|
-
dotSize: t && 'dotSize' in t ? t.dotSize : this.dotSize,
|
|
357
|
-
minWidth: t && 'minWidth' in t ? t.minWidth : this.minWidth,
|
|
358
|
-
maxWidth: t && 'maxWidth' in t ? t.maxWidth : this.maxWidth,
|
|
359
|
-
velocityFilterWeight:
|
|
360
|
-
t && 'velocityFilterWeight' in t
|
|
361
|
-
? t.velocityFilterWeight
|
|
362
|
-
: this.velocityFilterWeight,
|
|
363
|
-
compositeOperation:
|
|
364
|
-
t && 'compositeOperation' in t
|
|
365
|
-
? t.compositeOperation
|
|
366
|
-
: this.compositeOperation,
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
_strokeBegin(t) {
|
|
370
|
-
if (
|
|
371
|
-
!this.dispatchEvent(
|
|
372
|
-
new CustomEvent('beginStroke', { detail: t, cancelable: !0 }),
|
|
373
|
-
)
|
|
374
|
-
)
|
|
375
|
-
return;
|
|
376
|
-
let { addEventListener: i } = this._getListenerFunctions();
|
|
377
|
-
switch (t.event.type) {
|
|
378
|
-
case 'mousedown':
|
|
379
|
-
(i('mousemove', this._handleMouseMove),
|
|
380
|
-
i('mouseup', this._handleMouseUp));
|
|
381
|
-
break;
|
|
382
|
-
case 'touchstart':
|
|
383
|
-
(i('touchmove', this._handleTouchMove),
|
|
384
|
-
i('touchend', this._handleTouchEnd));
|
|
385
|
-
break;
|
|
386
|
-
case 'pointerdown':
|
|
387
|
-
(i('pointermove', this._handlePointerMove),
|
|
388
|
-
i('pointerup', this._handlePointerUp));
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
this._drawingStroke = !0;
|
|
392
|
-
let s = this._getPointGroupOptions(),
|
|
393
|
-
o = Object.assign(Object.assign({}, s), { points: [] });
|
|
394
|
-
(this._data.push(o), this._reset(s), this._strokeUpdate(t));
|
|
395
|
-
}
|
|
396
|
-
_strokeUpdate(t) {
|
|
397
|
-
if (!this._drawingStroke) return;
|
|
398
|
-
if (this._data.length === 0) {
|
|
399
|
-
this._strokeBegin(t);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
this.dispatchEvent(new CustomEvent('beforeUpdateStroke', { detail: t }));
|
|
403
|
-
let e = this._createPoint(t.x, t.y, t.pressure),
|
|
404
|
-
i = this._data[this._data.length - 1],
|
|
405
|
-
s = i.points,
|
|
406
|
-
o = s.length > 0 && s[s.length - 1],
|
|
407
|
-
n = o ? e.distanceTo(o) <= this.minDistance : !1,
|
|
408
|
-
h = this._getPointGroupOptions(i);
|
|
409
|
-
if (!o || !(o && n)) {
|
|
410
|
-
let a = this._addPoint(e, h);
|
|
411
|
-
(o ? a && this._drawCurve(a, h) : this._drawDot(e, h),
|
|
412
|
-
s.push({ time: e.time, x: e.x, y: e.y, pressure: e.pressure }));
|
|
413
|
-
}
|
|
414
|
-
this.dispatchEvent(new CustomEvent('afterUpdateStroke', { detail: t }));
|
|
415
|
-
}
|
|
416
|
-
_strokeEnd(t, e = !0) {
|
|
417
|
-
(this._removeMoveUpEventListeners(),
|
|
418
|
-
this._drawingStroke &&
|
|
419
|
-
(e && this._strokeUpdate(t),
|
|
420
|
-
(this._drawingStroke = !1),
|
|
421
|
-
this.dispatchEvent(new CustomEvent('endStroke', { detail: t }))));
|
|
422
|
-
}
|
|
423
|
-
_handlePointerEvents() {
|
|
424
|
-
((this._drawingStroke = !1),
|
|
425
|
-
this.canvas.addEventListener('pointerdown', this._handlePointerDown));
|
|
426
|
-
}
|
|
427
|
-
_handleMouseEvents() {
|
|
428
|
-
((this._drawingStroke = !1),
|
|
429
|
-
this.canvas.addEventListener('mousedown', this._handleMouseDown));
|
|
430
|
-
}
|
|
431
|
-
_handleTouchEvents() {
|
|
432
|
-
this.canvas.addEventListener('touchstart', this._handleTouchStart);
|
|
433
|
-
}
|
|
434
|
-
_reset(t) {
|
|
435
|
-
((this._lastPoints = []),
|
|
436
|
-
(this._lastVelocity = 0),
|
|
437
|
-
(this._lastWidth = (t.minWidth + t.maxWidth) / 2),
|
|
438
|
-
(this._ctx.fillStyle = t.penColor),
|
|
439
|
-
(this._ctx.globalCompositeOperation = t.compositeOperation));
|
|
440
|
-
}
|
|
441
|
-
_createPoint(t, e, i) {
|
|
442
|
-
let s = this.canvas.getBoundingClientRect();
|
|
443
|
-
return new w(t - s.left, e - s.top, i, new Date().getTime());
|
|
444
|
-
}
|
|
445
|
-
_addPoint(t, e) {
|
|
446
|
-
let { _lastPoints: i } = this;
|
|
447
|
-
if ((i.push(t), i.length > 2)) {
|
|
448
|
-
i.length === 3 && i.unshift(i[0]);
|
|
449
|
-
let s = this._calculateCurveWidths(i[1], i[2], e),
|
|
450
|
-
o = y.fromPoints(i, s);
|
|
451
|
-
return (i.shift(), o);
|
|
452
|
-
}
|
|
453
|
-
return null;
|
|
454
|
-
}
|
|
455
|
-
_calculateCurveWidths(t, e, i) {
|
|
456
|
-
let s =
|
|
457
|
-
i.velocityFilterWeight * e.velocityFrom(t) +
|
|
458
|
-
(1 - i.velocityFilterWeight) * this._lastVelocity,
|
|
459
|
-
o = this._strokeWidth(s, i),
|
|
460
|
-
n = { end: o, start: this._lastWidth };
|
|
461
|
-
return ((this._lastVelocity = s), (this._lastWidth = o), n);
|
|
462
|
-
}
|
|
463
|
-
_strokeWidth(t, e) {
|
|
464
|
-
return Math.max(e.maxWidth / (t + 1), e.minWidth);
|
|
465
|
-
}
|
|
466
|
-
_drawCurveSegment(t, e, i) {
|
|
467
|
-
let s = this._ctx;
|
|
468
|
-
(s.moveTo(t, e),
|
|
469
|
-
s.arc(t, e, i, 0, 2 * Math.PI, !1),
|
|
470
|
-
(this._isEmpty = !1));
|
|
471
|
-
}
|
|
472
|
-
_drawCurve(t, e) {
|
|
473
|
-
let i = this._ctx,
|
|
474
|
-
s = t.endWidth - t.startWidth,
|
|
475
|
-
o = Math.ceil(t.length()) * 2;
|
|
476
|
-
(i.beginPath(), (i.fillStyle = e.penColor));
|
|
477
|
-
for (let n = 0; n < o; n += 1) {
|
|
478
|
-
let h = n / o,
|
|
479
|
-
a = h * h,
|
|
480
|
-
r = a * h,
|
|
481
|
-
c = 1 - h,
|
|
482
|
-
l = c * c,
|
|
483
|
-
m = l * c,
|
|
484
|
-
p = m * t.startPoint.x;
|
|
485
|
-
((p += 3 * l * h * t.control1.x),
|
|
486
|
-
(p += 3 * c * a * t.control2.x),
|
|
487
|
-
(p += r * t.endPoint.x));
|
|
488
|
-
let d = m * t.startPoint.y;
|
|
489
|
-
((d += 3 * l * h * t.control1.y),
|
|
490
|
-
(d += 3 * c * a * t.control2.y),
|
|
491
|
-
(d += r * t.endPoint.y));
|
|
492
|
-
let v = Math.min(t.startWidth + r * s, e.maxWidth);
|
|
493
|
-
this._drawCurveSegment(p, d, v);
|
|
494
|
-
}
|
|
495
|
-
(i.closePath(), i.fill());
|
|
496
|
-
}
|
|
497
|
-
_drawDot(t, e) {
|
|
498
|
-
let i = this._ctx,
|
|
499
|
-
s = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
|
|
500
|
-
(i.beginPath(),
|
|
501
|
-
this._drawCurveSegment(t.x, t.y, s),
|
|
502
|
-
i.closePath(),
|
|
503
|
-
(i.fillStyle = e.penColor),
|
|
504
|
-
i.fill());
|
|
505
|
-
}
|
|
506
|
-
_fromData(t, e, i) {
|
|
507
|
-
for (let s of t) {
|
|
508
|
-
let { points: o } = s,
|
|
509
|
-
n = this._getPointGroupOptions(s);
|
|
510
|
-
if (o.length > 1)
|
|
511
|
-
for (let h = 0; h < o.length; h += 1) {
|
|
512
|
-
let a = o[h],
|
|
513
|
-
r = new w(a.x, a.y, a.pressure, a.time);
|
|
514
|
-
h === 0 && this._reset(n);
|
|
515
|
-
let c = this._addPoint(r, n);
|
|
516
|
-
c && e(c, n);
|
|
517
|
-
}
|
|
518
|
-
else (this._reset(n), i(o[0], n));
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
toSVG({ includeBackgroundColor: t = !1 } = {}) {
|
|
522
|
-
let e = this._data,
|
|
523
|
-
i = Math.max(window.devicePixelRatio || 1, 1),
|
|
524
|
-
s = 0,
|
|
525
|
-
o = 0,
|
|
526
|
-
n = this.canvas.width / i,
|
|
527
|
-
h = this.canvas.height / i,
|
|
528
|
-
a = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
529
|
-
if (
|
|
530
|
-
(a.setAttribute('xmlns', 'http://www.w3.org/2000/svg'),
|
|
531
|
-
a.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'),
|
|
532
|
-
a.setAttribute(
|
|
533
|
-
'viewBox',
|
|
534
|
-
''.concat(s, ' ').concat(o, ' ').concat(n, ' ').concat(h),
|
|
535
|
-
),
|
|
536
|
-
a.setAttribute('width', n.toString()),
|
|
537
|
-
a.setAttribute('height', h.toString()),
|
|
538
|
-
t && this.backgroundColor)
|
|
539
|
-
) {
|
|
540
|
-
let r = document.createElement('rect');
|
|
541
|
-
(r.setAttribute('width', '100%'),
|
|
542
|
-
r.setAttribute('height', '100%'),
|
|
543
|
-
r.setAttribute('fill', this.backgroundColor),
|
|
544
|
-
a.appendChild(r));
|
|
545
|
-
}
|
|
546
|
-
return (
|
|
547
|
-
this._fromData(
|
|
548
|
-
e,
|
|
549
|
-
(r, { penColor: c }) => {
|
|
550
|
-
let l = document.createElement('path');
|
|
551
|
-
if (
|
|
552
|
-
!isNaN(r.control1.x) &&
|
|
553
|
-
!isNaN(r.control1.y) &&
|
|
554
|
-
!isNaN(r.control2.x) &&
|
|
555
|
-
!isNaN(r.control2.y)
|
|
556
|
-
) {
|
|
557
|
-
let m =
|
|
558
|
-
'M '
|
|
559
|
-
.concat(r.startPoint.x.toFixed(3), ',')
|
|
560
|
-
.concat(r.startPoint.y.toFixed(3), ' ') +
|
|
561
|
-
'C '
|
|
562
|
-
.concat(r.control1.x.toFixed(3), ',')
|
|
563
|
-
.concat(r.control1.y.toFixed(3), ' ') +
|
|
564
|
-
''
|
|
565
|
-
.concat(r.control2.x.toFixed(3), ',')
|
|
566
|
-
.concat(r.control2.y.toFixed(3), ' ') +
|
|
567
|
-
''
|
|
568
|
-
.concat(r.endPoint.x.toFixed(3), ',')
|
|
569
|
-
.concat(r.endPoint.y.toFixed(3));
|
|
570
|
-
(l.setAttribute('d', m),
|
|
571
|
-
l.setAttribute('stroke-width', (r.endWidth * 2.25).toFixed(3)),
|
|
572
|
-
l.setAttribute('stroke', c),
|
|
573
|
-
l.setAttribute('fill', 'none'),
|
|
574
|
-
l.setAttribute('stroke-linecap', 'round'),
|
|
575
|
-
a.appendChild(l));
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
(r, { penColor: c, dotSize: l, minWidth: m, maxWidth: p }) => {
|
|
579
|
-
let d = document.createElement('circle'),
|
|
580
|
-
v = l > 0 ? l : (m + p) / 2;
|
|
581
|
-
(d.setAttribute('r', v.toString()),
|
|
582
|
-
d.setAttribute('cx', r.x.toString()),
|
|
583
|
-
d.setAttribute('cy', r.y.toString()),
|
|
584
|
-
d.setAttribute('fill', c),
|
|
585
|
-
a.appendChild(d));
|
|
586
|
-
},
|
|
587
|
-
),
|
|
588
|
-
a.outerHTML
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
var g = class g {
|
|
593
|
-
static getHumanSize(t) {
|
|
594
|
-
let e = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
595
|
-
i = Math.min(Math.floor(Math.log(t) / Math.log(1024)), e.length - 1),
|
|
596
|
-
s = t / 1024 ** i;
|
|
597
|
-
return i === 0
|
|
598
|
-
? ''.concat(t, ' bytes')
|
|
599
|
-
: ''.concat(s.toFixed(0), ' ').concat(e[i]);
|
|
600
|
-
}
|
|
601
|
-
static getData(t) {
|
|
602
|
-
return new Promise((e, i) => {
|
|
603
|
-
let s = new FileReader();
|
|
604
|
-
((s.onload = (o) => {
|
|
605
|
-
e(o.target.result);
|
|
606
|
-
}),
|
|
607
|
-
(s.onerror = () => {
|
|
608
|
-
i(
|
|
609
|
-
new Error(
|
|
610
|
-
'An error occurred reading the file. Please check the file, and try again',
|
|
611
|
-
),
|
|
612
|
-
);
|
|
613
|
-
}),
|
|
614
|
-
s.readAsDataURL(t));
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
static async retrieve(t) {
|
|
618
|
-
if (t.length > 1)
|
|
619
|
-
throw new Error('Only one file upload is permitted at a time');
|
|
620
|
-
let e = t[0];
|
|
621
|
-
if (!g.supportedTypes.includes(e.type))
|
|
622
|
-
throw new Error(
|
|
623
|
-
'Unsupported file format. Please ensure that you are providing a JPG, PNG or SVG image',
|
|
624
|
-
);
|
|
625
|
-
if (e.size > g.memoryLimit)
|
|
626
|
-
throw new Error(
|
|
627
|
-
''
|
|
628
|
-
.concat(
|
|
629
|
-
e.name,
|
|
630
|
-
' is too large. Please ensure that the file is less than ',
|
|
631
|
-
)
|
|
632
|
-
.concat(g.getHumanSize(g.memoryLimit), '.'),
|
|
633
|
-
);
|
|
634
|
-
return await g.getData(e);
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
(x(g, 'memoryLimit', 2048e3),
|
|
638
|
-
x(g, 'supportedTypes', ['image/jpeg', 'image/png', 'image/svg+xml']));
|
|
639
|
-
var E = g,
|
|
640
|
-
_ = class extends HTMLElement {
|
|
641
|
-
connectedCallback() {
|
|
642
|
-
let t = this.attachShadow({ mode: 'open' }),
|
|
643
|
-
e = document.createElement('style');
|
|
644
|
-
e.textContent =
|
|
645
|
-
'\n:host {\n display: block;\n block-size: auto;\n inline-size: 30rem;\n max-inline-size: 100%;\n position: relative;\n --color-active: #2D2B2A;\n --color-default: #001096;\n --color-disabled: #848282;\n}\n\n:host::part(upload) {\n text-align: center;\n}\n\n:host::part(signature-controls) {\n display: inline-flex;\n position: absolute;\n top: 1rem;\n right: 1rem;\n}\n\n:host::part(upload) svg + * {\n margin-inline-start: .5rem;\n}\n\n:host::part(canvas) {\n background-color: #F9F0E7;\n --dot-bg: #F9F0E7;\n --dot-color: black;\n --dot-size: 1px;\n --dot-space: 22px;\n background:\n linear-gradient(90deg, var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n linear-gradient(var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),\n var(--dot-color);\n border-radius: 2rem;\n inline-size: 30rem;\n max-inline-size: 100%;\n aspect-ratio: 2 / 1;\n}\n\n:host::part(upload-preview-image) {\n max-inline-size: 10rem;\n margin-inline: auto;\n}\n\n.visually-hidden {\n clip: rect(0 0 0 0); \n clip-path: inset(50%);\n height: 1px;\n overflow: hidden;\n position: absolute;\n white-space: nowrap; \n width: 1px;\n}\n\nbutton,\nlabel {\n font: inherit;\n cursor: pointer;\n}\n\nlabel {\n display: inline-flex;\n text-decoration: underline;\n}\n\nlabel svg + * {\n margin-inline-start: .5rem;\n}\n\n[type="file"] {\n display: none;\n}\n\n.center {\n text-align: center;\n margin-inline: auto;\n}\n\n.color-red {\n color: red;\n}\n\nbutton[data-variant="icon"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n}\n\nbutton[data-variant="text"] {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n border: 0px;\n text-decoration: underline;\n display: inline-flex;\n align-items: baseline;\n}\n\nbutton[data-variant="solid"] {\n --button-color: '.concat(
|
|
646
|
-
this.themeColor,
|
|
647
|
-
';\n border-radius: 2.5rem;\n border: 0;\n background-color: transparent;\n color: #fff;\n cursor: pointer;\n inline-size: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n font-weight: 600;\n padding: .75rem 1.5rem;\n text-align: center;\n background-color: var(--button-color);\n border: 2px solid var(--button-color);\n}\n\nbutton:hover,\nbutton:focus,\nbutton:active {\n --button-color: var(--color-active);\n}\n\nbutton:disabled {\n --button-color: var(--color-disabled);\n}\n',
|
|
648
|
-
);
|
|
649
|
-
let i = document.createElement('div'),
|
|
650
|
-
s = document.createElement('div');
|
|
651
|
-
s.innerHTML =
|
|
652
|
-
'\n <p id="error" class="color-red | center"><p>\n ';
|
|
653
|
-
let o = document.createElement('div');
|
|
654
|
-
(o.setAttribute('id', 'controls'),
|
|
655
|
-
o.setAttribute('part', 'signature-controls'),
|
|
656
|
-
(o.innerHTML =
|
|
657
|
-
'\n <button data-variant="icon" type="button" name="clear" id="clear">\n <span class="visually-hidden">\n Clear Signature\n </span>\n <svg fill="none" xmlns="http://www.w3.org/2000/svg" width="18" viewBox="0 0 17 18">\n <path d="M3.314 15.646a8.004 8.004 0 01-2.217-4.257 8.06 8.06 0 01.545-4.655l1.789.788a6.062 6.062 0 001.264 6.737 6.033 6.033 0 008.551 0c2.358-2.37 2.358-6.224 0-8.592a5.996 5.996 0 00-4.405-1.782l.662 2.354-3.128-.796-3.127-.796 2.25-2.324L7.748 0l.55 1.953a7.966 7.966 0 016.33 2.326 8.004 8.004 0 012.342 5.684 8.005 8.005 0 01-2.343 5.683A7.928 7.928 0 018.97 18a7.928 7.928 0 01-5.656-2.354z" fill="currentColor" />\n </svg>\n </button>\n '));
|
|
658
|
-
let n = document.createElement('canvas'),
|
|
659
|
-
r = this.parentElement
|
|
660
|
-
.closest(':not([hidden])')
|
|
661
|
-
.querySelector(':not([hidden])').offsetWidth,
|
|
662
|
-
l =
|
|
663
|
-
30 *
|
|
664
|
-
getComputedStyle(document.documentElement).fontSize.split('px')[0],
|
|
665
|
-
m = 2;
|
|
666
|
-
((n.width = r < l ? r : l),
|
|
667
|
-
(n.height = (r < l ? r : l) / m),
|
|
668
|
-
n.setAttribute('id', 'signature-canvas'),
|
|
669
|
-
n.setAttribute('part', 'canvas'));
|
|
670
|
-
let p = document.createElement('div');
|
|
671
|
-
(p.setAttribute('id', 'signature-upload-wrapper'),
|
|
672
|
-
(p.innerHTML =
|
|
673
|
-
'\n <p part="upload">\n <strong>or</strong>\n <label>\n <input type=\'file\' onclick=\'this.value=null;\' id=\'upload-signature\' accept=\'image/jpeg, image/png, image/svg+xml\' />\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none">\n <rect width="16" height="16" fill="#F9F0E7" rx="2"/>\n <mask id="sign" width="16" height="16" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha">\n <rect width="16" height="16" fill="#D9D9D9" rx="2"/>\n </mask>\n <g mask="url(#sign)">\n <path fill="#2D2B2A" d="M0 13.333h16V16H0z"/>\n </g>\n <path fill="#2D2B2A" fill-rule="evenodd" d="M2.69 7.346a.23.23 0 0 1 .059-.073.275.275 0 0 1 .284-.034c.07.036.146.064.224.084h.12c0-.012.105-.048.105-.395a.796.796 0 0 1 .211-.61.667.667 0 0 1 .607-.096c.202.061.39.154.555.275.194.138.38.286.555.443.146.134.31.25.489.347l.092.047c.119.06.238-.023.185-.143l-.04-.12a.817.817 0 0 1-.066-.694.675.675 0 0 1 .244-.273.774.774 0 0 1 .364-.12c.324-.028.651 0 .964.083h.026c.027-.861.225-1.83.82-2.523.593-.694 1.478-.993 2.205-.837.726.155 1.307.73 1.307 1.602 0 1.34-.872 2.26-1.915 2.93.471.374.85.835 1.11 1.351.027.046.05.094.065.144h.014a.55.55 0 0 0 .079.203.44.44 0 0 0 .04.18c.002.025.011.05.026.07h-.013c.037.17.041.344.013.515a.955.955 0 0 1-.188.493 1.097 1.097 0 0 1-.433.344 1.346 1.346 0 0 1-1.122.012 2.194 2.194 0 0 1-.846-.67 5.024 5.024 0 0 1-.462-.681h-.026a.502.502 0 0 0-.106-.144.014.014 0 0 1-.01-.003.011.011 0 0 1-.003-.009.035.035 0 0 1-.013-.023.047.047 0 0 1-.011-.017.626.626 0 0 0-.055-.163.24.24 0 0 0-.014-.095h.014a3.477 3.477 0 0 1-.198-.49 6.318 6.318 0 0 1-.278-1.699L7.51 6.51c-.243-.07-.5-.094-.753-.071-.158.024-.198.071-.211.107-.014.036-.04.168.053.359.092.191.171.478.118.658a.45.45 0 0 1-.21.25.66.66 0 0 1-.305.06 1.521 1.521 0 0 1-.568-.19 3.533 3.533 0 0 1-.58-.42 3.54 3.54 0 0 0-.49-.394 1.49 1.49 0 0 0-.409-.203c-.053-.024-.079-.024-.092-.012H4.05c-.014.012-.066.072-.066.275 0 .395-.12.705-.423.813a.813.813 0 0 1-.41.024 1.646 1.646 0 0 1-.343-.12.237.237 0 0 1-.126-.127.208.208 0 0 1 .007-.172Zm5.731.766c.068.204.152.404.251.598.011.053.03.105.053.155.036.068.08.132.132.191.02.05.047.099.08.144.085.152.186.296.303.43.167.22.389.4.647.526a.847.847 0 0 0 .687-.011.655.655 0 0 0 .247-.204.573.573 0 0 0 .11-.287 1.435 1.435 0 0 0-.04-.454h-.014a.496.496 0 0 0-.079-.335.491.491 0 0 0-.119-.191 3.842 3.842 0 0 0-1.017-1.16l-.356.18a.253.253 0 0 1-.193.027.248.248 0 0 1-.088-.041.22.22 0 0 1-.063-.07.219.219 0 0 1-.02-.172.242.242 0 0 1 .113-.14l.172-.083a3.388 3.388 0 0 0-.463-.251l-.58-.24c.022.47.101.935.237 1.388Zm.568-1.555c.24.12.474.252.7.395 1.017-.634 1.81-1.459 1.81-2.63 0-.67-.41-1.053-.912-1.16-.502-.108-1.189.083-1.704.669-.515.586-.7 1.47-.713 2.32v.083c.251.084.515.192.819.323Z" clip-rule="evenodd"/>\n </svg>\n <span>upload a signature</span>\n </label>\n </p>\n '));
|
|
674
|
-
let d = document.createElement('p');
|
|
675
|
-
((d.innerHTML =
|
|
676
|
-
'\n <button data-variant="solid" type="button" name="publish" id="publish">\n <span>\n Continue\n </span>\n <svg\n aria-hidden="true"\n width="25"\n height="24"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n >\n <path\n d="M7 12h11m0 0-4.588-4M18 12l-4.588 4"\n stroke="#fff"\n stroke-width="1.5"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n </svg>\n </button>\n '),
|
|
677
|
-
i.appendChild(s),
|
|
678
|
-
i.appendChild(o),
|
|
679
|
-
i.appendChild(n),
|
|
680
|
-
this.allowUpload && i.appendChild(p),
|
|
681
|
-
i.appendChild(d),
|
|
682
|
-
t.appendChild(e),
|
|
683
|
-
t.appendChild(i),
|
|
684
|
-
(this.core = new f(n)),
|
|
685
|
-
(this.errorMessage = s.querySelector('#error')),
|
|
686
|
-
window && (window.onresize = this.resizeCanvas()),
|
|
687
|
-
(this.clearSignatureButton = o.querySelector('#clear')),
|
|
688
|
-
this.clearSignatureButton.addEventListener('click', () =>
|
|
689
|
-
this.clearSignature(),
|
|
690
|
-
),
|
|
691
|
-
(this.uploadSignatureButton = p.querySelector('#upload-signature')),
|
|
692
|
-
this.uploadSignatureButton.addEventListener('change', (v) =>
|
|
693
|
-
this.uploadSignature(v),
|
|
694
|
-
),
|
|
695
|
-
(this.publishSignatureButton = d.querySelector('#publish')),
|
|
696
|
-
this.publishSignatureButton.addEventListener('click', () =>
|
|
697
|
-
this.publishSignature(),
|
|
698
|
-
));
|
|
699
|
-
}
|
|
700
|
-
disconnectedCallback() {
|
|
701
|
-
(this.publishSignatureButton.removeEventListener('click', () =>
|
|
702
|
-
this.publishSignature(),
|
|
703
|
-
),
|
|
704
|
-
this.clearSignatureButton.removeEventListener('click', () =>
|
|
705
|
-
this.clearSignature(),
|
|
706
|
-
),
|
|
707
|
-
this.uploadSignatureButton.removeEventListener('change', (t) =>
|
|
708
|
-
this.uploadSignature(t),
|
|
709
|
-
));
|
|
710
|
-
}
|
|
711
|
-
resizeCanvas() {
|
|
712
|
-
let t = this.shadowRoot.querySelector('canvas'),
|
|
713
|
-
e = Math.max(window.devicePixelRatio || 1, 1);
|
|
714
|
-
((t.width = (t.offsetWidth || t.width) * e),
|
|
715
|
-
(t.height = (t.offsetHeight || t.height) * e),
|
|
716
|
-
t.getContext('2d').scale(e, e),
|
|
717
|
-
this.core.fromData(this.core.toData()));
|
|
718
|
-
}
|
|
719
|
-
publishSignature() {
|
|
720
|
-
try {
|
|
721
|
-
this.resetErrorMessage();
|
|
722
|
-
let t = this.shadowRoot.querySelector('img'),
|
|
723
|
-
e = t ? t.src : void 0;
|
|
724
|
-
if (
|
|
725
|
-
(!e &&
|
|
726
|
-
!this.core.isEmpty() &&
|
|
727
|
-
(e = this.core.toDataURL('image/svg+xml')),
|
|
728
|
-
e)
|
|
729
|
-
)
|
|
730
|
-
this.dispatchEvent(
|
|
731
|
-
new CustomEvent('signature-pad.publish', { detail: e }),
|
|
732
|
-
);
|
|
733
|
-
else
|
|
734
|
-
throw new Error(
|
|
735
|
-
'No signature present. '.concat(
|
|
736
|
-
this.allowUpload ? 'Draw or upload' : 'Draw',
|
|
737
|
-
' a signature',
|
|
738
|
-
),
|
|
739
|
-
);
|
|
740
|
-
} catch (t) {
|
|
741
|
-
this.handleError(t.message);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
resetErrorMessage() {
|
|
745
|
-
this.errorMessage.textContent = '';
|
|
746
|
-
}
|
|
747
|
-
handleError(t) {
|
|
748
|
-
this.errorMessage.textContent = t;
|
|
749
|
-
}
|
|
750
|
-
clearSignature() {
|
|
751
|
-
this.resetErrorMessage();
|
|
752
|
-
let t = this.shadowRoot.querySelector('canvas'),
|
|
753
|
-
e = this.shadowRoot.querySelector('img');
|
|
754
|
-
(e && (e.remove(), t.removeAttribute('hidden')), this.core.clear());
|
|
755
|
-
}
|
|
756
|
-
previewUpload(t) {
|
|
757
|
-
let e = this.shadowRoot.querySelector('canvas'),
|
|
758
|
-
i = this.shadowRoot.querySelector('img');
|
|
759
|
-
(i || (i = document.createElement('img')),
|
|
760
|
-
(i.src = t),
|
|
761
|
-
i.setAttribute('part', 'upload-preview-image'),
|
|
762
|
-
e.setAttribute('hidden', !0),
|
|
763
|
-
e.insertAdjacentElement('afterend', i));
|
|
764
|
-
}
|
|
765
|
-
async uploadSignature(t) {
|
|
766
|
-
try {
|
|
767
|
-
this.resetErrorMessage();
|
|
768
|
-
let { files: e } = t.target,
|
|
769
|
-
i = await E.retrieve(e);
|
|
770
|
-
this.previewUpload(i);
|
|
771
|
-
} catch (e) {
|
|
772
|
-
this.handleError(e.message);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
get allowUpload() {
|
|
776
|
-
return this.hasAttribute('allow-upload');
|
|
777
|
-
}
|
|
778
|
-
get themeColor() {
|
|
779
|
-
return this.getAttribute('theme-color') || '#001096';
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
'customElements' in window &&
|
|
783
|
-
!window.customElements.get('smileid-signature-pad') &&
|
|
784
|
-
window.customElements.define('smileid-signature-pad', _);
|
|
785
|
-
var P = _;
|
|
786
|
-
var z = P;
|
|
787
|
-
})();
|
|
788
|
-
/*! Bundled license information:
|
|
789
|
-
|
|
790
|
-
signature_pad/dist/signature_pad.js:
|
|
791
|
-
(*!
|
|
792
|
-
* Signature Pad v5.0.2 | https://github.com/szimek/signature_pad
|
|
793
|
-
* (c) 2024 Szymon Nowak | Released under the MIT license
|
|
794
|
-
*)
|
|
795
|
-
*/
|
|
796
|
-
//# sourceMappingURL=index.js.map
|