@bagelink/vue 1.4.8 → 1.4.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SignaturePad.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/SignaturePad.vue"],"names":[],"mappings":"AA0QA,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;AAcF,iBAAS,KAAK,SAIb;AAED,iBAAS,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,sBAGhC;AAgCD,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,6BAQ/B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F,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;;;;;;;;;;;;;;;eA5MH,OAAO;;;;AAySpB,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({
@@ -19674,7 +19668,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
19674
19668
  sigData.value = data2;
19675
19669
  saveFile();
19676
19670
  }
19677
- async function loadFile(file) {
19671
+ function loadFile(file) {
19678
19672
  if (!file) return;
19679
19673
  const reader = new FileReader();
19680
19674
  return new Promise((resolve) => {
@@ -19690,38 +19684,36 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
19690
19684
  });
19691
19685
  }
19692
19686
  vue.watch(fileData, (newFile) => {
19693
- loadFile(newFile);
19694
- });
19687
+ void loadFile(newFile);
19688
+ });
19689
+ function resizeCanvas() {
19690
+ let url;
19691
+ if (!isEmpty()) url = save2();
19692
+ const ratio = props2.ratio ?? 1 / 2;
19693
+ const { width } = vCanvas.value.getBoundingClientRect();
19694
+ vCanvas.value.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
19695
+ vCanvas.value.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
19696
+ clear();
19697
+ if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
19698
+ if (props2.waterMark) addWaterMark(props2.waterMark);
19699
+ }
19695
19700
  function draw() {
19696
- const canvas = vCanvas.value;
19697
- sig.value = new SignaturePad(canvas, signatureOptions.value);
19698
- function resizeCanvas(c2) {
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);
19701
+ sig.value = new SignaturePad(vCanvas.value, signatureOptions.value);
19702
+ window.addEventListener("resize", resizeCanvas);
19703
+ resizeCanvas();
19713
19704
  if (props2.disabled) sig.value.off();
19714
19705
  else sig.value.on();
19715
19706
  _isEmpty.value = sig.value.isEmpty();
19716
19707
  sig.value.addEventListener("endStroke", onEndStroke);
19717
19708
  if (fileData.value) {
19718
- loadFile(fileData.value);
19709
+ void loadFile(fileData.value);
19719
19710
  }
19720
19711
  }
19721
19712
  vue.onMounted(draw);
19722
19713
  vue.onUnmounted(() => {
19723
19714
  var _a;
19724
19715
  (_a = sig.value) == null ? void 0 : _a.removeEventListener("endStroke", onEndStroke);
19716
+ window.removeEventListener("resize", resizeCanvas);
19725
19717
  });
