vant 4.0.0-rc.4 → 4.0.0-rc.6

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 (84) hide show
  1. package/es/calendar/Calendar.mjs +10 -3
  2. package/es/calendar/CalendarHeader.d.ts +2 -0
  3. package/es/calendar/CalendarHeader.mjs +5 -1
  4. package/es/cell/Cell.d.ts +17 -0
  5. package/es/cell/Cell.mjs +11 -4
  6. package/es/cell/index.d.ts +9 -0
  7. package/es/collapse-item/CollapseItem.d.ts +13 -0
  8. package/es/collapse-item/index.d.ts +9 -0
  9. package/es/coupon/index.css +1 -1
  10. package/es/coupon-list/index.css +1 -1
  11. package/es/date-picker/DatePicker.mjs +4 -1
  12. package/es/date-picker/utils.d.ts +1 -0
  13. package/es/date-picker/utils.mjs +11 -0
  14. package/es/field/Field.d.ts +13 -0
  15. package/es/field/Field.mjs +3 -3
  16. package/es/field/index.css +1 -1
  17. package/es/field/index.d.ts +9 -0
  18. package/es/field/types.d.ts +1 -1
  19. package/es/image-preview/ImagePreview.mjs +3 -1
  20. package/es/image-preview/ImagePreviewItem.mjs +7 -2
  21. package/es/image-preview/index.css +1 -1
  22. package/es/index.d.ts +1 -1
  23. package/es/index.mjs +1 -1
  24. package/es/loading/Loading.mjs +8 -4
  25. package/es/nav-bar/NavBar.d.ts +13 -0
  26. package/es/nav-bar/NavBar.mjs +4 -3
  27. package/es/nav-bar/index.d.ts +9 -0
  28. package/es/stepper/Stepper.d.ts +13 -0
  29. package/es/stepper/Stepper.mjs +4 -3
  30. package/es/stepper/index.d.ts +9 -0
  31. package/es/swipe/Swipe.mjs +1 -1
  32. package/es/tabs/Tabs.mjs +44 -41
  33. package/es/time-picker/TimePicker.mjs +4 -3
  34. package/es/toast/Toast.d.ts +4 -1
  35. package/es/toast/Toast.mjs +2 -1
  36. package/es/toast/index.css +1 -1
  37. package/es/toast/index.d.ts +3 -1
  38. package/es/toast/types.d.ts +2 -0
  39. package/lib/calendar/Calendar.js +10 -3
  40. package/lib/calendar/CalendarHeader.d.ts +2 -0
  41. package/lib/calendar/CalendarHeader.js +5 -1
  42. package/lib/cell/Cell.d.ts +17 -0
  43. package/lib/cell/Cell.js +10 -3
  44. package/lib/cell/index.d.ts +9 -0
  45. package/lib/collapse-item/CollapseItem.d.ts +13 -0
  46. package/lib/collapse-item/index.d.ts +9 -0
  47. package/lib/coupon/index.css +1 -1
  48. package/lib/coupon-list/index.css +1 -1
  49. package/lib/date-picker/DatePicker.js +3 -0
  50. package/lib/date-picker/utils.d.ts +1 -0
  51. package/lib/date-picker/utils.js +11 -0
  52. package/lib/field/Field.d.ts +13 -0
  53. package/lib/field/Field.js +3 -3
  54. package/lib/field/index.css +1 -1
  55. package/lib/field/index.d.ts +9 -0
  56. package/lib/field/types.d.ts +1 -1
  57. package/lib/image-preview/ImagePreview.js +3 -1
  58. package/lib/image-preview/ImagePreviewItem.js +7 -2
  59. package/lib/image-preview/index.css +1 -1
  60. package/lib/index.css +1 -1
  61. package/lib/index.d.ts +1 -1
  62. package/lib/index.js +1 -1
  63. package/lib/loading/Loading.js +8 -4
  64. package/lib/nav-bar/NavBar.d.ts +13 -0
  65. package/lib/nav-bar/NavBar.js +4 -3
  66. package/lib/nav-bar/index.d.ts +9 -0
  67. package/lib/stepper/Stepper.d.ts +13 -0
  68. package/lib/stepper/Stepper.js +4 -3
  69. package/lib/stepper/index.d.ts +9 -0
  70. package/lib/swipe/Swipe.js +1 -1
  71. package/lib/tabs/Tabs.js +44 -41
  72. package/lib/time-picker/TimePicker.js +3 -2
  73. package/lib/toast/Toast.d.ts +4 -1
  74. package/lib/toast/Toast.js +2 -1
  75. package/lib/toast/index.css +1 -1
  76. package/lib/toast/index.d.ts +3 -1
  77. package/lib/toast/types.d.ts +2 -0
  78. package/lib/vant.cjs.js +118 -69
  79. package/lib/vant.es.js +118 -69
  80. package/lib/vant.js +118 -69
  81. package/lib/vant.min.js +1 -1
  82. package/lib/web-types.json +671 -633
  83. package/package.json +2 -2
  84. package/changelog.generated.md +0 -59
