vant 4.0.0-rc.3 → 4.0.0-rc.5

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 (47) hide show
  1. package/README.md +4 -5
  2. package/changelog.generated.md +47 -23
  3. package/es/date-picker/DatePicker.mjs +4 -1
  4. package/es/date-picker/utils.d.ts +1 -0
  5. package/es/date-picker/utils.mjs +11 -0
  6. package/es/field/Field.mjs +5 -4
  7. package/es/field/index.css +1 -1
  8. package/es/field/types.d.ts +1 -1
  9. package/es/index.d.ts +1 -1
  10. package/es/index.mjs +1 -1
  11. package/es/loading/Loading.mjs +8 -4
  12. package/es/nav-bar/NavBar.d.ts +13 -0
  13. package/es/nav-bar/NavBar.mjs +4 -3
  14. package/es/nav-bar/index.d.ts +9 -0
  15. package/es/notify/function-call.mjs +1 -1
  16. package/es/stepper/Stepper.d.ts +13 -0
  17. package/es/stepper/Stepper.mjs +4 -3
  18. package/es/stepper/index.d.ts +9 -0
  19. package/es/tab/Tab.mjs +12 -2
  20. package/es/tabs/Tabs.mjs +51 -48
  21. package/es/time-picker/TimePicker.mjs +4 -3
  22. package/lib/date-picker/DatePicker.js +3 -0
  23. package/lib/date-picker/utils.d.ts +1 -0
  24. package/lib/date-picker/utils.js +11 -0
  25. package/lib/field/Field.js +5 -4
  26. package/lib/field/index.css +1 -1
  27. package/lib/field/types.d.ts +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/index.d.ts +1 -1
  30. package/lib/index.js +1 -1
  31. package/lib/loading/Loading.js +8 -4
  32. package/lib/nav-bar/NavBar.d.ts +13 -0
  33. package/lib/nav-bar/NavBar.js +4 -3
  34. package/lib/nav-bar/index.d.ts +9 -0
  35. package/lib/notify/function-call.js +1 -1
  36. package/lib/stepper/Stepper.d.ts +13 -0
  37. package/lib/stepper/Stepper.js +4 -3
  38. package/lib/stepper/index.d.ts +9 -0
  39. package/lib/tab/Tab.js +11 -1
  40. package/lib/tabs/Tabs.js +51 -48
  41. package/lib/time-picker/TimePicker.js +3 -2
  42. package/lib/vant.cjs.js +101 -67
  43. package/lib/vant.es.js +101 -67
  44. package/lib/vant.js +101 -67
  45. package/lib/vant.min.js +1 -1
  46. package/lib/web-types.json +523 -499
  47. package/package.json +5 -5
package/lib/vant.cjs.js CHANGED
@@ -739,6 +739,13 @@ var stdin_default$1z = vue.defineComponent({
739
739
  const spinnerStyle = vue.computed(() => extend({
740
740
  color: props.color
741
741
  }, getSizeStyle(props.size)));
742
+ const renderIcon = () => {
743
+ const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
744
+ return vue.createVNode("span", {
745
+ "class": bem$1n("spinner", props.type),
746
+ "style": spinnerStyle.value
747
+ }, [slots.icon ? slots.icon() : DefaultIcon]);
748
+ };
742
749
  const renderText = () => {
743
750
  var _a;
744
751
  if (slots.default) {
@@ -762,10 +769,7 @@ var stdin_default$1z = vue.defineComponent({
762
769
  }]),
763
770
  "aria-live": "polite",
764
771
  "aria-busy": true
765
- }, [vue.createVNode("span", {
766
- "class": bem$1n("spinner", type),
767
- "style": spinnerStyle.value
768
- }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
772
+ }, [renderIcon(), renderText()]);
769
773
  };
770
774
  }
771
775
  });
@@ -2635,7 +2639,7 @@ var stdin_default$1m = vue.defineComponent({
2635
2639
  index += diff;
2636
2640
  }
2637
2641
  };