19726
19718
  __expose({
19727
19719
  save: save2,
@@ -19734,7 +19726,7 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
19734
19726
  return (_ctx, _cache) => {
19735
19727
  return vue.openBlock(), vue.createElementBlock("div", {
19736
19728
  class: vue.normalizeClass(["bgl_input signature-pad relative", { "bg-transparent": _ctx.disabled }]),
19737
- onTouchmove: _cache[0] || (_cache[0] = vue.withModifiers(() => {
19729
+ onTouchmove: _cache[1] || (_cache[1] = vue.withModifiers(() => {
19738
19730
  }, ["prevent"]))
19739
19731
  }, [
19740
19732
  _ctx.clearable && !_ctx.disabled ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
@@ -19751,7 +19743,18 @@ const _sfc_main$B = /* @__PURE__ */ vue.defineComponent({
19751
19743
  class: "canvas",
19752
19744
  disabled: _ctx.disabled
19753
19745
  }, null, 8, _hoisted_1$u),
19754
- _ctx.required && vue.unref(_isEmpty) ? (vue.openBlock(), vue.createElementBlock("input", _hoisted_2$l)) : vue.createCommentVNode("", true)
19746
+ vue.createElementVNode("input", {
19747
+ placeholder: "required",
19748
+ type: "text",
19749
+ required: _ctx.required && vue.unref(_isEmpty),
19750
+ class: "pixel opacity-0",
19751
+ tabindex: "-1",
19752
+ "aria-hidden": "true",
19753
+ onFocus: _cache[0] || (_cache[0] = (event) => {
19754
+ var _a, _b;
19755
+ return (_b = (_a = event.target) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
19756
+ })
19757
+ }, null, 40, _hoisted_2$l)
19755
19758
  ], 34);
19756
19759
  };
19757
19760
  }
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({
@@ -19672,7 +19666,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
19672
19666
  sigData.value = data2;
19673
19667
  saveFile();
19674
19668
  }
19675
- async function loadFile(file) {
19669
+ function loadFile(file) {
19676
19670
  if (!file) return;
19677
19671
  const reader = new FileReader();
19678
19672
  return new Promise((resolve) => {
@@ -19688,38 +19682,36 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
19688
19682
  });
19689
19683
  }
19690
19684
  watch(fileData, (newFile) => {
19691
- loadFile(newFile);
19692
- });
19685
+ void loadFile(newFile);
19686
+ });
19687
+ function resizeCanvas() {
19688
+ let url;
19689
+ if (!isEmpty()) url = save2();
19690
+ const ratio = props2.ratio ?? 1 / 2;
19691
+ const { width } = vCanvas.value.getBoundingClientRect();
19692
+ vCanvas.value.width = props2.width ? Number(props2.width.replaceAll("px", "")) : width;
19693
+ vCanvas.value.height = props2.height ? Number(props2.height.replaceAll("px", "")) : width * ratio;
19694
+ clear();
19695
+ if (!props2.clearOnResize && url !== void 0) void fromDataURL(url);
19696
+ if (props2.waterMark) addWaterMark(props2.waterMark);
19697
+ }
19693
19698
  function draw() {
19694
- const canvas = vCanvas.value;
19695
- sig.value = new SignaturePad(canvas, signatureOptions.value);
19696
- function resizeCanvas(c2) {
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);
19699
+ sig.value = new SignaturePad(vCanvas.value, signatureOptions.value);
19700
+ window.addEventListener("resize", resizeCanvas);
19701
+ resizeCanvas();
19711
19702
  if (props2.disabled) sig.value.off();
19712
19703
  else sig.value.on();
19713
19704
  _isEmpty.value = sig.value.isEmpty();
19714
19705
  sig.value.addEventListener("endStroke", onEndStroke);
19715
19706
  if (fileData.value) {
19716
- loadFile(fileData.value);
19707
+ void loadFile(fileData.value);
19717
19708
  }
19718
19709
  }
19719
19710
  onMounted(draw);
19720
19711
  onUnmounted(() => {
19721
19712
  var _a;
19722
19713
  (_a = sig.value) == null ? void 0 : _a.removeEventListener("endStroke", onEndStroke);
19714
+ window.removeEventListener("resize", resizeCanvas);
19723
19715
  });
19724
19716
  __expose({
19725
19717
  save: save2,
@@ -19732,7 +19724,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
19732
19724
  return (_ctx, _cache) => {
19733
19725
  return openBlock(), createElementBlock("div", {
19734
19726
  class: normalizeClass(["bgl_input signature-pad relative", { "bg-transparent": _ctx.disabled }]),
19735
- onTouchmove: _cache[0] || (_cache[0] = withModifiers(() => {
19727
+ onTouchmove: _cache[1] || (_cache[1] = withModifiers(() => {
19736
19728
  }, ["prevent"]))
19737
19729
  }, [
19738
19730
  _ctx.clearable && !_ctx.disabled ? (openBlock(), createBlock(unref(Btn), {
@@ -19749,7 +19741,18 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
19749
19741
  class: "canvas",
19750
19742
  disabled: _ctx.disabled
19751
19743
  }, null, 8, _hoisted_1$u),
19752
- _ctx.required && unref(_isEmpty) ? (openBlock(), createElementBlock("input", _hoisted_2$l)) : createCommentVNode("", true)
19744
+ createElementVNode("input", {
19745
+ placeholder: "required",
19746
+ type: "text",
19747
+ required: _ctx.required && unref(_isEmpty),
19748
+ class: "pixel opacity-0",
19749
+ tabindex: "-1",
19750
+ "aria-hidden": "true",
19751
+ onFocus: _cache[0] || (_cache[0] = (event) => {
19752
+ var _a, _b;
19753
+ return (_b = (_a = event.target) == null ? void 0 : _a.blur) == null ? void 0 : _b.call(_a);
19754
+ })
19755
+ }, null, 40, _hoisted_2$l)
19753
19756
  ], 34);
19754
19757
  };
19755
19758
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.4.8",
4
+ "version": "1.4.12",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -153,7 +153,7 @@ function onEndStroke() {
153
153
  saveFile()
154
154
  }
155
155
 
156
- async function loadFile(file: File | undefined) {
156
+ function loadFile(file: File | undefined) {
157
157
  if (!file) return
158
158
  const reader = new FileReader()
159
159
  return new Promise((resolve) => {
@@ -169,26 +169,25 @@ async function loadFile(file: File | undefined) {
169
169
  }
170
170
 
171
171
  watch(fileData, (newFile) => {
172
- loadFile(newFile)
172
+ void loadFile(newFile)
173
173
  })
174
174
 
175
+ function resizeCanvas() {
176
+ let url
177
+ if (!isEmpty()) url = save()
178
+ const ratio = props.ratio ?? 1 / 2
179
+ const { width } = vCanvas!.getBoundingClientRect()
180
+ vCanvas!.width = props.width ? Number(props.width.replaceAll('px', '')) : width
181
+ vCanvas!.height = props.height ? Number(props.height.replaceAll('px', '')) : width * ratio
182
+ clear()
183
+ if (!props.clearOnResize && url !== undefined) void fromDataURL(url)
184
+ if (props.waterMark) addWaterMark(props.waterMark)
185
+ }
186
+
175
187
  function draw() {
176
- const canvas = vCanvas!
177
- sig = new SignaturePad(canvas, signatureOptions)
178
- function resizeCanvas(c: HTMLCanvasElement) {
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)
188
+ sig = new SignaturePad(vCanvas!, signatureOptions)
189
+ window.addEventListener('resize', resizeCanvas)
190
+ resizeCanvas()
192
191
  if (props.disabled) sig.off()
193
192
  else sig.on()
194
193
  _isEmpty = sig.isEmpty()
@@ -196,13 +195,14 @@ function draw() {
196
195
 
197
196
  // Load initial file if provided
198
197
  if (fileData.value) {
199
- loadFile(fileData.value)
198
+ void loadFile(fileData.value)
200
199
  }
201
200
  }
202
201
 
203
202
  onMounted(draw)
204
203
  onUnmounted(() => {
205
204
  sig?.removeEventListener('endStroke', onEndStroke)
205
+ window.removeEventListener('resize', resizeCanvas)
206
206
  })
207
207
 
208
208
  defineExpose({
@@ -235,12 +235,20 @@ defineExpose({
235
235
  :disabled
236
236
  />
237
237
  <input
238
- v-if="required && _isEmpty"
239
238
  placeholder="required"
240
239
  type="text"
241
- required
240
+ :required="required && _isEmpty"
242
241
  class="pixel opacity-0"
242
+ tabindex="-1"
243
+ aria-hidden="true"
244
+ @focus="event => (event.target as any)?.blur?.()"
243
245
  >
246
+ <!--
247
+ we add a hidden input to make the signature pad required
248
+ we need to set the tabindex to -1 and aria-hidden to true
249
+ to make it not focusable and not visible to screen readers
250
+ ! most importantally this prevents the keyboard from opening on mobile
251
+ -->
244
252
  </div>
245
253
  </template>
246
254