package/lib/vant.js CHANGED
@@ -1106,6 +1106,13 @@
1106
1106
  const spinnerStyle = vue.computed(() => extend({
1107
1107
  color: props.color
1108
1108
  }, getSizeStyle(props.size)));
1109
+ const renderIcon = () => {
1110
+ const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
1111
+ return vue.createVNode("span", {
1112
+ "class": bem$1n("spinner", props.type),
1113
+ "style": spinnerStyle.value
1114
+ }, [slots.icon ? slots.icon() : DefaultIcon]);
1115
+ };
1109
1116
  const renderText = () => {
1110
1117
  var _a;
1111
1118
  if (slots.default) {
@@ -1129,10 +1136,7 @@
1129
1136
  }]),
1130
1137
  "aria-live": "polite",
1131
1138
  "aria-busy": true
1132
- }, [vue.createVNode("span", {
1133
- "class": bem$1n("spinner", type),
1134
- "style": spinnerStyle.value
1135
- }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
1139
+ }, [renderIcon(), renderText()]);
1136
1140
  };
1137
1141
  }
1138
1142
  });
@@ -2516,7 +2520,7 @@
2516
2520
  }
2517
2521
  return 0;
2518
2522
  });
2519
- const maxCount = vue.computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
2523
+ const maxCount = vue.computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
2520
2524
  const trackSize = vue.computed(() => count.value * size.value);
2521
2525
  const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
2522
2526
  const isCorrectDirection = vue.computed(() => {
@@ -3007,17 +3011,19 @@
3007
3011
  const newTab = children[newIndex];
3008
3012
  const newName = getTabName(newTab, newIndex);
3009
3013
  const shouldEmitChange = state.currentIndex !== null;
3010
- state.currentIndex = newIndex;
3014
+ if (state.currentIndex !== newIndex) {
3015
+ state.currentIndex = newIndex;
3016
+ if (!skipScrollIntoView) {
3017
+ scrollIntoView();
3018
+ }
3019
+ setLine();
3020
+ }
3011
3021
  if (newName !== props.active) {
3012
3022
  emit("update:active", newName);
3013
3023
  if (shouldEmitChange) {
3014
3024
  emit("change", newName, newTab.title);
3015
3025
  }
3016
3026
  }
3017
- if (!skipScrollIntoView) {
3018
- scrollIntoView();
3019
- }
3020
- setLine();
3021
3027
  if (stickyFixed && !props.scrollspy) {
3022
3028
  setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
3023
3029
  }
@@ -3116,13 +3122,14 @@
3116
3122
  }
3117
3123
  };
