@popsure/dirty-swan 0.33.0 → 0.33.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/cjs/index.js +71 -67
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/App.d.ts +3 -0
- package/dist/esm/_commonjsHelpers-e7f67fd8.js +23 -0
- package/dist/esm/_commonjsHelpers-e7f67fd8.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.js +2062 -0
- package/dist/esm/components/autocompleteAddress/index.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.stories.js +110 -0
- package/dist/esm/components/autocompleteAddress/index.stories.js.map +1 -0
- package/dist/esm/components/autocompleteAddress/index.test.js +115 -0
- package/dist/esm/components/autocompleteAddress/index.test.js.map +1 -0
- package/dist/esm/components/button/index.js +26 -0
- package/dist/esm/components/button/index.js.map +1 -0
- package/dist/esm/components/cards/cardButton/index.js +6 -0
- package/dist/esm/components/cards/cardButton/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +7 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js.map +1 -0
- package/dist/esm/components/cards/index.js +125 -0
- package/dist/esm/components/cards/index.js.map +1 -0
- package/dist/esm/components/cards/infoCard/index.js +7 -0
- package/dist/esm/components/cards/infoCard/index.js.map +1 -0
- package/dist/esm/components/chip/index.js +22 -0
- package/dist/esm/components/chip/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +32 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js +8 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/Chevron.js +10 -0
- package/dist/esm/components/comparisonTable/components/Chevron.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/Row/index.js +36 -0
- package/dist/esm/components/comparisonTable/components/Row/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js +24 -0
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.js +15 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js +37 -0
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +22 -0
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js +10 -0
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRating/index.js +27 -0
- package/dist/esm/components/comparisonTable/components/TableRating/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js +18 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js +82 -0
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js +13 -0
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js.map +1 -0
- package/dist/esm/components/comparisonTable/index.js +1683 -0
- package/dist/esm/components/comparisonTable/index.js.map +1 -0
- package/dist/esm/components/dateSelector/index.js +2180 -0
- package/dist/esm/components/dateSelector/index.js.map +1 -0
- package/dist/esm/components/dateSelector/index.test.js +65 -0
- package/dist/esm/components/dateSelector/index.test.js.map +1 -0
- package/dist/esm/components/downloadButton/index.js +36 -0
- package/dist/esm/components/downloadButton/index.js.map +1 -0
- package/dist/esm/components/downloadButton/index.stories.js +47 -0
- package/dist/esm/components/downloadButton/index.stories.js.map +1 -0
- package/dist/esm/components/input/autoSuggestInput/index.js +2157 -0
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js +41 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.js +58 -0
- package/dist/esm/components/input/checkbox/index.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.stories.js +154 -0
- package/dist/esm/components/input/checkbox/index.stories.js.map +1 -0
- package/dist/esm/components/input/checkbox/index.test.js +106 -0
- package/dist/esm/components/input/checkbox/index.test.js.map +1 -0
- package/dist/esm/components/input/currency/index.js +63 -0
- package/dist/esm/components/input/currency/index.js.map +1 -0
- package/dist/esm/components/input/currency/index.test.js +209 -0
- package/dist/esm/components/input/currency/index.test.js.map +1 -0
- package/dist/esm/components/input/iban/index.js +33 -0
- package/dist/esm/components/input/iban/index.js.map +1 -0
- package/dist/esm/components/input/index.js +29 -0
- package/dist/esm/components/input/index.js.map +1 -0
- package/dist/esm/components/markdown/index.js +22178 -0
- package/dist/esm/components/markdown/index.js.map +1 -0
- package/dist/esm/components/markdown/index.stories.js +66 -0
- package/dist/esm/components/markdown/index.stories.js.map +1 -0
- package/dist/esm/components/modal/bottomModal/index.js +35 -0
- package/dist/esm/components/modal/bottomModal/index.js.map +1 -0
- package/dist/esm/components/modal/bottomOrRegularModal/index.js +36 -0
- package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +1 -0
- package/dist/esm/components/modal/regularModal/index.js +28 -0
- package/dist/esm/components/modal/regularModal/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js +6 -0
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/index.js +2862 -0
- package/dist/esm/components/multiDropzone/index.js.map +1 -0
- package/dist/esm/components/multiDropzone/index.test.js +201 -0
- package/dist/esm/components/multiDropzone/index.test.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.js +42 -0
- package/dist/esm/components/segmentedControl/index.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.stories.js +62 -0
- package/dist/esm/components/segmentedControl/index.stories.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.test.js +63 -0
- package/dist/esm/components/segmentedControl/index.test.js.map +1 -0
- package/dist/esm/components/signaturePad/index.js +560 -0
- package/dist/esm/components/signaturePad/index.js.map +1 -0
- package/dist/esm/components/signaturePad/index.stories.js +33 -0
- package/dist/esm/components/signaturePad/index.stories.js.map +1 -0
- package/dist/esm/customRender-4157fcff.js +24102 -0
- package/dist/esm/customRender-4157fcff.js.map +1 -0
- package/dist/esm/extend-expect-46bdce4a.js +7406 -0
- package/dist/esm/extend-expect-46bdce4a.js.map +1 -0
- package/dist/esm/index-1463d5e9.js +382 -0
- package/dist/esm/index-1463d5e9.js.map +1 -0
- package/dist/esm/index-171a0108.js +997 -0
- package/dist/esm/index-171a0108.js.map +1 -0
- package/dist/esm/index-21239ab0.js +237 -0
- package/dist/esm/index-21239ab0.js.map +1 -0
- package/dist/esm/index-47663d39.js +48 -0
- package/dist/esm/index-47663d39.js.map +1 -0
- package/dist/esm/index-6ced5532.js +69 -0
- package/dist/esm/index-6ced5532.js.map +1 -0
- package/dist/esm/index-db2e797f.js +13 -0
- package/dist/esm/index-db2e797f.js.map +1 -0
- package/dist/esm/index-dd80248b.js +91 -0
- package/dist/esm/index-dd80248b.js.map +1 -0
- package/dist/esm/index-e9e37a34.js +62 -0
- package/dist/esm/index-e9e37a34.js.map +1 -0
- package/dist/esm/index-fb46adf9.js +12 -0
- package/dist/esm/index-fb46adf9.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/components/autocompleteAddress/index.d.ts +20 -0
- package/dist/esm/lib/components/autocompleteAddress/index.stories.d.ts +66 -0
- package/dist/esm/lib/components/autocompleteAddress/index.test.d.ts +1 -0
- package/dist/esm/lib/components/autocompleteAddress/mapStyle.d.ts +2 -0
- package/dist/esm/lib/components/autocompleteAddress/util/index.d.ts +4 -0
- package/dist/esm/lib/components/button/icons/index.d.ts +9 -0
- package/dist/esm/lib/components/button/index.d.ts +13 -0
- package/dist/esm/lib/components/cards/cardButton/index.d.ts +16 -0
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +14 -0
- package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +15 -0
- package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +14 -0
- package/dist/esm/lib/components/cards/icons/index.d.ts +13 -0
- package/dist/esm/lib/components/cards/index.d.ts +16 -0
- package/dist/esm/lib/components/cards/infoCard/index.d.ts +13 -0
- package/dist/esm/lib/components/chip/index.d.ts +6 -0
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +9 -0
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/index.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/Chevron.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/Row/index.d.ts +11 -0
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/Arrow.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/index.d.ts +10 -0
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.d.ts +8 -0
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.test.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/TableInfoButton/index.d.ts +5 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/StarIcon.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/ZapIcon.d.ts +4 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRating/index.d.ts +7 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.d.ts +9 -0
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.test.d.ts +1 -0
- package/dist/esm/lib/components/comparisonTable/components/TableTrueFalse.d.ts +5 -0
- package/dist/esm/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +14 -0
- package/dist/esm/lib/components/comparisonTable/index.d.ts +52 -0
- package/dist/esm/lib/components/dateSelector/index.d.ts +23 -0
- package/dist/esm/lib/components/dateSelector/index.test.d.ts +1 -0
- package/dist/esm/lib/components/downloadButton/index.d.ts +10 -0
- package/dist/esm/lib/components/downloadButton/index.stories.d.ts +36 -0
- package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +15 -0
- package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.d.ts +11 -0
- package/dist/esm/lib/components/input/checkbox/index.d.ts +17 -0
- package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +64 -0
- package/dist/esm/lib/components/input/checkbox/index.test.d.ts +1 -0
- package/dist/esm/lib/components/input/currency/format/index.d.ts +2 -0
- package/dist/esm/lib/components/input/currency/index.d.ts +7 -0
- package/dist/esm/lib/components/input/currency/index.test.d.ts +1 -0
- package/dist/esm/lib/components/input/iban/formatIban/index.d.ts +1 -0
- package/dist/esm/lib/components/input/iban/index.d.ts +6 -0
- package/dist/esm/lib/components/input/index.d.ts +16 -0
- package/dist/esm/lib/components/markdown/index.d.ts +10 -0
- package/dist/esm/lib/components/markdown/index.stories.d.ts +44 -0
- package/dist/esm/lib/components/modal/bottomModal/index.d.ts +3 -0
- package/dist/esm/lib/components/modal/bottomOrRegularModal/index.d.ts +3 -0
- package/dist/esm/lib/components/modal/hooks/useOnClose.d.ts +9 -0
- package/dist/esm/lib/components/modal/index.d.ts +13 -0
- package/dist/esm/lib/components/modal/regularModal/index.d.ts +3 -0
- package/dist/esm/lib/components/multiDropzone/UploadFileCell/index.d.ts +10 -0
- package/dist/esm/lib/components/multiDropzone/icons/index.d.ts +11 -0
- package/dist/esm/lib/components/multiDropzone/index.d.ts +15 -0
- package/dist/esm/lib/components/multiDropzone/index.test.d.ts +1 -0
- package/dist/esm/lib/components/multiDropzone/types.d.ts +42 -0
- package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +11 -0
- package/dist/esm/lib/components/segmentedControl/index.d.ts +12 -0
- package/dist/esm/lib/components/segmentedControl/index.stories.d.ts +37 -0
- package/dist/esm/lib/components/segmentedControl/index.test.d.ts +1 -0
- package/dist/esm/lib/components/signaturePad/index.d.ts +19 -0
- package/dist/esm/lib/components/signaturePad/index.stories.d.ts +21 -0
- package/dist/esm/lib/hooks/useOnClickOutside.d.ts +2 -0
- package/dist/esm/lib/index.d.ts +22 -0
- package/dist/esm/lib/models/autoSuggestInput/index.d.ts +4 -0
- package/dist/esm/lib/models/download.d.ts +1 -0
- package/dist/esm/lib/scss/private/base/demo.d.ts +5 -0
- package/dist/esm/lib/scss/public/demo.d.ts +2 -0
- package/dist/esm/lib/util/calendarDate/index.d.ts +3 -0
- package/dist/esm/lib/util/formatBytes/index.d.ts +1 -0
- package/dist/esm/lib/util/generateId/index.d.ts +2 -0
- package/dist/esm/lib/util/images/index.d.ts +11 -0
- package/dist/esm/lib/util/images/index.stories.d.ts +12 -0
- package/dist/esm/lib/util/testUtils/customRender.d.ts +7 -0
- package/dist/esm/lib/util/testUtils/index.d.ts +2 -0
- package/dist/esm/lib/util/zeroFill.d.ts +1 -0
- package/dist/esm/mapStyle-1288a869.js +187 -0
- package/dist/esm/mapStyle-1288a869.js.map +1 -0
- package/dist/esm/scss/private/base/demo.js +80 -0
- package/dist/esm/scss/private/base/demo.js.map +1 -0
- package/dist/esm/scss/public/demo.js +290 -0
- package/dist/esm/scss/public/demo.js.map +1 -0
- package/dist/esm/style-inject.es-1f59c1d0.js +29 -0
- package/dist/esm/style-inject.es-1f59c1d0.js.map +1 -0
- package/dist/esm/tslib.es6-5bc94358.js +104 -0
- package/dist/esm/tslib.es6-5bc94358.js.map +1 -0
- package/dist/esm/useOnClose-d818a54f.js +46 -0
- package/dist/esm/useOnClose-d818a54f.js.map +1 -0
- package/dist/esm/util/images/index.stories.js +23 -0
- package/dist/esm/util/images/index.stories.js.map +1 -0
- package/dist/esm/util/testUtils/customRender.js +7 -0
- package/dist/esm/util/testUtils/customRender.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/components/input/checkbox/index.tsx +2 -1
- package/src/lib/components/input/checkbox/styles.module.scss +3 -0
- package/src/lib/components/markdown/index.stories.tsx +64 -2
- package/src/global.d.ts +0 -1
- package/src/lib/components/markdown/example.md +0 -78
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import { e as __extends, _ as __assign } from '../../tslib.es6-5bc94358.js';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import React__default, { Component } from 'react';
|
|
4
|
+
import { s as styleInject } from '../../style-inject.es-1f59c1d0.js';
|
|
5
|
+
|
|
6
|
+
/*!
|
|
7
|
+
* Signature Pad v3.0.0-beta.4 | https://github.com/szimek/signature_pad
|
|
8
|
+
* (c) 2020 Szymon Nowak | Released under the MIT license
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
class Point {
|
|
12
|
+
constructor(x, y, time) {
|
|
13
|
+
this.x = x;
|
|
14
|
+
this.y = y;
|
|
15
|
+
this.time = time || Date.now();
|
|
16
|
+
}
|
|
17
|
+
distanceTo(start) {
|
|
18
|
+
return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
|
|
19
|
+
}
|
|
20
|
+
equals(other) {
|
|
21
|
+
return this.x === other.x && this.y === other.y && this.time === other.time;
|
|
22
|
+
}
|
|
23
|
+
velocityFrom(start) {
|
|
24
|
+
return this.time !== start.time
|
|
25
|
+
? this.distanceTo(start) / (this.time - start.time)
|
|
26
|
+
: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class Bezier {
|
|
31
|
+
constructor(startPoint, control2, control1, endPoint, startWidth, endWidth) {
|
|
32
|
+
this.startPoint = startPoint;
|
|
33
|
+
this.control2 = control2;
|
|
34
|
+
this.control1 = control1;
|
|
35
|
+
this.endPoint = endPoint;
|
|
36
|
+
this.startWidth = startWidth;
|
|
37
|
+
this.endWidth = endWidth;
|
|
38
|
+
}
|
|
39
|
+
static fromPoints(points, widths) {
|
|
40
|
+
const c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
|
|
41
|
+
const c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
|
|
42
|
+
return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
|
|
43
|
+
}
|
|
44
|
+
static calculateControlPoints(s1, s2, s3) {
|
|
45
|
+
const dx1 = s1.x - s2.x;
|
|
46
|
+
const dy1 = s1.y - s2.y;
|
|
47
|
+
const dx2 = s2.x - s3.x;
|
|
48
|
+
const dy2 = s2.y - s3.y;
|
|
49
|
+
const m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
|
|
50
|
+
const m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
|
|
51
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
52
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
53
|
+
const dxm = m1.x - m2.x;
|
|
54
|
+
const dym = m1.y - m2.y;
|
|
55
|
+
const k = l2 / (l1 + l2);
|
|
56
|
+
const cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
|
57
|
+
const tx = s2.x - cm.x;
|
|
58
|
+
const ty = s2.y - cm.y;
|
|
59
|
+
return {
|
|
60
|
+
c1: new Point(m1.x + tx, m1.y + ty),
|
|
61
|
+
c2: new Point(m2.x + tx, m2.y + ty),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
length() {
|
|
65
|
+
const steps = 10;
|
|
66
|
+
let length = 0;
|
|
67
|
+
let px;
|
|
68
|
+
let py;
|
|
69
|
+
for (let i = 0; i <= steps; i += 1) {
|
|
70
|
+
const t = i / steps;
|
|
71
|
+
const cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
|
|
72
|
+
const cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
|
|
73
|
+
if (i > 0) {
|
|
74
|
+
const xdiff = cx - px;
|
|
75
|
+
const ydiff = cy - py;
|
|
76
|
+
length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
|
|
77
|
+
}
|
|
78
|
+
px = cx;
|
|
79
|
+
py = cy;
|
|
80
|
+
}
|
|
81
|
+
return length;
|
|
82
|
+
}
|
|
83
|
+
point(t, start, c1, c2, end) {
|
|
84
|
+
return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
|
|
85
|
+
+ (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
|
|
86
|
+
+ (3.0 * c2 * (1.0 - t) * t * t)
|
|
87
|
+
+ (end * t * t * t);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function throttle(fn, wait = 250) {
|
|
92
|
+
let previous = 0;
|
|
93
|
+
let timeout = null;
|
|
94
|
+
let result;
|
|
95
|
+
let storedContext;
|
|
96
|
+
let storedArgs;
|
|
97
|
+
const later = () => {
|
|
98
|
+
previous = Date.now();
|
|
99
|
+
timeout = null;
|
|
100
|
+
result = fn.apply(storedContext, storedArgs);
|
|
101
|
+
if (!timeout) {
|
|
102
|
+
storedContext = null;
|
|
103
|
+
storedArgs = [];
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return function wrapper(...args) {
|
|
107
|
+
const now = Date.now();
|
|
108
|
+
const remaining = wait - (now - previous);
|
|
109
|
+
storedContext = this;
|
|
110
|
+
storedArgs = args;
|
|
111
|
+
if (remaining <= 0 || remaining > wait) {
|
|
112
|
+
if (timeout) {
|
|
113
|
+
clearTimeout(timeout);
|
|
114
|
+
timeout = null;
|
|
115
|
+
}
|
|
116
|
+
previous = now;
|
|
117
|
+
result = fn.apply(storedContext, storedArgs);
|
|
118
|
+
if (!timeout) {
|
|
119
|
+
storedContext = null;
|
|
120
|
+
storedArgs = [];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (!timeout) {
|
|
124
|
+
timeout = window.setTimeout(later, remaining);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class SignaturePad$1 {
|
|
131
|
+
constructor(canvas, options = {}) {
|
|
132
|
+
this.canvas = canvas;
|
|
133
|
+
this.options = options;
|
|
134
|
+
this._handleMouseDown = (event) => {
|
|
135
|
+
if (event.which === 1) {
|
|
136
|
+
this._mouseButtonDown = true;
|
|
137
|
+
this._strokeBegin(event);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
this._handleMouseMove = (event) => {
|
|
141
|
+
if (this._mouseButtonDown) {
|
|
142
|
+
this._strokeMoveUpdate(event);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
this._handleMouseUp = (event) => {
|
|
146
|
+
if (event.which === 1 && this._mouseButtonDown) {
|
|
147
|
+
this._mouseButtonDown = false;
|
|
148
|
+
this._strokeEnd(event);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
this._handleTouchStart = (event) => {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
if (event.targetTouches.length === 1) {
|
|
154
|
+
const touch = event.changedTouches[0];
|
|
155
|
+
this._strokeBegin(touch);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
this._handleTouchMove = (event) => {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
const touch = event.targetTouches[0];
|
|
161
|
+
this._strokeMoveUpdate(touch);
|
|
162
|
+
};
|
|
163
|
+
this._handleTouchEnd = (event) => {
|
|
164
|
+
const wasCanvasTouched = event.target === this.canvas;
|
|
165
|
+
if (wasCanvasTouched) {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
const touch = event.changedTouches[0];
|
|
168
|
+
this._strokeEnd(touch);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
this.velocityFilterWeight = options.velocityFilterWeight || 0.7;
|
|
172
|
+
this.minWidth = options.minWidth || 0.5;
|
|
173
|
+
this.maxWidth = options.maxWidth || 2.5;
|
|
174
|
+
this.throttle = ('throttle' in options ? options.throttle : 16);
|
|
175
|
+
this.minDistance = ('minDistance' in options
|
|
176
|
+
? options.minDistance
|
|
177
|
+
: 5);
|
|
178
|
+
this.dotSize =
|
|
179
|
+
options.dotSize ||
|
|
180
|
+
function dotSize() {
|
|
181
|
+
return (this.minWidth + this.maxWidth) / 2;
|
|
182
|
+
};
|
|
183
|
+
this.penColor = options.penColor || 'black';
|
|
184
|
+
this.backgroundColor = options.backgroundColor || 'rgba(0,0,0,0)';
|
|
185
|
+
this.onBegin = options.onBegin;
|
|
186
|
+
this.onEnd = options.onEnd;
|
|
187
|
+
this._strokeMoveUpdate = this.throttle
|
|
188
|
+
? throttle(SignaturePad$1.prototype._strokeUpdate, this.throttle)
|
|
189
|
+
: SignaturePad$1.prototype._strokeUpdate;
|
|
190
|
+
this._ctx = canvas.getContext('2d');
|
|
191
|
+
this.clear();
|
|
192
|
+
this.on();
|
|
193
|
+
}
|
|
194
|
+
clear() {
|
|
195
|
+
const { _ctx: ctx, canvas } = this;
|
|
196
|
+
ctx.fillStyle = this.backgroundColor;
|
|
197
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
198
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
199
|
+
this._data = [];
|
|
200
|
+
this._reset();
|
|
201
|
+
this._isEmpty = true;
|
|
202
|
+
}
|
|
203
|
+
fromDataURL(dataUrl, options = {}, callback) {
|
|
204
|
+
const image = new Image();
|
|
205
|
+
const ratio = options.ratio || window.devicePixelRatio || 1;
|
|
206
|
+
const width = options.width || this.canvas.width / ratio;
|
|
207
|
+
const height = options.height || this.canvas.height / ratio;
|
|
208
|
+
this._reset();
|
|
209
|
+
image.onload = () => {
|
|
210
|
+
this._ctx.drawImage(image, 0, 0, width, height);
|
|
211
|
+
if (callback) {
|
|
212
|
+
callback();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
image.onerror = (error) => {
|
|
216
|
+
if (callback) {
|
|
217
|
+
callback(error);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
image.src = dataUrl;
|
|
221
|
+
this._isEmpty = false;
|
|
222
|
+
}
|
|
223
|
+
toDataURL(type = 'image/png', encoderOptions) {
|
|
224
|
+
switch (type) {
|
|
225
|
+
case 'image/svg+xml':
|
|
226
|
+
return this._toSVG();
|
|
227
|
+
default:
|
|
228
|
+
return this.canvas.toDataURL(type, encoderOptions);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
on() {
|
|
232
|
+
this.canvas.style.touchAction = 'none';
|
|
233
|
+
this.canvas.style.msTouchAction = 'none';
|
|
234
|
+
if (window.PointerEvent) {
|
|
235
|
+
this._handlePointerEvents();
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this._handleMouseEvents();
|
|
239
|
+
if ('ontouchstart' in window) {
|
|
240
|
+
this._handleTouchEvents();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
off() {
|
|
245
|
+
this.canvas.style.touchAction = 'auto';
|
|
246
|
+
this.canvas.style.msTouchAction = 'auto';
|
|
247
|
+
this.canvas.removeEventListener('pointerdown', this._handleMouseDown);
|
|
248
|
+
this.canvas.removeEventListener('pointermove', this._handleMouseMove);
|
|
249
|
+
document.removeEventListener('pointerup', this._handleMouseUp);
|
|
250
|
+
this.canvas.removeEventListener('mousedown', this._handleMouseDown);
|
|
251
|
+
this.canvas.removeEventListener('mousemove', this._handleMouseMove);
|
|
252
|
+
document.removeEventListener('mouseup', this._handleMouseUp);
|
|
253
|
+
this.canvas.removeEventListener('touchstart', this._handleTouchStart);
|
|
254
|
+
this.canvas.removeEventListener('touchmove', this._handleTouchMove);
|
|
255
|
+
this.canvas.removeEventListener('touchend', this._handleTouchEnd);
|
|
256
|
+
}
|
|
257
|
+
isEmpty() {
|
|
258
|
+
return this._isEmpty;
|
|
259
|
+
}
|
|
260
|
+
fromData(pointGroups) {
|
|
261
|
+
this.clear();
|
|
262
|
+
this._fromData(pointGroups, ({ color, curve }) => this._drawCurve({ color, curve }), ({ color, point }) => this._drawDot({ color, point }));
|
|
263
|
+
this._data = pointGroups;
|
|
264
|
+
}
|
|
265
|
+
toData() {
|
|
266
|
+
return this._data;
|
|
267
|
+
}
|
|
268
|
+
_strokeBegin(event) {
|
|
269
|
+
const newPointGroup = {
|
|
270
|
+
color: this.penColor,
|
|
271
|
+
points: [],
|
|
272
|
+
};
|
|
273
|
+
if (typeof this.onBegin === 'function') {
|
|
274
|
+
this.onBegin(event);
|
|
275
|
+
}
|
|
276
|
+
this._data.push(newPointGroup);
|
|
277
|
+
this._reset();
|
|
278
|
+
this._strokeUpdate(event);
|
|
279
|
+
}
|
|
280
|
+
_strokeUpdate(event) {
|
|
281
|
+
if (this._data.length === 0) {
|
|
282
|
+
this._strokeBegin(event);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const x = event.clientX;
|
|
286
|
+
const y = event.clientY;
|
|
287
|
+
const point = this._createPoint(x, y);
|
|
288
|
+
const lastPointGroup = this._data[this._data.length - 1];
|
|
289
|
+
const lastPoints = lastPointGroup.points;
|
|
290
|
+
const lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
|
|
291
|
+
const isLastPointTooClose = lastPoint
|
|
292
|
+
? point.distanceTo(lastPoint) <= this.minDistance
|
|
293
|
+
: false;
|
|
294
|
+
const color = lastPointGroup.color;
|
|
295
|
+
if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
|
|
296
|
+
const curve = this._addPoint(point);
|
|
297
|
+
if (!lastPoint) {
|
|
298
|
+
this._drawDot({ color, point });
|
|
299
|
+
}
|
|
300
|
+
else if (curve) {
|
|
301
|
+
this._drawCurve({ color, curve });
|
|
302
|
+
}
|
|
303
|
+
lastPoints.push({
|
|
304
|
+
time: point.time,
|
|
305
|
+
x: point.x,
|
|
306
|
+
y: point.y,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
_strokeEnd(event) {
|
|
311
|
+
this._strokeUpdate(event);
|
|
312
|
+
if (typeof this.onEnd === 'function') {
|
|
313
|
+
this.onEnd(event);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
_handlePointerEvents() {
|
|
317
|
+
this._mouseButtonDown = false;
|
|
318
|
+
this.canvas.addEventListener('pointerdown', this._handleMouseDown);
|
|
319
|
+
this.canvas.addEventListener('pointermove', this._handleMouseMove);
|
|
320
|
+
document.addEventListener('pointerup', this._handleMouseUp);
|
|
321
|
+
}
|
|
322
|
+
_handleMouseEvents() {
|
|
323
|
+
this._mouseButtonDown = false;
|
|
324
|
+
this.canvas.addEventListener('mousedown', this._handleMouseDown);
|
|
325
|
+
this.canvas.addEventListener('mousemove', this._handleMouseMove);
|
|
326
|
+
document.addEventListener('mouseup', this._handleMouseUp);
|
|
327
|
+
}
|
|
328
|
+
_handleTouchEvents() {
|
|
329
|
+
this.canvas.addEventListener('touchstart', this._handleTouchStart);
|
|
330
|
+
this.canvas.addEventListener('touchmove', this._handleTouchMove);
|
|
331
|
+
this.canvas.addEventListener('touchend', this._handleTouchEnd);
|
|
332
|
+
}
|
|
333
|
+
_reset() {
|
|
334
|
+
this._lastPoints = [];
|
|
335
|
+
this._lastVelocity = 0;
|
|
336
|
+
this._lastWidth = (this.minWidth + this.maxWidth) / 2;
|
|
337
|
+
this._ctx.fillStyle = this.penColor;
|
|
338
|
+
}
|
|
339
|
+
_createPoint(x, y) {
|
|
340
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
341
|
+
return new Point(x - rect.left, y - rect.top, new Date().getTime());
|
|
342
|
+
}
|
|
343
|
+
_addPoint(point) {
|
|
344
|
+
const { _lastPoints } = this;
|
|
345
|
+
_lastPoints.push(point);
|
|
346
|
+
if (_lastPoints.length > 2) {
|
|
347
|
+
if (_lastPoints.length === 3) {
|
|
348
|
+
_lastPoints.unshift(_lastPoints[0]);
|
|
349
|
+
}
|
|
350
|
+
const widths = this._calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
|
|
351
|
+
const curve = Bezier.fromPoints(_lastPoints, widths);
|
|
352
|
+
_lastPoints.shift();
|
|
353
|
+
return curve;
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
_calculateCurveWidths(startPoint, endPoint) {
|
|
358
|
+
const velocity = this.velocityFilterWeight * endPoint.velocityFrom(startPoint) +
|
|
359
|
+
(1 - this.velocityFilterWeight) * this._lastVelocity;
|
|
360
|
+
const newWidth = this._strokeWidth(velocity);
|
|
361
|
+
const widths = {
|
|
362
|
+
end: newWidth,
|
|
363
|
+
start: this._lastWidth,
|
|
364
|
+
};
|
|
365
|
+
this._lastVelocity = velocity;
|
|
366
|
+
this._lastWidth = newWidth;
|
|
367
|
+
return widths;
|
|
368
|
+
}
|
|
369
|
+
_strokeWidth(velocity) {
|
|
370
|
+
return Math.max(this.maxWidth / (velocity + 1), this.minWidth);
|
|
371
|
+
}
|
|
372
|
+
_drawCurveSegment(x, y, width) {
|
|
373
|
+
const ctx = this._ctx;
|
|
374
|
+
ctx.moveTo(x, y);
|
|
375
|
+
ctx.arc(x, y, width, 0, 2 * Math.PI, false);
|
|
376
|
+
this._isEmpty = false;
|
|
377
|
+
}
|
|
378
|
+
_drawCurve({ color, curve }) {
|
|
379
|
+
const ctx = this._ctx;
|
|
380
|
+
const widthDelta = curve.endWidth - curve.startWidth;
|
|
381
|
+
const drawSteps = Math.floor(curve.length()) * 2;
|
|
382
|
+
ctx.beginPath();
|
|
383
|
+
ctx.fillStyle = color;
|
|
384
|
+
for (let i = 0; i < drawSteps; i += 1) {
|
|
385
|
+
const t = i / drawSteps;
|
|
386
|
+
const tt = t * t;
|
|
387
|
+
const ttt = tt * t;
|
|
388
|
+
const u = 1 - t;
|
|
389
|
+
const uu = u * u;
|
|
390
|
+
const uuu = uu * u;
|
|
391
|
+
let x = uuu * curve.startPoint.x;
|
|
392
|
+
x += 3 * uu * t * curve.control1.x;
|
|
393
|
+
x += 3 * u * tt * curve.control2.x;
|
|
394
|
+
x += ttt * curve.endPoint.x;
|
|
395
|
+
let y = uuu * curve.startPoint.y;
|
|
396
|
+
y += 3 * uu * t * curve.control1.y;
|
|
397
|
+
y += 3 * u * tt * curve.control2.y;
|
|
398
|
+
y += ttt * curve.endPoint.y;
|
|
399
|
+
const width = Math.min(curve.startWidth + ttt * widthDelta, this.maxWidth);
|
|
400
|
+
this._drawCurveSegment(x, y, width);
|
|
401
|
+
}
|
|
402
|
+
ctx.closePath();
|
|
403
|
+
ctx.fill();
|
|
404
|
+
}
|
|
405
|
+
_drawDot({ color, point, }) {
|
|
406
|
+
const ctx = this._ctx;
|
|
407
|
+
const width = typeof this.dotSize === 'function' ? this.dotSize() : this.dotSize;
|
|
408
|
+
ctx.beginPath();
|
|
409
|
+
this._drawCurveSegment(point.x, point.y, width);
|
|
410
|
+
ctx.closePath();
|
|
411
|
+
ctx.fillStyle = color;
|
|
412
|
+
ctx.fill();
|
|
413
|
+
}
|
|
414
|
+
_fromData(pointGroups, drawCurve, drawDot) {
|
|
415
|
+
for (const group of pointGroups) {
|
|
416
|
+
const { color, points } = group;
|
|
417
|
+
if (points.length > 1) {
|
|
418
|
+
for (let j = 0; j < points.length; j += 1) {
|
|
419
|
+
const basicPoint = points[j];
|
|
420
|
+
const point = new Point(basicPoint.x, basicPoint.y, basicPoint.time);
|
|
421
|
+
this.penColor = color;
|
|
422
|
+
if (j === 0) {
|
|
423
|
+
this._reset();
|
|
424
|
+
}
|
|
425
|
+
const curve = this._addPoint(point);
|
|
426
|
+
if (curve) {
|
|
427
|
+
drawCurve({ color, curve });
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this._reset();
|
|
433
|
+
drawDot({
|
|
434
|
+
color,
|
|
435
|
+
point: points[0],
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
_toSVG() {
|
|
441
|
+
const pointGroups = this._data;
|
|
442
|
+
const ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
443
|
+
const minX = 0;
|
|
444
|
+
const minY = 0;
|
|
445
|
+
const maxX = this.canvas.width / ratio;
|
|
446
|
+
const maxY = this.canvas.height / ratio;
|
|
447
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
448
|
+
svg.setAttribute('width', this.canvas.width.toString());
|
|
449
|
+
svg.setAttribute('height', this.canvas.height.toString());
|
|
450
|
+
this._fromData(pointGroups, ({ color, curve }) => {
|
|
451
|
+
const path = document.createElement('path');
|
|
452
|
+
if (!isNaN(curve.control1.x) &&
|
|
453
|
+
!isNaN(curve.control1.y) &&
|
|
454
|
+
!isNaN(curve.control2.x) &&
|
|
455
|
+
!isNaN(curve.control2.y)) {
|
|
456
|
+
const attr = `M ${curve.startPoint.x.toFixed(3)},${curve.startPoint.y.toFixed(3)} ` +
|
|
457
|
+
`C ${curve.control1.x.toFixed(3)},${curve.control1.y.toFixed(3)} ` +
|
|
458
|
+
`${curve.control2.x.toFixed(3)},${curve.control2.y.toFixed(3)} ` +
|
|
459
|
+
`${curve.endPoint.x.toFixed(3)},${curve.endPoint.y.toFixed(3)}`;
|
|
460
|
+
path.setAttribute('d', attr);
|
|
461
|
+
path.setAttribute('stroke-width', (curve.endWidth * 2.25).toFixed(3));
|
|
462
|
+
path.setAttribute('stroke', color);
|
|
463
|
+
path.setAttribute('fill', 'none');
|
|
464
|
+
path.setAttribute('stroke-linecap', 'round');
|
|
465
|
+
svg.appendChild(path);
|
|
466
|
+
}
|
|
467
|
+
}, ({ color, point }) => {
|
|
468
|
+
const circle = document.createElement('circle');
|
|
469
|
+
const dotSize = typeof this.dotSize === 'function' ? this.dotSize() : this.dotSize;
|
|
470
|
+
circle.setAttribute('r', dotSize.toString());
|
|
471
|
+
circle.setAttribute('cx', point.x.toString());
|
|
472
|
+
circle.setAttribute('cy', point.y.toString());
|
|
473
|
+
circle.setAttribute('fill', color);
|
|
474
|
+
svg.appendChild(circle);
|
|
475
|
+
});
|
|
476
|
+
const prefix = 'data:image/svg+xml;base64,';
|
|
477
|
+
const header = '<svg' +
|
|
478
|
+
' xmlns="http://www.w3.org/2000/svg"' +
|
|
479
|
+
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
|
480
|
+
` viewBox="${minX} ${minY} ${maxX} ${maxY}"` +
|
|
481
|
+
` width="${maxX}"` +
|
|
482
|
+
` height="${maxY}"` +
|
|
483
|
+
'>';
|
|
484
|
+
let body = svg.innerHTML;
|
|
485
|
+
if (body === undefined) {
|
|
486
|
+
const dummy = document.createElement('dummy');
|
|
487
|
+
const nodes = svg.childNodes;
|
|
488
|
+
dummy.innerHTML = '';
|
|
489
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
490
|
+
dummy.appendChild(nodes[i].cloneNode(true));
|
|
491
|
+
}
|
|
492
|
+
body = dummy.innerHTML;
|
|
493
|
+
}
|
|
494
|
+
const footer = '</svg>';
|
|
495
|
+
const data = header + body + footer;
|
|
496
|
+
return prefix + btoa(data);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var css_248z = ".style-module_container__1VolG {\n position: relative;\n background-color: var(--ds-grey-200);\n border-radius: 8px;\n height: 272px;\n}\n\n.style-module_canvas__1Q440 {\n width: 100%;\n height: 100%;\n}\n\n.style-module_separator__Fdmnn {\n position: absolute;\n height: 2px;\n right: 112px;\n left: 72px;\n bottom: 32px;\n background-color: var(--ds-grey-400);\n border-radius: 1px;\n}\n\n.style-module_reset__1ePiM {\n display: flex;\n position: absolute;\n right: 16px;\n bottom: 32px;\n color: var(--ds-primary-500);\n cursor: pointer;\n border: none;\n text-decoration: none;\n font-size: 16px;\n line-height: 24px;\n background-color: transparent;\n}\n.style-module_reset__1ePiM:hover {\n color: var(--ds-primary-700);\n}\n.style-module_reset__1ePiM:before {\n content: \"\";\n display: inline-block;\n height: 24px;\n width: 24px;\n mask-repeat: no-repeat;\n mask-position: center;\n background-color: currentColor;\n -webkit-mask-repeat: no-repeat;\n -webkit-mask-position: center;\n -webkit-background-color: currentColor;\n margin-right: 4px;\n}\n.style-module_reset__1ePiM[disabled] {\n color: var(--ds-grey-500);\n}\n\n.style-module_sign__35Gp2 {\n position: absolute;\n bottom: 32px;\n left: 16px;\n height: 24px;\n width: 24px;\n mask-size: 24px 24px;\n mask-repeat: no-repeat;\n mask-position: center;\n -webkit-mask-size: 24px 24px;\n -webkit-mask-repeat: no-repeat;\n -webkit-mask-position: center;\n background-color: var(--ds-grey-500);\n}";
|
|
501
|
+
var styles = {"container":"style-module_container__1VolG","canvas":"style-module_canvas__1Q440","separator":"style-module_separator__Fdmnn","reset":"style-module_reset__1ePiM","sign":"style-module_sign__35Gp2"};
|
|
502
|
+
styleInject(css_248z);
|
|
503
|
+
|
|
504
|
+
var sign = "data:image/svg+xml,%3Csvg%20width%3D%2280%22%20height%3D%2280%22%20viewBox%3D%220%200%2080%2080%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M13.7%203.70001C13.3%204.00001%2013.5%205.10001%2014.1%206.20001C14.7%207.30001%2014.9%209.20001%2014.6%2010.5C14.1%2012.3%2015.3%2014.4%2019.3%2019.7C22.2%2023.4%2025.6%2028%2026.9%2029.8L29.2%2033L23%2039.7C19.7%2043.4%2017.1%2046.9%2017.4%2047.6C17.7%2048.3%2017.2%2049.4%2016.4%2050C14.8%2051.4%2014.5%2054%2016.1%2054C17.5%2054%2023.6%2049.5%2029%2044.4L33.5%2040.1L41%2051.3C49.2%2063.6%2053.7%2069%2055.8%2069C56.6%2069%2056.8%2068.5%2056.4%2067.7C56%2067.1%2057.8%2068.9%2060.5%2071.8C63.1%2074.7%2065.5%2076.9%2065.7%2076.6C65.9%2076.4%2065.2%2074.4%2064.1%2072.1C62.9%2069.9%2062%2067.2%2062%2066.2C62%2063.3%2054.5%2047.6%2048.9%2039C46.2%2034.8%2044%2031%2044%2030.6C44%2030.2%2046.2%2027.3%2048.9%2024.2C54.3%2017.9%2059%2011.2%2059%209.80001C59%209.30001%2057.7%209.10001%2056%209.50001C54.2%209.90001%2050.5%2012.7%2046.4%2017.1C42.7%2020.9%2039.4%2024%2039.1%2024C38.8%2024%2036.3%2020.7%2033.6%2016.8C30.9%2012.9%2027.9%209.50001%2027%209.30001C26%209.00001%2024.3%207.60001%2023.2%206.10001C21.7%204.10001%2020.3%203.30001%2017.7%203.20001C15.8%203.10001%2014%203.30001%2013.7%203.70001Z%22%20fill%3D%22%238E8CEE%22%2F%3E%3C%2Fsvg%3E";
|
|
505
|
+
|
|
506
|
+
var reset = "data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M1%204V10H7%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M3.51%2014.9999C4.15839%2016.8403%205.38734%2018.4201%207.01166%2019.5013C8.63598%2020.5825%2010.5677%2021.1065%2012.5157%2020.9944C14.4637%2020.8823%2016.3226%2020.1401%2017.8121%2018.8797C19.3017%2017.6193%2020.3413%2015.9089%2020.7742%2014.0063C21.2072%2012.1037%2021.0101%2010.1119%2020.2126%208.33105C19.4152%206.55019%2018.0605%205.07674%2016.3528%204.13271C14.6451%203.18868%2012.6769%202.82521%2010.7447%203.09707C8.81245%203.36892%207.02091%204.26137%205.64%205.63995L1%209.99995%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
|
|
507
|
+
|
|
508
|
+
var SignaturePad = /** @class */ (function (_super) {
|
|
509
|
+
__extends(SignaturePad, _super);
|
|
510
|
+
function SignaturePad(props) {
|
|
511
|
+
var _this = _super.call(this, props) || this;
|
|
512
|
+
_this.state = {
|
|
513
|
+
hasContent: false,
|
|
514
|
+
};
|
|
515
|
+
_this.canvasRef = React__default.createRef();
|
|
516
|
+
_this.notifyOnChange = _this.notifyOnChange.bind(_this);
|
|
517
|
+
_this.resizeCanvas = _this.resizeCanvas.bind(_this);
|
|
518
|
+
_this.clear = _this.clear.bind(_this);
|
|
519
|
+
return _this;
|
|
520
|
+
}
|
|
521
|
+
SignaturePad.prototype.componentDidMount = function () {
|
|
522
|
+
this.canvas = this.canvasRef.current;
|
|
523
|
+
this.signaturePad = new SignaturePad$1(this.canvas, {
|
|
524
|
+
onEnd: this.notifyOnChange,
|
|
525
|
+
});
|
|
526
|
+
this.resizeCanvas();
|
|
527
|
+
};
|
|
528
|
+
SignaturePad.prototype.render = function () {
|
|
529
|
+
var hasContent = this.state.hasContent;
|
|
530
|
+
return (jsxs(Fragment, { children: [jsx("style", { dangerouslySetInnerHTML: {
|
|
531
|
+
__html: "." + styles.reset + "::before { \n -webkit-mask-image: url(\"" + reset + "\");\n mask-image: url(\"" + reset + "\");\n }",
|
|
532
|
+
} }, void 0),
|
|
533
|
+
jsxs("div", __assign({ className: styles.container }, { children: [jsx("canvas", { className: styles.canvas, ref: this.canvasRef }, void 0),
|
|
534
|
+
jsx("div", { className: styles.separator }, void 0),
|
|
535
|
+
jsx("div", { className: styles.sign, style: {
|
|
536
|
+
WebkitMaskImage: "url(\"" + sign + "\")",
|
|
537
|
+
maskImage: "url(\"" + sign + "\")",
|
|
538
|
+
} }, void 0),
|
|
539
|
+
jsx("button", __assign({ className: styles.reset, onClick: this.clear, disabled: !hasContent }, { children: "Reset" }), void 0)] }), void 0)] }, void 0));
|
|
540
|
+
};
|
|
541
|
+
SignaturePad.prototype.notifyOnChange = function () {
|
|
542
|
+
var onChange = this.props.onChange;
|
|
543
|
+
onChange(this.signaturePad.isEmpty() ? '' : this.signaturePad.toDataURL());
|
|
544
|
+
this.setState({ hasContent: !this.signaturePad.isEmpty() });
|
|
545
|
+
};
|
|
546
|
+
SignaturePad.prototype.resizeCanvas = function () {
|
|
547
|
+
var ratio = Math.max(window.devicePixelRatio || 1, 1);
|
|
548
|
+
this.canvas.width = this.canvas.offsetWidth * ratio;
|
|
549
|
+
this.canvas.height = this.canvas.offsetHeight * ratio;
|
|
550
|
+
this.canvas.getContext('2d').scale(ratio, ratio);
|
|
551
|
+
};
|
|
552
|
+
SignaturePad.prototype.clear = function () {
|
|
553
|
+
this.signaturePad.clear();
|
|
554
|
+
this.notifyOnChange();
|
|
555
|
+
};
|
|
556
|
+
return SignaturePad;
|
|
557
|
+
}(Component));
|
|
558
|
+
|
|
559
|
+
export { SignaturePad };
|
|
560
|
+
//# sourceMappingURL=index.js.map
|