vant 4.7.1 → 4.7.3

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.
Files changed (90) hide show
  1. package/README.md +1 -0
  2. package/es/address-edit/AddressEdit.mjs +1 -1
  3. package/es/cell/Cell.d.ts +17 -5
  4. package/es/cell/Cell.mjs +5 -2
  5. package/es/cell/index.d.ts +9 -3
  6. package/es/collapse-item/CollapseItem.d.ts +13 -4
  7. package/es/collapse-item/index.d.ts +9 -3
  8. package/es/config-provider/types.d.ts +1 -1
  9. package/es/field/Field.d.ts +30 -21
  10. package/es/field/Field.mjs +11 -3
  11. package/es/field/index.css +1 -1
  12. package/es/field/index.d.ts +18 -12
  13. package/es/field/types.d.ts +1 -1
  14. package/es/form/Form.d.ts +3 -0
  15. package/es/form/Form.mjs +1 -0
  16. package/es/form/index.d.ts +2 -0
  17. package/es/icon/index.css +1 -1
  18. package/es/image-preview/ImagePreview.d.ts +13 -0
  19. package/es/image-preview/ImagePreview.mjs +2 -0
  20. package/es/image-preview/ImagePreviewItem.d.ts +3 -0
  21. package/es/image-preview/ImagePreviewItem.mjs +16 -11
  22. package/es/image-preview/function-call.mjs +1 -0
  23. package/es/image-preview/index.d.ts +9 -0
  24. package/es/image-preview/types.d.ts +1 -0
  25. package/es/index.d.ts +1 -1
  26. package/es/index.mjs +1 -1
  27. package/es/locale/lang/ar-SA.d.ts +63 -0
  28. package/es/locale/lang/ar-SA.mjs +65 -0
  29. package/es/picker-group/PickerGroup.mjs +3 -3
  30. package/es/progress/types.d.ts +1 -4
  31. package/es/search/Search.d.ts +13 -13
  32. package/es/search/Search.mjs +3 -1
  33. package/es/search/index.css +1 -1
  34. package/es/search/index.d.ts +9 -9
  35. package/es/signature/Signature.mjs +49 -38
  36. package/es/signature/index.d.ts +1 -1
  37. package/es/signature/types.d.ts +6 -0
  38. package/es/tabs/Tabs.d.ts +13 -0
  39. package/es/tabs/Tabs.mjs +3 -2
  40. package/es/tabs/index.d.ts +9 -0
  41. package/es/text-ellipsis/index.css +1 -1
  42. package/es/uploader/Uploader.mjs +12 -3
  43. package/lib/address-edit/AddressEdit.js +1 -1
  44. package/lib/cell/Cell.d.ts +17 -5
  45. package/lib/cell/Cell.js +5 -2
  46. package/lib/cell/index.d.ts +9 -3
  47. package/lib/collapse-item/CollapseItem.d.ts +13 -4
  48. package/lib/collapse-item/index.d.ts +9 -3
  49. package/lib/config-provider/types.d.ts +1 -1
  50. package/lib/field/Field.d.ts +30 -21
  51. package/lib/field/Field.js +11 -3
  52. package/lib/field/index.css +1 -1
  53. package/lib/field/index.d.ts +18 -12
  54. package/lib/field/types.d.ts +1 -1
  55. package/lib/form/Form.d.ts +3 -0
  56. package/lib/form/Form.js +1 -0
  57. package/lib/form/index.d.ts +2 -0
  58. package/lib/icon/index.css +1 -1
  59. package/lib/image-preview/ImagePreview.d.ts +13 -0
  60. package/lib/image-preview/ImagePreview.js +2 -0
  61. package/lib/image-preview/ImagePreviewItem.d.ts +3 -0
  62. package/lib/image-preview/ImagePreviewItem.js +16 -11
  63. package/lib/image-preview/function-call.js +1 -0
  64. package/lib/image-preview/index.d.ts +9 -0
  65. package/lib/image-preview/types.d.ts +1 -0
  66. package/lib/index.css +1 -1
  67. package/lib/index.d.ts +1 -1
  68. package/lib/index.js +1 -1
  69. package/lib/locale/lang/ar-SA.d.ts +63 -0
  70. package/lib/locale/lang/ar-SA.js +84 -0
  71. package/lib/picker-group/PickerGroup.js +2 -2
  72. package/lib/progress/types.d.ts +1 -4
  73. package/lib/search/Search.d.ts +13 -13
  74. package/lib/search/Search.js +3 -1
  75. package/lib/search/index.css +1 -1
  76. package/lib/search/index.d.ts +9 -9
  77. package/lib/signature/Signature.js +47 -36
  78. package/lib/signature/index.d.ts +1 -1
  79. package/lib/signature/types.d.ts +6 -0
  80. package/lib/tabs/Tabs.d.ts +13 -0
  81. package/lib/tabs/Tabs.js +3 -2
  82. package/lib/tabs/index.d.ts +9 -0
  83. package/lib/text-ellipsis/index.css +1 -1
  84. package/lib/uploader/Uploader.js +11 -2
  85. package/lib/vant.cjs.js +103 -61
  86. package/lib/vant.es.js +104 -62
  87. package/lib/vant.js +103 -61
  88. package/lib/vant.min.js +1 -1
  89. package/lib/web-types.json +1 -1
  90. package/package.json +4 -4