3118
3124
  const renderHeader = () => {
3119
- var _a, _b;
3125
+ var _a, _b, _c;
3120
3126
  const {
3121
3127
  type,
3122
- border
3128
+ border,
3129
+ sticky
3123
3130
  } = props;
3124
- return vue.createVNode("div", {
3125
- "ref": wrapRef,
3131
+ const Header = [vue.createVNode("div", {
3132
+ "ref": sticky ? void 0 : wrapRef,
3126
3133
  "class": [bem$1a("wrap"), {
3127
3134
  [BORDER_TOP_BOTTOM]: type === "line" && border
3128
3135
  }]
@@ -3135,7 +3142,13 @@
3135
3142
  }]),
3136
3143
  "style": navStyle.value,
3137
3144
  "aria-orientation": "horizontal"
3138
- }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]);
3145
+ }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
3146
+ if (sticky) {
3147
+ return vue.createVNode("div", {
3148
+ "ref": wrapRef
3149
+ }, [Header]);
3150
+ }
3151
+ return Header;
3139
3152
  };
3140
3153
  vue.watch([() => props.color, windowWidth], setLine);
3141
3154
  vue.watch(() => props.active, (value) => {
@@ -3189,37 +3202,31 @@
3189
3202
  currentName,
3190
3203
  scrollIntoView
3191
3204
  });
3192
- return () => {
3193
- var _a;
3194
- return vue.createVNode("div", {
3195
- "ref": root,
3196
- "class": bem$1a([props.type])
3197
- }, [props.sticky ? vue.createVNode(Sticky, {
3198
- "container": root.value,
3199
- "offsetTop": offsetTopPx.value,
3200
- "onScroll": onStickyScroll
3201
- }, {
3202
- default: () => {
3203
- var _a2;
3204
- return [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)];
3205
- }
3206
- }) : [renderHeader(), (_a = slots["nav-bottom"]) == null ? void 0 : _a.call(slots)], vue.createVNode(stdin_default$1n, {
3207
- "ref": contentRef,
3208
- "count": children.length,
3209
- "inited": state.inited,
3210
- "animated": props.animated,
3211
- "duration": props.duration,
3212
- "swipeable": props.swipeable,
3213
- "lazyRender": props.lazyRender,
3214
- "currentIndex": state.currentIndex,
3215
- "onChange": setCurrentIndex
3216
- }, {
3217
- default: () => {
3218
- var _a2;
3219
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
3220
- }
3221
- })]);
3222
- };
3205
+ return () => vue.createVNode("div", {
3206
+ "ref": root,
3207
+ "class": bem$1a([props.type])
3208
+ }, [props.sticky ? vue.createVNode(Sticky, {
3209
+ "container": root.value,
3210
+ "offsetTop": offsetTopPx.value,
3211
+ "onScroll": onStickyScroll
3212
+ }, {
3213
+ default: () => [renderHeader()]
3214
+ }) : renderHeader(), vue.createVNode(stdin_default$1n, {
3215
+ "ref": contentRef,
3216
+ "count": children.length,
3217
+ "inited": state.inited,
3218
+ "animated": props.animated,
3219
+ "duration": props.duration,
3220
+ "swipeable": props.swipeable,
3221
+ "lazyRender": props.lazyRender,
3222
+ "currentIndex": state.currentIndex,
3223
+ "onChange": setCurrentIndex
3224
+ }, {
3225
+ default: () => {
3226
+ var _a;
3227
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
3228
+ }
3229
+ })]);
3223
3230
  }
3224
3231
  });
3225
3232
  const TAB_STATUS_KEY = Symbol();
@@ -3785,6 +3792,7 @@
3785
3792
  const Area = withInstall(stdin_default$1h);
3786
3793
  const [name$19, bem$15] = createNamespace("cell");
3787
3794
  const cellSharedProps = {
3795
+ tag: makeStringProp("div"),
3788
3796
  icon: String,
3789
3797
  size: String,
3790
3798
  title: numericProp,
@@ -3863,8 +3871,9 @@
3863
3871
  }
3864
3872
  };
