@bagelink/vue 1.4.8 → 1.4.10
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.
|
@@ -50,6 +50,7 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
|
50
50
|
clearable: boolean;
|
|
51
51
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
52
52
|
vCanvas: HTMLCanvasElement;
|
|
53
|
+
requiredInput: HTMLInputElement;
|
|
53
54
|
}, HTMLDivElement>;
|
|
54
55
|
export default _default;
|
|
55
56
|
//# sourceMappingURL=SignaturePad.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignaturePad.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/SignaturePad.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignaturePad.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/SignaturePad.vue"],"names":[],"mappings":"AAoRA,OAAO,KAAK,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAKnE,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,CAAA;AAEnF,KAAK,WAAW,GAAG;IAClB,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB,CAAC;AAeF,iBAAS,KAAK,SAIb;AAED,iBAAS,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,sBAGhC;AAgCD,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,6BAQ/B;AAGD,iBAAS,IAAI,SAMZ;AAiBD,iBAAS,YAAY,CAAC,IAAI,EAAE,SAAS,QA0BpC;AAoFD,KAAK,iBAAiB,GAAG;IACzB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,MAAM,CAAC,EAAE,IAAI,CAAC;CACb,GAAG,WAAW,CAAC;;;;;;;;;;;;;;;eA7MH,OAAO;;;;;AA+SpB,wBAWG"}
|
package/dist/index.cjs
CHANGED
|
@@ -19537,13 +19537,7 @@ class SignaturePad extends SignatureEventTarget {
|
|
|
19537
19537
|
}
|
|
19538
19538
|
}
|
|
19539
19539
|
const _hoisted_1$u = ["disabled"];
|
|
19540
|
-
const _hoisted_2$l =
|
|
19541
|
-
key: 1,
|
|
19542
|
-
placeholder: "required",
|
|
19543
|
-
type: "text",
|
|
19544
|
-
required: "",
|
|
19545
|
-
class: "pixel opacity-0"
|
|
19546
|
-
};
|
|
19540
|
+
const _hoisted_2$l = ["required"];
|
|
19547
19541
|
const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
19548
19542
|
__name: "SignaturePad",
|
|
19549
19543
|
props: /* @__PURE__ */ vue.mergeModels({
|
|
@@ -19570,6 +19564,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
|
19570
19564
|
const sigData = vue.useModel(__props, "modelValue");
|
|
19571
19565
|
const fileData = vue.useModel(__props, "file");
|
|
19572
19566
|
const vCanvas = vue.ref();
|
|
19567
|
+
const requiredInput = vue.ref();
|
|
19573
19568
|
let sig = vue.ref();
|
|
19574
19569
|
let _isEmpty = vue.ref(true);
|
|
19575
19570
|
function clear() {
|
|
@@ -19674,7 +19669,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
|
19674
19669
|
sigData.value = data2;
|
|
19675
19670
|
saveFile();
|
|
19676
19671
|
}
|
|
19677
|
-
|
|
19672
|
+
function loadFile(file) {
|
|
19678
19673
|
if (!file) return;
|
|
19679
19674
|
const reader = new FileReader();
|
|
19680
19675
|
return new Promise((resolve) => {
|
|
@@ -19690,38 +19685,36 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
|
19690
19685
|
});
|
|
19691
19686
|
}
|
|
19692
19687
|
vue.watch(fileData, (newFile) => {
|
|
19693
|
-
loadFile(newFile);
|
|
19694
|
-
});
|
|
19688
|
+
void loadFile(newFile);
|
|
19689
|
+
});
|
|
19690
|
+
function resizeCanvas() {
|
|
19691
|
+
let url;
|
|
19692
|
+
if (!isEmpty()) url = save2();
|
|
19693
|
+
const ratio = props2.ratio ?? 1 / 2;
|
|
19694
|
+
const { width } = vCanvas.value.getBoundingClientRect();
|
|
19695
|
+
vCanvas.value.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
|
|
19696
|
+
vCanvas.value.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
|
|
19697
|
+
clear();
|
|
19698
|
+
if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
|
|
19699
|
+
if (props2.waterMark) addWaterMark(props2.waterMark);
|
|
19700
|
+
}
|
|
19695
19701
|
function draw() {
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
let url;
|
|
19700
|
-
if (!isEmpty()) url = save2();
|
|
19701
|
-
const ratio = props2.ratio ?? 1 / 2;
|
|
19702
|
-
const { width } = c2.getBoundingClientRect();
|
|
19703
|
-
c2.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
|
|
19704
|
-
c2.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
|
|
19705
|
-
clear();
|
|
19706
|
-
if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
|
|
19707
|
-
if (props2.waterMark) addWaterMark(props2.waterMark);
|
|
19708
|
-
}
|
|
19709
|
-
window.addEventListener("resize", () => {
|
|
19710
|
-
resizeCanvas(canvas);
|
|
19711
|
-
});
|
|
19712
|
-
resizeCanvas(canvas);
|
|
19702
|
+
sig.value = new SignaturePad(vCanvas.value, signatureOptions.value);
|
|
19703
|
+
window.addEventListener("resize", resizeCanvas);
|
|
19704
|
+
resizeCanvas();
|
|
19713
19705
|
if (props2.disabled) sig.value.off();
|
|
19714
19706
|
else sig.value.on();
|
|
19715
19707
|
_isEmpty.value = sig.value.isEmpty();
|
|
19716
19708
|
sig.value.addEventListener("endStroke", onEndStroke);
|
|
19717
19709
|
if (fileData.value) {
|
|
19718
|
-
loadFile(fileData.value);
|
|
19710
|
+
void loadFile(fileData.value);
|
|
19719
19711
|
}
|
|
19720
19712
|
}
|
|
19721
19713
|
vue.onMounted(draw);
|
|
19722
19714
|
vue.onUnmounted(() => {
|
|
19723
19715
|
var _a;
|
|
19724
19716
|
(_a = sig.value) == null ? void 0 : _a.removeEventListener("endStroke", onEndStroke);
|
|
19717
|
+
window.removeEventListener("resize", resizeCanvas);
|
|
19725
19718
|
});
|
|
19726
19719
|
__expose({
|
|
19727
19720
|
save: save2,
|
|
@@ -19734,7 +19727,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
|
19734
19727
|
return (_ctx, _cache) => {
|
|
19735
19728
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
19736
19729
|
class: vue.normalizeClass(["bgl_input signature-pad relative", { "bg-transparent": _ctx.disabled }]),
|
|
19737
|
-
onTouchmove: _cache[
|
|
19730
|
+
onTouchmove: _cache[1] || (_cache[1] = vue.withModifiers(() => {
|
|
19738
19731
|
}, ["prevent"]))
|
|
19739
19732
|
}, [
|
|
19740
19733
|
_ctx.clearable && !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
|
|
@@ -19751,7 +19744,20 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
|
|
|
19751
19744
|
class: "canvas",
|
|
19752
19745
|
disabled: _ctx.disabled
|
|
19753
19746
|
}, null, 8, _hoisted_1$u),
|
|
19754
|
-
|
|
19747
|
+
vue.createElementVNode("input", {
|
|
19748
|
+
ref_key: "requiredInput",
|
|
19749
|
+
ref: requiredInput,
|
|
19750
|
+
placeholder: "required",
|
|
19751
|
+
type: "text",
|
|
19752
|
+
required: _ctx.required && vue.unref(_isEmpty),
|
|
19753
|
+
class: "pixel opacity-0",
|
|
19754
|
+
tabindex: "-1",
|
|
19755
|
+
"aria-hidden": "true",
|
|
19756
|
+
onFocus: _cache[0] || (_cache[0] = (event) => {
|
|
19757
|
+
var _a, _b;
|
|
19758
|
+
return (_b = (_a = event.target) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
|
|
19759
|
+
})
|
|
19760
|
+
}, null, 40, _hoisted_2$l)
|
|
19755
19761
|
], 34);
|
|
19756
19762
|
};
|
|
19757
19763
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -19535,13 +19535,7 @@ class SignaturePad extends SignatureEventTarget {
|
|
|
19535
19535
|
}
|
|
19536
19536
|
}
|
|
19537
19537
|
const _hoisted_1$u = ["disabled"];
|
|
19538
|
-
const _hoisted_2$l =
|
|
19539
|
-
key: 1,
|
|
19540
|
-
placeholder: "required",
|
|
19541
|
-
type: "text",
|
|
19542
|
-
required: "",
|
|
19543
|
-
class: "pixel opacity-0"
|
|
19544
|
-
};
|
|
19538
|
+
const _hoisted_2$l = ["required"];
|
|
19545
19539
|
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
19546
19540
|
__name: "SignaturePad",
|
|
19547
19541
|
props: /* @__PURE__ */ mergeModels({
|
|
@@ -19568,6 +19562,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
19568
19562
|
const sigData = useModel(__props, "modelValue");
|
|
19569
19563
|
const fileData = useModel(__props, "file");
|
|
19570
19564
|
const vCanvas = ref();
|
|
19565
|
+
const requiredInput = ref();
|
|
19571
19566
|
let sig = ref();
|
|
19572
19567
|
let _isEmpty = ref(true);
|
|
19573
19568
|
function clear() {
|
|
@@ -19672,7 +19667,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
19672
19667
|
sigData.value = data2;
|
|
19673
19668
|
saveFile();
|
|
19674
19669
|
}
|
|
19675
|
-
|
|
19670
|
+
function loadFile(file) {
|
|
19676
19671
|
if (!file) return;
|
|
19677
19672
|
const reader = new FileReader();
|
|
19678
19673
|
return new Promise((resolve) => {
|
|
@@ -19688,38 +19683,36 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
19688
19683
|
});
|
|
19689
19684
|
}
|
|
19690
19685
|
watch(fileData, (newFile) => {
|
|
19691
|
-
loadFile(newFile);
|
|
19692
|
-
});
|
|
19686
|
+
void loadFile(newFile);
|
|
19687
|
+
});
|
|
19688
|
+
function resizeCanvas() {
|
|
19689
|
+
let url;
|
|
19690
|
+
if (!isEmpty()) url = save2();
|
|
19691
|
+
const ratio = props2.ratio ?? 1 / 2;
|
|
19692
|
+
const { width } = vCanvas.value.getBoundingClientRect();
|
|
19693
|
+
vCanvas.value.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
|
|
19694
|
+
vCanvas.value.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
|
|
19695
|
+
clear();
|
|
19696
|
+
if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
|
|
19697
|
+
if (props2.waterMark) addWaterMark(props2.waterMark);
|
|
19698
|
+
}
|
|
19693
19699
|
function draw() {
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
let url;
|
|
19698
|
-
if (!isEmpty()) url = save2();
|
|
19699
|
-
const ratio = props2.ratio ?? 1 / 2;
|
|
19700
|
-
const { width } = c2.getBoundingClientRect();
|
|
19701
|
-
c2.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
|
|
19702
|
-
c2.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
|
|
19703
|
-
clear();
|
|
19704
|
-
if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
|
|
19705
|
-
if (props2.waterMark) addWaterMark(props2.waterMark);
|
|
19706
|
-
}
|
|
19707
|
-
window.addEventListener("resize", () => {
|
|
19708
|
-
resizeCanvas(canvas);
|
|
19709
|
-
});
|
|
19710
|
-
resizeCanvas(canvas);
|
|
19700
|
+
sig.value = new SignaturePad(vCanvas.value, signatureOptions.value);
|
|
19701
|
+
window.addEventListener("resize", resizeCanvas);
|
|
19702
|
+
resizeCanvas();
|
|
19711
19703
|
if (props2.disabled) sig.value.off();
|
|
19712
19704
|
else sig.value.on();
|
|
19713
19705
|
_isEmpty.value = sig.value.isEmpty();
|
|
19714
19706
|
sig.value.addEventListener("endStroke", onEndStroke);
|
|
19715
19707
|
if (fileData.value) {
|
|
19716
|
-
loadFile(fileData.value);
|
|
19708
|
+
void loadFile(fileData.value);
|
|
19717
19709
|
}
|
|
19718
19710
|
}
|
|
19719
19711
|
onMounted(draw);
|
|
19720
19712
|
onUnmounted(() => {
|
|
19721
19713
|
var _a;
|
|
19722
19714
|
(_a = sig.value) == null ? void 0 : _a.removeEventListener("endStroke", onEndStroke);
|
|
19715
|
+
window.removeEventListener("resize", resizeCanvas);
|
|
19723
19716
|
});
|
|
19724
19717
|
__expose({
|
|
19725
19718
|
save: save2,
|
|
@@ -19732,7 +19725,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
19732
19725
|
return (_ctx, _cache) => {
|
|
19733
19726
|
return openBlock(), createElementBlock("div", {
|
|
19734
19727
|
class: normalizeClass(["bgl_input signature-pad relative", { "bg-transparent": _ctx.disabled }]),
|
|
19735
|
-
onTouchmove: _cache[
|
|
19728
|
+
onTouchmove: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
19736
19729
|
}, ["prevent"]))
|
|
19737
19730
|
}, [
|
|
19738
19731
|
_ctx.clearable && !_ctx.disabled ? (openBlock(), createBlock(unref(Btn), {
|
|
@@ -19749,7 +19742,20 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
19749
19742
|
class: "canvas",
|
|
19750
19743
|
disabled: _ctx.disabled
|
|
19751
19744
|
}, null, 8, _hoisted_1$u),
|
|
19752
|
-
|
|
19745
|
+
createElementVNode("input", {
|
|
19746
|
+
ref_key: "requiredInput",
|
|
19747
|
+
ref: requiredInput,
|
|
19748
|
+
placeholder: "required",
|
|
19749
|
+
type: "text",
|
|
19750
|
+
required: _ctx.required && unref(_isEmpty),
|
|
19751
|
+
class: "pixel opacity-0",
|
|
19752
|
+
tabindex: "-1",
|
|
19753
|
+
"aria-hidden": "true",
|
|
19754
|
+
onFocus: _cache[0] || (_cache[0] = (event) => {
|
|
19755
|
+
var _a, _b;
|
|
19756
|
+
return (_b = (_a = event.target) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
|
|
19757
|
+
})
|
|
19758
|
+
}, null, 40, _hoisted_2$l)
|
|
19753
19759
|
], 34);
|
|
19754
19760
|
};
|
|
19755
19761
|
}
|
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ const sigData = defineModel()
|
|
|
38
38
|
const fileData = defineModel<File>('file')
|
|
39
39
|
|
|
40
40
|
const vCanvas = $ref<HTMLCanvasElement>()
|
|
41
|
+
const requiredInput = $ref<HTMLInputElement>()
|
|
41
42
|
|
|
42
43
|
let sig = $ref<SignaturePad>()
|
|
43
44
|
|
|
@@ -153,7 +154,7 @@ function onEndStroke() {
|
|
|
153
154
|
saveFile()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
function loadFile(file: File | undefined) {
|
|
157
158
|
if (!file) return
|
|
158
159
|
const reader = new FileReader()
|
|
159
160
|
return new Promise((resolve) => {
|
|
@@ -169,26 +170,25 @@ async function loadFile(file: File | undefined) {
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
watch(fileData, (newFile) => {
|
|
172
|
-
loadFile(newFile)
|
|
173
|
+
void loadFile(newFile)
|
|
173
174
|
})
|
|
174
175
|
|
|
176
|
+
function resizeCanvas() {
|
|
177
|
+
let url
|
|
178
|
+
if (!isEmpty()) url = save()
|
|
179
|
+
const ratio = props.ratio ?? 1 / 2
|
|
180
|
+
const { width } = vCanvas!.getBoundingClientRect()
|
|
181
|
+
vCanvas!.width = props.width ? Number(props.width.replaceAll('px', '')) : width
|
|
182
|
+
vCanvas!.height = props.height ? Number(props.height.replaceAll('px', '')) : width * ratio
|
|
183
|
+
clear()
|
|
184
|
+
if (!props.clearOnResize && url !== undefined) void fromDataURL(url)
|
|
185
|
+
if (props.waterMark) addWaterMark(props.waterMark)
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
function draw() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
// ! TODO: function does not need to be declared inside draw()
|
|
180
|
-
let url
|
|
181
|
-
if (!isEmpty()) url = save()
|
|
182
|
-
const ratio = props.ratio ?? 1 / 2
|
|
183
|
-
const { width } = c.getBoundingClientRect()
|
|
184
|
-
c.width = props.width ? Number(props.width.replaceAll('px', '')) : width
|
|
185
|
-
c.height = props.height ? Number(props.height.replaceAll('px', '')) : width * ratio
|
|
186
|
-
clear()
|
|
187
|
-
if (!props.clearOnResize && url !== undefined) void fromDataURL(url)
|
|
188
|
-
if (props.waterMark) addWaterMark(props.waterMark)
|
|
189
|
-
}
|
|
190
|
-
window.addEventListener('resize', () => { resizeCanvas(canvas) })
|
|
191
|
-
resizeCanvas(canvas)
|
|
189
|
+
sig = new SignaturePad(vCanvas!, signatureOptions)
|
|
190
|
+
window.addEventListener('resize', resizeCanvas)
|
|
191
|
+
resizeCanvas()
|
|
192
192
|
if (props.disabled) sig.off()
|
|
193
193
|
else sig.on()
|
|
194
194
|
_isEmpty = sig.isEmpty()
|
|
@@ -196,13 +196,14 @@ function draw() {
|
|
|
196
196
|
|
|
197
197
|
// Load initial file if provided
|
|
198
198
|
if (fileData.value) {
|
|
199
|
-
loadFile(fileData.value)
|
|
199
|
+
void loadFile(fileData.value)
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
onMounted(draw)
|
|
204
204
|
onUnmounted(() => {
|
|
205
205
|
sig?.removeEventListener('endStroke', onEndStroke)
|
|
206
|
+
window.removeEventListener('resize', resizeCanvas)
|
|
206
207
|
})
|
|
207
208
|
|
|
208
209
|
defineExpose({
|
|
@@ -235,12 +236,21 @@ defineExpose({
|
|
|
235
236
|
:disabled
|
|
236
237
|
/>
|
|
237
238
|
<input
|
|
238
|
-
|
|
239
|
+
ref="requiredInput"
|
|
239
240
|
placeholder="required"
|
|
240
241
|
type="text"
|
|
241
|
-
required
|
|
242
|
+
:required="required && _isEmpty"
|
|
242
243
|
class="pixel opacity-0"
|
|
244
|
+
tabindex="-1"
|
|
245
|
+
aria-hidden="true"
|
|
246
|
+
@focus="event => (event.target as any)?.blur?.()"
|
|
243
247
|
>
|
|
248
|
+
<!--
|
|
249
|
+
we add a hidden input to make the signature pad required
|
|
250
|
+
we need to set the tabindex to -1 and aria-hidden to true
|
|
251
|
+
to make it not focusable and not visible to screen readers
|
|
252
|
+
! most importantally this prevents the keyboard from opening on mobile
|
|
253
|
+
-->
|
|
244
254
|
</div>
|
|
245
255
|
</template>
|
|
246
256
|
|