package/lib/vant.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Comment, Text, h } from "vue";
1
+ import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, Comment, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Text, h } from "vue";
2
2
  import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, cancelRaf, raf, useScrollParent, usePageVisibility, doubleRaf, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, inBrowser as inBrowser$1, useToggle, useCountDown, useClickAway } from "@vant/use";
3
3
  import { normalizeClass, stringifyStyle, normalizeStyle } from "@vue/shared";
4
4
  import { offsetModifier, createPopper } from "@vant/popperjs";
@@ -2608,6 +2608,7 @@ const tabsProps = {
2608
2608
  offsetTop: makeNumericProp(0),
2609
2609
  background: String,
2610
2610
  lazyRender: truthProp,
2611
+ showHeader: truthProp,
2611
2612
  lineWidth: numericProp,
2612
2613
  lineHeight: numericProp,
2613
2614
  beforeChange: Function,
@@ -2909,13 +2910,13 @@ var stdin_default$1C = defineComponent({
2909
2910
  return () => createVNode("div", {
2910
2911
  "ref": root,
2911
2912
  "class": bem$1o([props2.type])
2912
- }, [props2.sticky ? createVNode(Sticky, {
2913
+ }, [props2.showHeader ? props2.sticky ? createVNode(Sticky, {
2913
2914
  "container": root.value,
2914
2915
  "offsetTop": offsetTopPx.value,
2915
2916
  "onScroll": onStickyScroll
2916
2917
  }, {
2917
2918
  default: () => [renderHeader()]
2918
- }) : renderHeader(), createVNode(stdin_default$1D, {
2919
+ }) : renderHeader() : null, createVNode(stdin_default$1D, {
2919
2920
  "ref": contentRef,
2920
2921
  "count": children.length,
2921
2922
  "inited": state.inited,
@@ -3262,8 +3263,8 @@ var stdin_default$1z = defineComponent({
3262
3263
  };
3263
3264
  const onCancel = () => emit("cancel");
3264
3265
  return () => {
3265
- var _a;
3266
- const childNodes = (_a = slots.default) == null ? void 0 : _a.call(slots);
3266
+ var _a, _b;
3267
+ const childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== Comment);
3267
3268
  const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
3268
3269
  return createVNode("div", {
3269
3270
  "class": bem$1k()
@@ -3653,13 +3654,16 @@ const cellSharedProps = {
3653
3654
  center: Boolean,
3654
3655
  isLink: Boolean,
3655
3656
  border: truthProp,
3656
- required: Boolean,
3657
3657
  iconPrefix: String,
3658
3658
  valueClass: unknownProp,
3659
3659
  labelClass: unknownProp,
3660
3660
  titleClass: unknownProp,
3661
3661
  titleStyle: null,
3662
3662
  arrowDirection: String,
3663
+ required: {
3664
+ type: [Boolean, String],
3665
+ default: null
3666
+ },
3663
3667
  clickable: {
3664
3668
  type: Boolean,
3665
3669
  default: null
@@ -3740,7 +3744,7 @@ var stdin_default$1w = defineComponent({
3740
3744
  const clickable = (_a = props2.clickable) != null ? _a : isLink;
3741
3745
  const classes = {
3742
3746
  center,
3743
- required,
3747
+ required: !!required,
3744
3748
  clickable,
3745
3749
  borderless: !border
3746
3750
  };
@@ -3767,6 +3771,7 @@ const formProps = {
3767
3771
  colon: Boolean,
3768
3772
  disabled: Boolean,
3769
3773
  readonly: Boolean,
3774
+ required: [Boolean, String],
3770
3775
  showError: Boolean,
3771
3776
  labelWidth: numericProp,
3772
3777
  labelAlign: String,
@@ -4022,12 +4027,12 @@ const fieldSharedProps = {
4022
4027
  autocorrect: String,
4023
4028
  errorMessage: String,
4024
4029
  enterkeyhint: String,
4030
+ clearTrigger: makeStringProp("focus"),
4031
+ formatTrigger: makeStringProp("onChange"),
4025
4032
  spellcheck: {
4026
4033
  type: Boolean,
4027
4034
  default: null
4028
4035
  },
4029
- clearTrigger: makeStringProp("focus"),
4030
- formatTrigger: makeStringProp("onChange"),
4031
4036
  error: {
4032
4037
  type: Boolean,
4033
4038
  default: null
@@ -4103,6 +4108,14 @@ var stdin_default$1u = defineComponent({
4103
4108
  }
4104
4109
  return props2.modelValue;
4105
4110
  });
4111
+ const showRequiredMark = computed(() => {
4112
+ var _a;
4113
+ const required = getProp("required");
4114
+ if (required === "auto") {
4115
+ return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
4116
+ }
4117
+ return required;
4118
+ });
4106
4119
  const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
4107
4120
  if (state.status === "failed") {
4108
4121
  return;
@@ -4505,7 +4518,7 @@ var stdin_default$1u = defineComponent({
4505
4518
  "titleStyle": labelStyle.value,
4506
4519
  "valueClass": bem$1g("value"),
4507
4520
  "titleClass": [bem$1g("label", [labelAlign, {
4508
- required: props2.required
4521
+ required: showRequiredMark.value
4509
4522
  }]), props2.labelClass],
4510
4523
  "arrowDirection": props2.arrowDirection
4511
4524
  }, {
@@ -5169,7 +5182,7 @@ var stdin_default$1q = defineComponent({
5169
5182
  "label": t$i("area"),
5170
5183
  "is-link": !disableArea,
5171
5184
  "modelValue": areaText.value,
5172
- "rules": rules.value.areaCode,
5185
+ "rules": props2.showArea ? rules.value.areaCode : void 0,
5173
5186
  "placeholder": props2.areaPlaceholder || t$i("area"),
5174
5187
  "onFocus": () => onFocus("areaCode"),
5175
5188
  "onClick": () => {
@@ -10266,6 +10279,7 @@ var stdin_default$N = defineComponent({
10266
10279
  rootWidth: makeRequiredProp(Number),
10267
10280
  rootHeight: makeRequiredProp(Number),
10268
10281
  disableZoom: Boolean,
10282
+ doubleScale: Boolean,
10269
10283
  closeOnClickOverlay: Boolean
10270
10284
  },
10271
10285
  emits: ["scale", "close", "longPress"],
@@ -10439,18 +10453,22 @@ var stdin_default$N = defineComponent({
10439
10453
  const TAP_TIME = 250;
10440
10454
  if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
10441
10455
  if (deltaTime < TAP_TIME) {
10442
- if (doubleTapTimer) {
10443
- clearTimeout(doubleTapTimer);
10444
- doubleTapTimer = null;
10445
- toggleScale();
10446
- } else {
10447
- if (!props2.closeOnClickOverlay && event.target === ((_a = swipeItem.value) == null ? void 0 : _a.$el)) {
10448
- return;
10449
- }
10450
- doubleTapTimer = setTimeout(() => {
10451
- emit("close");
10456
+ if (props2.doubleScale) {
10457
+ if (doubleTapTimer) {
10458
+ clearTimeout(doubleTapTimer);
10452
10459
  doubleTapTimer = null;
10453
- }, TAP_TIME);
10460
+ toggleScale();
10461
+ } else {
10462
+ if (!props2.closeOnClickOverlay && event.target === ((_a = swipeItem.value) == null ? void 0 : _a.$el)) {
10463
+ return;
10464
+ }
10465
+ doubleTapTimer = setTimeout(() => {
10466
+ emit("close");
10467
+ doubleTapTimer = null;
10468
+ }, TAP_TIME);
10469
+ }
10470
+ } else {
10471
+ emit("close");
10454
10472
  }
10455
10473
  } else if (deltaTime > LONG_PRESS_START_TIME) {
10456
10474
  emit("longPress");
@@ -10575,6 +10593,7 @@ const imagePreviewProps = {
10575
10593
  closeIcon: makeStringProp("clear"),
10576
10594
  transition: String,
10577
10595
  beforeClose: Function,
10596
+ doubleScale: truthProp,
10578
10597
  overlayClass: unknownProp,
10579
10598
  overlayStyle: Object,
10580
10599
  swipeDuration: makeNumericProp(300),
@@ -10666,6 +10685,7 @@ var stdin_default$M = defineComponent({
10666
10685
  "rootWidth": state.rootWidth,
10667
10686
  "rootHeight": state.rootHeight,
10668
10687
  "disableZoom": state.disableZoom,
10688
+ "doubleScale": props2.doubleScale,
10669
10689
  "closeOnClickOverlay": props2.closeOnClickOverlay,
10670
10690
  "onScale": emitScale,
10671
10691
  "onClose": emitClose,
@@ -10743,6 +10763,7 @@ const defaultConfig = {
10743
10763
  closeIcon: "clear",
10744
10764
  transition: void 0,
10745
10765
  beforeClose: void 0,
10766
+ doubleScale: true,
10746
10767
  overlayStyle: void 0,
10747
10768
  overlayClass: void 0,
10748
10769
  startPosition: 0,
@@ -12962,7 +12983,9 @@ var stdin_default$v = defineComponent({
12962
12983
  return createVNode(Field, mergeProps({
12963
12984
  "ref": fieldRef,
12964
12985
  "type": "search",
12965
- "class": bem$m("field"),
12986
+ "class": bem$m("field", {
12987
+ "with-message": fieldAttrs.errorMessage
12988
+ }),
12966
12989
  "border": false,
12967
12990
  "onBlur": onBlur,
12968
12991
  "onFocus": onFocus,
@@ -13233,37 +13256,37 @@ var stdin_default$r = defineComponent({
13233
13256
  }) {
13234
13257
  const canvasRef = ref();
13235
13258
  const wrapRef = ref();
13236
- const state = reactive({
13237
- width: 0,
13238
- height: 0,
13239
- ctx: null,
13240
- ratio: inBrowser ? window.devicePixelRatio : 1
13259
+ const ctx = computed(() => {
13260
+ if (!canvasRef.value)
13261
+ return null;
13262
+ return canvasRef.value.getContext("2d");
13241
13263
  });
13242
- let canvasRect;
13243
13264
  const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
13265
+ let canvasWidth = 0;
13266
+ let canvasHeight = 0;
13267
+ let canvasRect;
13244
13268
  const touchStart = () => {
13245
- if (!state.ctx) {
13269
+ if (!ctx.value) {
13246
13270
  return false;
13247
13271
  }
13248
- state.ctx.beginPath();
13249
- state.ctx.lineWidth = props2.lineWidth * state.ratio;
13250
- state.ctx.strokeStyle = props2.penColor;
13272
+ ctx.value.beginPath();
13273
+ ctx.value.lineWidth = props2.lineWidth;
13274
+ ctx.value.strokeStyle = props2.penColor;
13251
13275
  canvasRect = useRect(canvasRef);
13252
13276
  emit("start");
13253
13277
  };
13254
13278
  const touchMove = (event) => {
13255
- var _a, _b;
13256
- if (!state.ctx) {
13279
+ if (!ctx.value) {
13257
13280
  return false;
13258
13281
  }
13259
13282
  preventDefault(event);
13260
13283
  const touch = event.touches[0];
13261
- const mouseX = (touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0)) * state.ratio;
13262
- const mouseY = (touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0)) * state.ratio;
13263
- state.ctx.lineCap = "round";
13264
- state.ctx.lineJoin = "round";
13265
- (_a = state.ctx) == null ? void 0 : _a.lineTo(mouseX, mouseY);
13266
- (_b = state.ctx) == null ? void 0 : _b.stroke();
13284
+ const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
13285
+ const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
13286
+ ctx.value.lineCap = "round";
13287
+ ctx.value.lineJoin = "round";
13288
+ ctx.value.lineTo(mouseX, mouseY);
13289
+ ctx.value.stroke();
13267
13290
  emit("signing", event);
13268
13291
  };
13269
13292
  const touchEnd = (event) => {
@@ -13280,10 +13303,10 @@ var stdin_default$r = defineComponent({
13280
13303
  }
13281
13304
  return canvas.toDataURL() === empty.toDataURL();
13282
13305
  };
13283
- const setCanvasBgColor = (ctx) => {
13284
- if (ctx && props2.backgroundColor) {
13285
- ctx.fillStyle = props2.backgroundColor;
13286
- ctx.fillRect(0, 0, state.width, state.height);
13306
+ const setCanvasBgColor = (ctx2) => {
13307
+ if (ctx2 && props2.backgroundColor) {
13308
+ ctx2.fillStyle = props2.backgroundColor;
13309
+ ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
13287
13310
  }
13288
13311
  };
13289
13312
  const submit = () => {
@@ -13303,23 +13326,35 @@ var stdin_default$r = defineComponent({
13303
13326
  });
13304
13327
  };
13305
13328
  const clear = () => {
13306
- if (state.ctx) {
13307
- state.ctx.clearRect(0, 0, state.width, state.height);
13308
- state.ctx.closePath();
13309
- setCanvasBgColor(state.ctx);
13329
+ if (ctx.value) {
13330
+ ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
13331
+ ctx.value.closePath();
13332
+ setCanvasBgColor(ctx.value);
13310
13333
  }
13311
13334
  emit("clear");
13312
13335
  };
13313
- onMounted(() => {
13336
+ const initialize = () => {
13314
13337
  var _a, _b, _c;
13315
- if (isRenderCanvas) {
13316
- state.ctx = (_a = canvasRef.value) == null ? void 0 : _a.getContext("2d");
13317
- state.width = (((_b = wrapRef.value) == null ? void 0 : _b.offsetWidth) || 0) * state.ratio;
13318
- state.height = (((_c = wrapRef.value) == null ? void 0 : _c.offsetHeight) || 0) * state.ratio;
13319
- nextTick(() => {
13320
- setCanvasBgColor(state.ctx);
13321
- });
13338
+ if (isRenderCanvas && canvasRef.value) {
13339
+ const canvas = canvasRef.value;
13340
+ const dpr = inBrowser ? window.devicePixelRatio : 1;
13341
+ canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
13342
+ canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
13343
+ (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
13344
+ setCanvasBgColor(ctx.value);
13322
13345
  }
13346
+ };
13347
+ const resize = () => {
13348
+ if (ctx.value) {
13349
+ const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
13350
+ initialize();
13351
+ ctx.value.putImageData(data, 0, 0);
13352
+ }
13353
+ };
13354
+ watch(windowWidth, resize);
13355
+ onMounted(initialize);
13356
+ useExpose({
13357
+ resize
13323
13358
  });
13324
13359
  return () => createVNode("div", {
13325
13360
  "class": bem$i()
@@ -13328,8 +13363,6 @@ var stdin_default$r = defineComponent({
13328
13363
  "ref": wrapRef
13329
13364
  }, [isRenderCanvas ? createVNode("canvas", {
13330
13365
  "ref": canvasRef,
13331
- "width": state.width,
13332
- "height": state.height,
13333
13366
  "onTouchstartPassive": touchStart,
13334
13367
  "onTouchmove": touchMove,
13335
13368
  "onTouchend": touchEnd
@@ -15287,6 +15320,7 @@ var stdin_default$5 = defineComponent({
15287
15320
  const inputRef = ref();
15288
15321
  const urls = [];
15289
15322
  const reuploadIndex = ref(-1);
15323
+ const isReuploading = ref(false);
15290
15324
  const getDetail = (index = props2.modelValue.length) => ({
15291
15325
  name: props2.name,
15292
15326
  index
@@ -15423,8 +15457,15 @@ var stdin_default$5 = defineComponent({
15423
15457
  emit("delete", item, getDetail(index));
15424
15458
  };
15425
15459
  const reuploadImage = (index) => {
15426
- chooseFile();
15460
+ isReuploading.value = true;
15427
15461
  reuploadIndex.value = index;
15462
+ nextTick(() => chooseFile());
15463
+ };
15464
+ const onInputClick = () => {
15465
+ if (!isReuploading.value) {
15466
+ reuploadIndex.value = -1;
15467
+ }
15468
+ isReuploading.value = false;
15428
15469
  };
15429
15470
  const renderPreviewItem = (item, index) => {
15430
15471
  const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
@@ -15457,7 +15498,8 @@ var stdin_default$5 = defineComponent({
15457
15498
  "capture": props2.capture,
15458
15499
  "multiple": props2.multiple && reuploadIndex.value === -1,
15459
15500
  "disabled": props2.disabled,
15460
- "onChange": onChange
15501
+ "onChange": onChange,
15502
+ "onClick": onInputClick
15461
15503
  }, null);
15462
15504
  if (slots.default) {
15463
15505
  return withDirectives(createVNode("div", {
@@ -16503,7 +16545,7 @@ const Lazyload = {
16503
16545
  });
16504
16546
  }
16505
16547
  };
16506
- const version = "4.7.1";
16548
+ const version = "4.7.3";
16507
16549
  function install(app) {
16508
16550
  const components = [
16509
16551
  ActionBar,