vant 4.7.1 → 4.7.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/lib/vant.js CHANGED
@@ -10698,6 +10698,7 @@
10698
10698
  rootWidth: makeRequiredProp(Number),
10699
10699
  rootHeight: makeRequiredProp(Number),
10700
10700
  disableZoom: Boolean,
10701
+ doubleScale: Boolean,
10701
10702
  closeOnClickOverlay: Boolean
10702
10703
  },
10703
10704
  emits: ["scale", "close", "longPress"],
@@ -10871,18 +10872,22 @@
10871
10872
  const TAP_TIME = 250;
10872
10873
  if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
10873
10874
  if (deltaTime < TAP_TIME) {
10874
- if (doubleTapTimer) {
10875
- clearTimeout(doubleTapTimer);
10876
- doubleTapTimer = null;
10877
- toggleScale();
10878
- } else {
10879
- if (!props2.closeOnClickOverlay && event.target === ((_a = swipeItem.value) == null ? void 0 : _a.$el)) {
10880
- return;
10881
- }
10882
- doubleTapTimer = setTimeout(() => {
10883
- emit("close");
10875
+ if (props2.doubleScale) {
10876
+ if (doubleTapTimer) {
10877
+ clearTimeout(doubleTapTimer);
10884
10878
  doubleTapTimer = null;
10885
- }, TAP_TIME);
10879
+ toggleScale();
10880
+ } else {
10881
+ if (!props2.closeOnClickOverlay && event.target === ((_a = swipeItem.value) == null ? void 0 : _a.$el)) {
10882
+ return;
10883
+ }
10884
+ doubleTapTimer = setTimeout(() => {
10885
+ emit("close");
10886
+ doubleTapTimer = null;
10887
+ }, TAP_TIME);
10888
+ }
10889
+ } else {
10890
+ emit("close");
10886
10891
  }
10887
10892
  } else if (deltaTime > LONG_PRESS_START_TIME) {
10888
10893
  emit("longPress");
@@ -11007,6 +11012,7 @@
11007
11012
  closeIcon: makeStringProp("clear"),
11008
11013
  transition: String,
11009
11014
  beforeClose: Function,
11015
+ doubleScale: truthProp,
11010
11016
  overlayClass: unknownProp,
11011
11017
  overlayStyle: Object,
11012
11018
  swipeDuration: makeNumericProp(300),
@@ -11098,6 +11104,7 @@
11098
11104
  "rootWidth": state.rootWidth,
11099
11105
  "rootHeight": state.rootHeight,
11100
11106
  "disableZoom": state.disableZoom,
11107
+ "doubleScale": props2.doubleScale,
11101
11108
  "closeOnClickOverlay": props2.closeOnClickOverlay,
11102
11109
  "onScale": emitScale,
11103
11110
  "onClose": emitClose,
@@ -11175,6 +11182,7 @@
11175
11182
  closeIcon: "clear",
11176
11183
  transition: void 0,
11177
11184
  beforeClose: void 0,
11185
+ doubleScale: true,
11178
11186
  overlayStyle: void 0,
11179
11187
  overlayClass: void 0,
11180
11188
  startPosition: 0,
@@ -14471,37 +14479,37 @@
14471
14479
  }) {
14472
14480
  const canvasRef = vue.ref();
14473
14481
  const wrapRef = vue.ref();
14474
- const state = vue.reactive({
14475
- width: 0,
14476
- height: 0,
14477
- ctx: null,
14478
- ratio: inBrowser$1 ? window.devicePixelRatio : 1
14482
+ const ctx = vue.computed(() => {
14483
+ if (!canvasRef.value)
14484
+ return null;
14485
+ return canvasRef.value.getContext("2d");
14479
14486
  });
14480
- let canvasRect;
14481
14487
  const isRenderCanvas = inBrowser$1 ? hasCanvasSupport() : true;
14488
+ let canvasWidth = 0;
14489
+ let canvasHeight = 0;
14490
+ let canvasRect;
14482
14491
  const touchStart = () => {
14483
- if (!state.ctx) {
14492
+ if (!ctx.value) {
14484
14493
  return false;
14485
14494
  }
14486
- state.ctx.beginPath();
14487
- state.ctx.lineWidth = props2.lineWidth * state.ratio;
14488
- state.ctx.strokeStyle = props2.penColor;
14495
+ ctx.value.beginPath();
14496
+ ctx.value.lineWidth = props2.lineWidth;
14497
+ ctx.value.strokeStyle = props2.penColor;
14489
14498
  canvasRect = useRect(canvasRef);
14490
14499
  emit("start");
14491
14500
  };
14492
14501
  const touchMove = (event) => {
14493
- var _a, _b;
14494
- if (!state.ctx) {
14502
+ if (!ctx.value) {
14495
14503
  return false;
14496
14504
  }
14497
14505
  preventDefault(event);
14498
14506
  const touch = event.touches[0];
14499
- const mouseX = (touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0)) * state.ratio;
14500
- const mouseY = (touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0)) * state.ratio;
14501
- state.ctx.lineCap = "round";
14502
- state.ctx.lineJoin = "round";
14503
- (_a = state.ctx) == null ? void 0 : _a.lineTo(mouseX, mouseY);
14504
- (_b = state.ctx) == null ? void 0 : _b.stroke();
14507
+ const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
14508
+ const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
14509
+ ctx.value.lineCap = "round";
14510
+ ctx.value.lineJoin = "round";
14511
+ ctx.value.lineTo(mouseX, mouseY);
14512
+ ctx.value.stroke();
14505
14513
  emit("signing", event);
14506
14514
  };
14507
14515
  const touchEnd = (event) => {
@@ -14518,10 +14526,10 @@
14518
14526
  }
14519
14527
  return canvas.toDataURL() === empty.toDataURL();
14520
14528
  };
14521
- const setCanvasBgColor = (ctx) => {
14522
- if (ctx && props2.backgroundColor) {
14523
- ctx.fillStyle = props2.backgroundColor;
14524
- ctx.fillRect(0, 0, state.width, state.height);
14529
+ const setCanvasBgColor = (ctx2) => {
14530
+ if (ctx2 && props2.backgroundColor) {
14531
+ ctx2.fillStyle = props2.backgroundColor;
14532
+ ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
14525
14533
  }
14526
14534
  };
14527
14535
  const submit = () => {
@@ -14541,22 +14549,22 @@
14541
14549
  });
14542
14550
  };
14543
14551
  const clear = () => {
14544
- if (state.ctx) {
14545
- state.ctx.clearRect(0, 0, state.width, state.height);
14546
- state.ctx.closePath();
14547
- setCanvasBgColor(state.ctx);
14552
+ if (ctx.value) {
14553
+ ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
14554
+ ctx.value.closePath();
14555
+ setCanvasBgColor(ctx.value);
14548
14556
  }
14549
14557
  emit("clear");
14550
14558
  };
14551
14559
  vue.onMounted(() => {
14552
14560
  var _a, _b, _c;
14553
- if (isRenderCanvas) {
14554
- state.ctx = (_a = canvasRef.value) == null ? void 0 : _a.getContext("2d");
14555
- state.width = (((_b = wrapRef.value) == null ? void 0 : _b.offsetWidth) || 0) * state.ratio;
14556
- state.height = (((_c = wrapRef.value) == null ? void 0 : _c.offsetHeight) || 0) * state.ratio;
14557
- vue.nextTick(() => {
14558
- setCanvasBgColor(state.ctx);
14559
- });
14561
+ if (isRenderCanvas && canvasRef.value) {
14562
+ const canvas = canvasRef.value;
14563
+ const dpr = inBrowser$1 ? window.devicePixelRatio : 1;
14564
+ canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
14565
+ canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
14566
+ (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
14567
+ setCanvasBgColor(ctx.value);
14560
14568
  }
14561
14569
  });
14562
14570
  return () => vue.createVNode("div", {
@@ -14566,8 +14574,6 @@
14566
14574
  "ref": wrapRef
14567
14575
  }, [isRenderCanvas ? vue.createVNode("canvas", {
14568
14576
  "ref": canvasRef,
14569
- "width": state.width,
14570
- "height": state.height,
14571
14577
  "onTouchstartPassive": touchStart,
14572
14578
  "onTouchmove": touchMove,
14573
14579
  "onTouchend": touchEnd
@@ -16516,6 +16522,7 @@
16516
16522
  const inputRef = vue.ref();
16517
16523
  const urls = [];
16518
16524
  const reuploadIndex = vue.ref(-1);
16525
+ const isReuploading = vue.ref(false);
16519
16526
  const getDetail = (index = props2.modelValue.length) => ({
16520
16527
  name: props2.name,
16521
16528
  index
@@ -16652,8 +16659,15 @@
16652
16659
  emit("delete", item, getDetail(index));
16653
16660
  };
16654
16661
  const reuploadImage = (index) => {
16655
- chooseFile();
16662
+ isReuploading.value = true;
16656
16663
  reuploadIndex.value = index;
16664
+ vue.nextTick(() => chooseFile());
16665
+ };
16666
+ const onInputClick = () => {
16667
+ if (!isReuploading.value) {
16668
+ reuploadIndex.value = -1;
16669
+ }
16670
+ isReuploading.value = false;
16657
16671
  };
16658
16672
  const renderPreviewItem = (item, index) => {
16659
16673
  const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
@@ -16686,7 +16700,8 @@
16686
16700
  "capture": props2.capture,
16687
16701
  "multiple": props2.multiple && reuploadIndex.value === -1,
16688
16702
  "disabled": props2.disabled,
16689
- "onChange": onChange
16703
+ "onChange": onChange,
16704
+ "onClick": onInputClick
16690
16705
  }, null);
16691
16706
  if (slots.default) {
16692
16707
  return vue.withDirectives(vue.createVNode("div", {
@@ -17715,7 +17730,7 @@
17715
17730
  });
17716
17731
  }
17717
17732
  };
17718
- const version = "4.7.1";
17733
+ const version = "4.7.2";
17719
17734
  function install(app) {
17720
17735
  const components = [
17721
17736
  ActionBar,