2638
- const setCurrentIndex = (currentIndex) => {
2642
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
2639
2643
  const newIndex = findAvailableTab(currentIndex);
2640
2644
  if (!isDef(newIndex)) {
2641
2645
  return;
@@ -2643,18 +2647,27 @@ var stdin_default$1m = vue.defineComponent({
2643
2647
  const newTab = children[newIndex];
2644
2648
  const newName = getTabName(newTab, newIndex);
2645
2649
  const shouldEmitChange = state.currentIndex !== null;
2646
- state.currentIndex = newIndex;
2650
+ if (state.currentIndex !== newIndex) {
2651
+ state.currentIndex = newIndex;
2652
+ if (!skipScrollIntoView) {
2653
+ scrollIntoView();
2654
+ }
2655
+ setLine();
2656
+ }
2647
2657
  if (newName !== props.active) {
2648
2658
  emit("update:active", newName);
2649
2659
  if (shouldEmitChange) {
2650
2660
  emit("change", newName, newTab.title);
2651
2661
  }
2652
2662
  }
2663
+ if (stickyFixed && !props.scrollspy) {
2664
+ setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
2665
+ }
2653
2666
  };
2654
- const setCurrentIndexByName = (name2) => {
2667
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
2655
2668
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
2656
2669
  const index = matched ? children.indexOf(matched) : 0;
2657
- setCurrentIndex(index);
2670
+ setCurrentIndex(index, skipScrollIntoView);
2658
2671
  };
2659
2672
  const scrollToCurrentContent = (immediate = false) => {
2660
2673
  if (props.scrollspy) {
@@ -2745,13 +2758,14 @@ var stdin_default$1m = vue.defineComponent({
2745
2758
  }
2746
2759
  };
2747
2760
  const renderHeader = () => {
2748
- var _a, _b;
2761
+ var _a, _b, _c;
2749
2762
  const {
2750
2763
  type,
2751
- border
2764
+ border,
2765
+ sticky
2752
2766
  } = props;
2753
- return vue.createVNode("div", {
2754
- "ref": wrapRef,
2767
+ const Header = [vue.createVNode("div", {
2768
+ "ref": sticky ? void 0 : wrapRef,
2755
2769
  "class": [bem$1a("wrap"), {
2756
2770
  [BORDER_TOP_BOTTOM]: type === "line" && border
2757
2771
  }]
@@ -2764,7 +2778,13 @@ var stdin_default$1m = vue.defineComponent({
2764
2778
  }]),
2765
2779
  "style": navStyle.value,
2766
2780
  "aria-orientation": "horizontal"
2767
- }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]);
2781
+ }, [(_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)];
2782
+ if (sticky) {
2783
+ return vue.createVNode("div", {
2784
+ "ref": wrapRef
2785
+ }, [Header]);
2786
+ }
2787
+ return Header;
2768
2788
  };
2769
2789
  vue.watch([() => props.color, windowWidth], setLine);
2770
2790
  vue.watch(() => props.active, (value) => {
@@ -2781,15 +2801,8 @@ var stdin_default$1m = vue.defineComponent({
2781
2801
  });
2782
2802
  }
2783
2803
  });
2784
- vue.watch(() => state.currentIndex, () => {
2785
- scrollIntoView();
2786
- setLine();
2787
- if (stickyFixed && !props.scrollspy) {
2788
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
2789
- }
2790
- });
2791
2804
  const init = () => {
2792
- setCurrentIndexByName(props.active);
2805
+ setCurrentIndexByName(props.active, true);
2793
2806
  vue.nextTick(() => {
2794
2807
  state.inited = true;
2795
2808
  if (wrapRef.value) {
@@ -2825,37 +2838,31 @@ var stdin_default$1m = vue.defineComponent({
2825
2838
  currentName,
2826
2839
  scrollIntoView
2827
2840
  });
2828
- return () => {
2829
- var _a;
2830
- return vue.createVNode("div", {
2831
- "ref": root,
2832
- "class": bem$1a([props.type])
2833
- }, [props.sticky ? vue.createVNode(Sticky, {
2834
- "container": root.value,
2835
- "offsetTop": offsetTopPx.value,
2836
- "onScroll": onStickyScroll
2837
- }, {
2838
- default: () => {
2839
- var _a2;
2840
- return [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)];
2841
- }
2842
- }) : [renderHeader(), (_a = slots["nav-bottom"]) == null ? void 0 : _a.call(slots)], vue.createVNode(stdin_default$1n, {
2843
- "ref": contentRef,
2844
- "count": children.length,
2845
- "inited": state.inited,
2846
- "animated": props.animated,
2847
- "duration": props.duration,
2848
- "swipeable": props.swipeable,
2849
- "lazyRender": props.lazyRender,
2850
- "currentIndex": state.currentIndex,
2851
- "onChange": setCurrentIndex
2852
- }, {
2853
- default: () => {
2854
- var _a2;
2855
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
2856
- }
2857
- })]);
2858
- };
2841
+ return () => vue.createVNode("div", {
2842
+ "ref": root,
2843
+ "class": bem$1a([props.type])
2844
+ }, [props.sticky ? vue.createVNode(Sticky, {
2845
+ "container": root.value,
2846
+ "offsetTop": offsetTopPx.value,
2847
+ "onScroll": onStickyScroll
2848
+ }, {
2849
+ default: () => [renderHeader()]
2850
+ }) : renderHeader(), vue.createVNode(stdin_default$1n, {
2851
+ "ref": contentRef,
2852
+ "count": children.length,
2853
+ "inited": state.inited,
2854
+ "animated": props.animated,
2855
+ "duration": props.duration,
2856
+ "swipeable": props.swipeable,
2857
+ "lazyRender": props.lazyRender,
2858
+ "currentIndex": state.currentIndex,
2859
+ "onChange": setCurrentIndex
2860
+ }, {
2861
+ default: () => {
2862
+ var _a;
2863
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
2864
+ }
2865
+ })]);
2859
2866
  }
2860
2867
  });
2861
2868
  const TAB_STATUS_KEY = Symbol();
@@ -2982,6 +2989,16 @@ var stdin_default$1k = vue.defineComponent({
2982
2989
  }
2983
2990
  return isActive;
2984
2991
  });
2992
+ const hasInactiveClass = vue.ref(!active.value);
2993
+ vue.watch(active, (val) => {
2994
+ if (val) {
2995
+ hasInactiveClass.value = false;
2996
+ } else {
2997
+ use.doubleRaf(() => {
2998
+ hasInactiveClass.value = true;
2999
+ });
3000
+ }
3001
+ });
2985
3002
  vue.watch(() => props.title, () => {
2986
3003
  parent.setLine();
2987
3004
  parent.scrollIntoView();
@@ -3005,7 +3022,7 @@ var stdin_default$1k = vue.defineComponent({
3005
3022
  "id": id,
3006
3023
  "role": "tabpanel",
3007
3024
  "class": bem$18("panel-wrapper", {
3008
- inactive: !active.value
3025
+ inactive: hasInactiveClass.value
3009
3026
  }),
3010
3027
  "tabindex": active.value ? 0 : -1,
3011
3028
  "aria-hidden": !active.value,
@@ -3891,7 +3908,8 @@ var stdin_default$1e = vue.defineComponent({
3891
3908
  state.validateMessage = "";
3892
3909
  };
3893
3910
  const endValidate = () => emit("endValidate", {
3894
- status: state.status
3911
+ status: state.status,
3912
+ message: state.validateMessage
3895
3913
  });
3896
3914
  const validate = (rules = props.rules) => new Promise((resolve) => {
3897
3915
  resetValidation();
@@ -4180,9 +4198,9 @@ var stdin_default$1e = vue.defineComponent({
4180
4198
  const labelAlign = getProp("labelAlign");
4181
4199
  const Label = renderLabel();
4182
4200
  const LeftIcon = renderLeftIcon();
4201
+ const renderTitle = () => labelAlign === "top" ? [LeftIcon, Label] : Label;
4183
4202
  return vue.createVNode(Cell, {
4184
4203
  "size": props.size,
4185
- "icon": props.leftIcon,
4186
4204
  "class": bem$13({
4187
4205
  error: showError.value,
4188
4206
  disabled,
@@ -4199,8 +4217,8 @@ var stdin_default$1e = vue.defineComponent({
4199
4217
  }]), props.labelClass],
4200
4218
  "arrowDirection": props.arrowDirection
4201
4219
  }, {
4202
- icon: LeftIcon ? () => LeftIcon : null,
4203
- title: Label ? () => Label : null,
4220
+ icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
4221
+ title: Label || labelAlign === "top" ? renderTitle : null,
4204
4222
  value: renderFieldBody,
4205
4223
  extra: slots.extra
4206
4224
  });
@@ -5388,6 +5406,16 @@ const genOptions = (min, max, type, formatter, filter) => {
5388
5406
  });
5389
5407
  return filter ? filter(type, options) : options;
5390
5408
  };
5409
+ const formatValueRange = (values, columns) => values.map((value, index) => {
5410
+ const column = columns[index];
5411
+ if (column.length) {
5412
+ const maxValue = +column[column.length - 1].value;
5413
+ if (+value > maxValue) {
5414
+ return String(maxValue);
5415
+ }
5416
+ }
5417
+ return value;
5418
+ });
5391
5419
  const [name$Y] = createNamespace("calendar-day");
5392
5420
  var stdin_default$13 = vue.defineComponent({
5393
5421
  name: name$Y,
@@ -8323,9 +8351,12 @@ var stdin_default$I = vue.defineComponent({
8323
8351
  }
8324
8352
  });
8325
8353
  vue.watch(() => props.modelValue, (newValues) => {
8354
+ newValues = formatValueRange(newValues, columns.value);
8326
8355
  if (!isSameValue(newValues, currentValues.value)) {
8327
8356
  currentValues.value = newValues;
8328
8357
  }
8358
+ }, {
8359
+ immediate: true
8329
8360
  });
8330
8361
  const onChange = (...args) => emit("change", ...args);
8331
8362
  const onCancel = (...args) => emit("cancel", ...args);
@@ -10006,7 +10037,8 @@ const navBarProps = {
10006
10037
  rightText: String,
10007
10038
  leftArrow: Boolean,
10008
10039
  placeholder: Boolean,
10009
- safeAreaInsetTop: Boolean
10040
+ safeAreaInsetTop: Boolean,
10041
+ clickable: truthProp
10010
10042
  };
10011
10043
  var stdin_default$w = vue.defineComponent({
10012
10044
  name: name$r,
@@ -10061,12 +10093,12 @@ var stdin_default$w = vue.defineComponent({
10061
10093
  }, [vue.createVNode("div", {
10062
10094
  "class": bem$q("content")
10063
10095
  }, [hasLeft && vue.createVNode("div", {
10064
- "class": [bem$q("left"), HAPTICS_FEEDBACK],
10096
+ "class": [bem$q("left"), props.clickable ? HAPTICS_FEEDBACK : ""],
10065
10097
  "onClick": onClickLeft
10066
10098
  }, [renderLeft()]), vue.createVNode("div", {
10067
10099
  "class": [bem$q("title"), "van-ellipsis"]
10068
10100
  }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
10069
- "class": [bem$q("right"), HAPTICS_FEEDBACK],
10101
+ "class": [bem$q("right"), props.clickable ? HAPTICS_FEEDBACK : ""],
10070
10102
  "onClick": onClickRight
10071
10103
  }, [renderRight()])])]);
10072
10104
  };
@@ -10322,7 +10354,7 @@ function showNotify(options) {
10322
10354
  instance.open(options);
10323
10355
  clearTimeout(timer);
10324
10356
  if (options.duration > 0) {
10325
- timer = window.setTimeout(closeNotify, options.duration);
10357
+ timer = setTimeout(closeNotify, options.duration);
10326
10358
  }
10327
10359
  return instance;
10328
10360
  }
@@ -12399,6 +12431,7 @@ const stepperProps = {
12399
12431
  showMinus: truthProp,
12400
12432
  showInput: truthProp,
12401
12433
  longPress: truthProp,
12434
+ autoFixed: truthProp,
12402
12435
  allowEmpty: Boolean,
12403
12436
  modelValue: numericProp,
12404
12437
  inputWidth: numericProp,
@@ -12418,7 +12451,7 @@ var stdin_default$c = vue.defineComponent({
12418
12451
  setup(props, {
12419
12452
  emit
12420
12453
  }) {
12421
- const format2 = (value) => {
12454
+ const format2 = (value, autoFixed = true) => {
12422
12455
  const {
12423
12456
  min,
12424
12457
  max,
@@ -12431,7 +12464,7 @@ var stdin_default$c = vue.defineComponent({
12431
12464
  value = formatNumber(String(value), !props.integer);
12432
12465
  value = value === "" ? 0 : +value;
12433
12466
  value = Number.isNaN(value) ? +min : value;
12434
- value = Math.max(Math.min(+max, value), +min);
12467
+ value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
12435
12468
  if (isDef(decimalLength)) {
12436
12469
  value = value.toFixed(+decimalLength);
12437
12470
  }
@@ -12515,7 +12548,7 @@ var stdin_default$c = vue.defineComponent({
12515
12548
  };
12516
12549
  const onBlur = (event) => {
12517
12550
  const input = event.target;
12518
- const value = format2(input.value);
12551
+ const value = format2(input.value, props.autoFixed);
12519
12552
  input.value = String(value);
12520
12553
  current2.value = value;
12521
12554
  vue.nextTick(() => {
@@ -13114,13 +13147,14 @@ var stdin_default$7 = vue.defineComponent({
13114
13147
  if (!isSameValue(newValues, props.modelValue)) {
13115
13148
  emit("update:modelValue", newValues);
13116
13149
  }
13117
- }, {
13118
- immediate: true
13119
13150
  });
13120
13151
  vue.watch(() => props.modelValue, (newValues) => {
13152
+ newValues = formatValueRange(newValues, columns.value);
13121
13153
  if (!isSameValue(newValues, currentValues.value)) {
13122
13154
  currentValues.value = newValues;
13123
13155
  }
13156
+ }, {
13157
+ immediate: true
13124
13158
  });
13125
13159
  const onChange = (...args) => emit("change", ...args);
13126
13160
  const onCancel = (...args) => emit("cancel", ...args);
@@ -14541,7 +14575,7 @@ const Lazyload = {
14541
14575
  });
14542
14576
  }
14543
14577
  };
14544
- const version = "4.0.0-rc.3";
14578
+ const version = "4.0.0-rc.5";
14545
14579
  function install(app) {
14546
14580
  const components = [
14547
14581
  ActionBar,