3865
3873
  return () => {
3866
- var _a, _b;
3874
+ var _a;
3867
3875
  const {
3876
+ tag,
3868
3877
  size,
3869
3878
  center,
3870
3879
  border,
@@ -3881,12 +3890,17 @@
3881
3890
  if (size) {
3882
3891
  classes[size] = !!size;
3883
3892
  }
3884
- return vue.createVNode("div", {
3893
+ return vue.createVNode(tag, {
3885
3894
  "class": bem$15(classes),
3886
3895
  "role": clickable ? "button" : void 0,
3887
3896
  "tabindex": clickable ? 0 : void 0,
3888
3897
  "onClick": route2
3889
- }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
3898
+ }, {
3899
+ default: () => {
3900
+ var _a2;
3901
+ return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
3902
+ }
3903
+ });
3890
3904
  };
3891
3905
  }
3892
3906
  });
@@ -4549,9 +4563,9 @@
4549
4563
  const labelAlign = getProp("labelAlign");
4550
4564
  const Label = renderLabel();
4551
4565
  const LeftIcon = renderLeftIcon();
4566
+ const renderTitle = () => labelAlign === "top" ? [LeftIcon, Label] : Label;
4552
4567
  return vue.createVNode(Cell, {
4553
4568
  "size": props.size,
4554
- "icon": props.leftIcon,
4555
4569
  "class": bem$13({
4556
4570
  error: showError.value,
4557
4571
  disabled,
@@ -4568,8 +4582,8 @@
4568
4582
  }]), props.labelClass],
4569
4583
  "arrowDirection": props.arrowDirection
4570
4584
  }, {
4571
- icon: LeftIcon ? () => LeftIcon : null,
4572
- title: Label ? () => Label : null,
4585
+ icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
4586
+ title: Label || labelAlign === "top" ? renderTitle : null,
4573
4587
  value: renderFieldBody,
4574
4588
  extra: slots.extra
4575
4589
  });
@@ -4603,6 +4617,7 @@
4603
4617
  duration: makeNumberProp(2e3),
4604
4618
  position: makeStringProp("middle"),
4605
4619
  teleport: [String, Object],
4620
+ wordBreak: String,
4606
4621
  className: unknownProp,
4607
4622
  iconPrefix: String,
4608
4623
  transition: makeStringProp("van-fade"),
@@ -4694,7 +4709,7 @@
4694
4709
  vue.onMounted(toggleClickable);
4695
4710
  vue.onUnmounted(toggleClickable);
4696
4711
  return () => vue.createVNode(Popup, vue.mergeProps({
4697
- "class": [bem$12([props.position, {
4712
+ "class": [bem$12([props.position, props.wordBreak === "normal" ? "break-normal" : props.wordBreak, {
4698
4713
  [props.type]: !props.icon
4699
4714
  }]), props.className],
4700
4715
  "lockScroll": false,
@@ -5757,6 +5772,16 @@
5757
5772
  });
5758
5773
  return filter ? filter(type, options) : options;
5759
5774
  };
5775
+ const formatValueRange = (values, columns) => values.map((value, index) => {
5776
+ const column = columns[index];
5777
+ if (column.length) {
5778
+ const maxValue = +column[column.length - 1].value;
5779
+ if (+value > maxValue) {
5780
+ return String(maxValue);
5781
+ }
5782
+ }
5783
+ return value;
5784
+ });
5760
5785
  const [name$Y] = createNamespace("calendar-day");
5761
5786
  var stdin_default$13 = vue.defineComponent({
5762
5787
  name: name$Y,
@@ -6079,6 +6104,7 @@
6079
6104
  var stdin_default$11 = vue.defineComponent({
6080
6105
  name: name$W,
6081
6106
  props: {
6107
+ date: Date,
6082
6108
  title: String,
6083
6109
  subtitle: String,
6084
6110
  showTitle: Boolean,
@@ -6102,7 +6128,10 @@
6102
6128
  const onClickSubtitle = (event) => emit("clickSubtitle", event);
6103
6129
  const renderSubtitle = () => {
6104
6130
  if (props.showSubtitle) {
6105
- const title = slots.subtitle ? slots.subtitle() : props.subtitle;
6131
+ const title = slots.subtitle ? slots.subtitle({
6132
+ date: props.date,
6133
+ text: props.subtitle
6134
+ }) : props.subtitle;
6106
6135
  return vue.createVNode("div", {
6107
6136
  "class": bem$V("header-subtitle"),
6108
6137
  "onClick": onClickSubtitle
@@ -6222,7 +6251,10 @@
6222
6251
  };
6223
6252
  let bodyHeight;
6224
6253
  const bodyRef = vue.ref();
6225
- const subtitle = vue.ref("");
6254
+ const subtitle = vue.ref({
6255
+ text: "",
6256
+ date: void 0
6257
+ });
6226
6258
  const currentDate = vue.ref(getInitialDate());
6227
6259
  const [monthRefs, setMonthRefs] = useRefs();
6228
6260
  const dayOffset = vue.computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
@@ -6283,7 +6315,10 @@
6283
6315
  monthRefs.value[index].setVisible(visible);
6284
6316
  });
6285
6317
  if (currentMonth) {
6286
- subtitle.value = currentMonth.getTitle();
6318
+ subtitle.value = {
6319
+ text: currentMonth.getTitle(),
6320
+ date: currentMonth.date
6321
+ };
6287
6322
  }
6288
6323
  };
6289
6324
  const scrollToDate = (targetDate) => {
@@ -6473,8 +6508,9 @@
6473
6508
  const renderCalendar = () => vue.createVNode("div", {
6474
6509
  "class": bem$V()
6475
6510
  }, [vue.createVNode(stdin_default$11, {
6511
+ "date": subtitle.value.date,
6476
6512
  "title": props.title,
6477
- "subtitle": subtitle.value,
6513
+ "subtitle": subtitle.value.text,
6478
6514
  "showTitle": props.showTitle,
6479
6515
  "showSubtitle": props.showSubtitle,
6480
6516
  "firstDayOfWeek": dayOffset.value,
@@ -8675,9 +8711,12 @@
8675
8711
  }
8676
8712
  });
8677
8713
  vue.watch(() => props.modelValue, (newValues) => {
8714
+ newValues = formatValueRange(newValues, columns.value);
8678
8715
  if (!isSameValue(newValues, currentValues.value)) {
8679
8716
  currentValues.value = newValues;
8680
8717
  }
8718
+ }, {
8719
+ immediate: true
8681
8720
  });
8682
8721
  const onChange = (...args) => emit("change", ...args);
8683
8722
  const onCancel = (...args) => emit("cancel", ...args);
@@ -9479,7 +9518,8 @@
9479
9518
  },
9480
9519
  emits: ["scale", "close"],
9481
9520
  setup(props, {
9482
- emit
9521
+ emit,
9522
+ slots
9483
9523
  }) {
9484
9524
  const state = vue.reactive({
9485
9525
  scale: 1,
@@ -9697,7 +9737,11 @@
9697
9737
  "onTouchend": onTouchEnd,
9698
9738
  "onTouchcancel": onTouchEnd
9699
9739
  }, {
9700
- default: () => [vue.createVNode(Image$1, {
9740
+ default: () => [slots.image ? vue.createVNode("div", {
9741
+ "class": bem$v("image-wrap")
9742
+ }, [slots.image({
9743
+ src: props.src
9744
+ })]) : vue.createVNode(Image$1, {
9701
9745
  "src": props.src,
9702
9746
  "fit": "contain",
9703
9747
  "class": bem$v("image", {
@@ -9806,7 +9850,9 @@
9806
9850
  "rootHeight": state.rootHeight,
9807
9851
  "onScale": emitScale,
9808
9852
  "onClose": emitClose
9809
- }, null))]
9853
+ }, {
9854
+ image: slots.image
9855
+ }))]
9810
9856
  });
9811
9857
  const renderClose = () => {
9812
9858
  if (props.closeable) {
@@ -10349,7 +10395,8 @@
10349
10395
  rightText: String,
10350
10396
  leftArrow: Boolean,
10351
10397
  placeholder: Boolean,
10352
- safeAreaInsetTop: Boolean
10398
+ safeAreaInsetTop: Boolean,
10399
+ clickable: truthProp
10353
10400
  };
10354
10401
  var stdin_default$w = vue.defineComponent({
10355
10402
  name: name$r,
@@ -10404,12 +10451,12 @@
10404
10451
  }, [vue.createVNode("div", {
10405
10452
  "class": bem$q("content")
10406
10453
  }, [hasLeft && vue.createVNode("div", {
10407
- "class": [bem$q("left"), HAPTICS_FEEDBACK],
10454
+ "class": [bem$q("left"), props.clickable ? HAPTICS_FEEDBACK : ""],
10408
10455
  "onClick": onClickLeft
10409
10456
  }, [renderLeft()]), vue.createVNode("div", {
10410
10457
  "class": [bem$q("title"), "van-ellipsis"]
10411
10458
  }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
10412
- "class": [bem$q("right"), HAPTICS_FEEDBACK],
10459
+ "class": [bem$q("right"), props.clickable ? HAPTICS_FEEDBACK : ""],
10413
10460
  "onClick": onClickRight
10414
10461
  }, [renderRight()])])]);
10415
10462
  };
@@ -13645,6 +13692,7 @@
13645
13692
  showMinus: truthProp,
13646
13693
  showInput: truthProp,
13647
13694
  longPress: truthProp,
13695
+ autoFixed: truthProp,
13648
13696
  allowEmpty: Boolean,
13649
13697
  modelValue: numericProp,
13650
13698
  inputWidth: numericProp,
@@ -13664,7 +13712,7 @@
13664
13712
  setup(props, {
13665
13713
  emit
13666
13714
  }) {
13667
- const format2 = (value) => {
13715
+ const format2 = (value, autoFixed = true) => {
13668
13716
  const {
13669
13717
  min,
13670
13718
  max,
@@ -13677,7 +13725,7 @@
13677
13725
  value = formatNumber(String(value), !props.integer);
13678
13726
  value = value === "" ? 0 : +value;
13679
13727
  value = Number.isNaN(value) ? +min : value;
13680
- value = Math.max(Math.min(+max, value), +min);
13728
+ value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
13681
13729
  if (isDef(decimalLength)) {
13682
13730
  value = value.toFixed(+decimalLength);
13683
13731
  }
@@ -13761,7 +13809,7 @@
13761
13809
  };
13762
13810
  const onBlur = (event) => {
13763
13811
  const input = event.target;
13764
- const value = format2(input.value);
13812
+ const value = format2(input.value, props.autoFixed);
13765
13813
  input.value = String(value);
13766
13814
  current2.value = value;
13767
13815
  vue.nextTick(() => {
@@ -14357,13 +14405,14 @@
14357
14405
  if (!isSameValue(newValues, props.modelValue)) {
14358
14406
  emit("update:modelValue", newValues);
14359
14407
  }
14360
- }, {
14361
- immediate: true
14362
14408
  });
14363
14409
  vue.watch(() => props.modelValue, (newValues) => {
14410
+ newValues = formatValueRange(newValues, columns.value);
14364
14411
  if (!isSameValue(newValues, currentValues.value)) {
14365
14412
  currentValues.value = newValues;
14366
14413
  }
14414
+ }, {
14415
+ immediate: true
14367
14416
  });
14368
14417
  const onChange = (...args) => emit("change", ...args);
14369
14418
  const onCancel = (...args) => emit("cancel", ...args);
@@ -15767,7 +15816,7 @@
15767
15816
  });
15768
15817
  }
15769
15818
  };
15770
- const version = "4.0.0-rc.4";
15819
+ const version = "4.0.0-rc.6";
15771
15820
  function install(app) {
15772
15821
  const components = [
15773
15822
  ActionBar,