vant 3.5.0-beta.1 → 3.5.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.
Files changed (69) hide show
  1. package/LICENSE +10 -0
  2. package/es/action-bar/ActionBar.d.ts +4 -0
  3. package/es/action-bar/ActionBar.mjs +13 -2
  4. package/es/action-bar/index.d.ts +3 -0
  5. package/es/calendar/Calendar.mjs +3 -0
  6. package/es/dialog/Dialog.d.ts +8 -0
  7. package/es/dialog/Dialog.mjs +6 -0
  8. package/es/dialog/function-call.d.ts +10 -0
  9. package/es/dialog/function-call.mjs +2 -0
  10. package/es/dialog/types.d.ts +3 -1
  11. package/es/field/Field.d.ts +3 -1
  12. package/es/field/Field.mjs +7 -1
  13. package/es/field/index.d.ts +3 -1
  14. package/es/index.d.ts +1 -1
  15. package/es/index.mjs +1 -1
  16. package/es/picker/Picker.mjs +1 -1
  17. package/es/picker/PickerColumn.mjs +2 -0
  18. package/es/popup/Popup.mjs +1 -1
  19. package/es/pull-refresh/PullRefresh.d.ts +2 -1
  20. package/es/pull-refresh/PullRefresh.mjs +5 -1
  21. package/es/pull-refresh/index.d.ts +2 -1
  22. package/es/submit-bar/SubmitBar.d.ts +4 -0
  23. package/es/submit-bar/SubmitBar.mjs +13 -2
  24. package/es/submit-bar/index.d.ts +3 -0
  25. package/es/switch/Switch.mjs +2 -1
  26. package/es/toast/function-call.d.ts +5 -6
  27. package/es/toast/types.d.ts +10 -1
  28. package/es/uploader/Uploader.d.ts +3 -3
  29. package/es/uploader/index.d.ts +2 -2
  30. package/lib/action-bar/ActionBar.d.ts +4 -0
  31. package/lib/action-bar/ActionBar.js +12 -1
  32. package/lib/action-bar/index.d.ts +3 -0
  33. package/lib/calendar/Calendar.js +3 -0
  34. package/lib/dialog/Dialog.d.ts +8 -0
  35. package/lib/dialog/Dialog.js +6 -0
  36. package/lib/dialog/function-call.d.ts +10 -0
  37. package/lib/dialog/function-call.js +2 -0
  38. package/lib/dialog/types.d.ts +3 -1
  39. package/lib/field/Field.d.ts +3 -1
  40. package/lib/field/Field.js +7 -1
  41. package/lib/field/index.d.ts +3 -1
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.js +1 -1
  44. package/lib/picker/Picker.js +1 -1
  45. package/lib/picker/PickerColumn.js +2 -0
  46. package/lib/popup/Popup.js +1 -1
  47. package/lib/pull-refresh/PullRefresh.d.ts +2 -1
  48. package/lib/pull-refresh/PullRefresh.js +5 -1
  49. package/lib/pull-refresh/index.d.ts +2 -1
  50. package/lib/submit-bar/SubmitBar.d.ts +4 -0
  51. package/lib/submit-bar/SubmitBar.js +12 -1
  52. package/lib/submit-bar/index.d.ts +3 -0
  53. package/lib/switch/Switch.js +2 -1
  54. package/lib/toast/function-call.d.ts +5 -6
  55. package/lib/toast/types.d.ts +10 -1
  56. package/lib/uploader/Uploader.d.ts +3 -3
  57. package/lib/uploader/index.d.ts +2 -2
  58. package/lib/vant.cjs.js +72 -28
  59. package/lib/vant.es.js +73 -29
  60. package/lib/vant.js +73 -29
  61. package/lib/vant.min.js +1 -1
  62. package/package.json +3 -3
  63. package/vetur/attributes.json +212 -196
  64. package/vetur/tags.json +72 -68
  65. package/vetur/web-types.json +1061 -994
  66. package/lib/ssr.js +0 -7
  67. package/lib/ssr.mjs +0 -1
  68. package/lib/vant.cjs.min.js +0 -1
  69. package/lib/vant.es.min.js +0 -14649
package/lib/vant.js CHANGED
@@ -352,7 +352,7 @@
352
352
  }
353
353
  return { width, height };
354
354
  }
355
- var overflowScrollReg = /scroll|auto/i;
355
+ var overflowScrollReg = /scroll|auto|overlay/i;
356
356
  var defaultRoot = inBrowser ? window : void 0;
357
357
  function isElement$1(node) {
358
358
  const ELEMENT_NODE_TYPE = 1;
@@ -747,9 +747,30 @@
747
747
  };
748
748
  return options;
749
749
  }
750
+ const useHeight = (element) => {
751
+ const height2 = vue.ref();
752
+ const setHeight = () => {
753
+ height2.value = useRect(element).height;
754
+ };
755
+ vue.onMounted(() => {
756
+ vue.nextTick(setHeight);
757
+ setTimeout(setHeight, 100);
758
+ });
759
+ return height2;
760
+ };
761
+ function usePlaceholder(contentRef, bem2) {
762
+ const height2 = useHeight(contentRef);
763
+ return (renderContent) => vue.createVNode("div", {
764
+ "class": bem2("placeholder"),
765
+ "style": {
766
+ height: height2.value ? `${height2.value}px` : void 0
767
+ }
768
+ }, [renderContent()]);
769
+ }
750
770
  const [name$1u, bem$1q] = createNamespace("action-bar");
751
771
  const ACTION_BAR_KEY = Symbol(name$1u);
752
772
  const actionBarProps = {
773
+ placeholder: Boolean,
753
774
  safeAreaInsetBottom: truthProp
754
775
  };
755
776
  var stdin_default$1B = vue.defineComponent({
@@ -758,18 +779,27 @@
758
779
  setup(props, {
759
780
  slots
760
781
  }) {
782
+ const root = vue.ref();
783
+ const renderPlaceholder = usePlaceholder(root, bem$1q);
761
784
  const {
762
785
  linkChildren
763
786
  } = useChildren(ACTION_BAR_KEY);
764
787
  linkChildren();
765
- return () => {
788
+ const renderActionBar = () => {
766
789
  var _a;
767
790
  return vue.createVNode("div", {
791
+ "ref": root,
768
792
  "class": [bem$1q(), {
769
793
  "van-safe-area-bottom": props.safeAreaInsetBottom
770
794
  }]
771
795
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
772
796
  };
797
+ return () => {
798
+ if (props.placeholder) {
799
+ return renderPlaceholder(renderActionBar);
800
+ }
801
+ return renderActionBar();
802
+ };
773
803
  }
774
804
  });
775
805
  const ActionBar = withInstall(stdin_default$1B);
@@ -1653,7 +1683,7 @@
1653
1683
  }
1654
1684
  });
1655
1685
  vue.onDeactivated(() => {
1656
- if (props.show) {
1686
+ if (props.show && props.teleport) {
1657
1687
  close();
1658
1688
  shouldReopen = true;
1659
1689
  }
@@ -2007,6 +2037,7 @@
2007
2037
  }
2008
2038
  };
2009
2039
  const getValue = () => state.options[state.index];
2040
+ const hasOptions = () => state.options.length;
2010
2041
  setIndex(state.index);
2011
2042
  useParent(PICKER_KEY);
2012
2043
  useExpose({
@@ -2015,6 +2046,7 @@
2015
2046
  getValue,
2016
2047
  setValue,
2017
2048
  setOptions,
2049
+ hasOptions,
2018
2050
  stopMomentum
2019
2051
  });
2020
2052
  vue.watch(() => props.initialOptions, setOptions);
@@ -2134,7 +2166,7 @@
2134
2166
  } else {
2135
2167
  formattedColumns.value = columns;
2136
2168
  }
2137
- hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0);
2169
+ hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
2138
2170
  };
2139
2171
  const getIndexes = () => children.map((child) => child.state.index);
2140
2172
  const setColumnValues = (index, options) => {
@@ -2967,7 +2999,7 @@
2967
2999
  var stdin_default$1l = vue.defineComponent({
2968
3000
  name: name$1e,
2969
3001
  props: fieldProps,
2970
- emits: ["blur", "focus", "clear", "keypress", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
3002
+ emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
2971
3003
  setup(props, {
2972
3004
  emit,
2973
3005
  slots
@@ -3041,18 +3073,24 @@
3041
3073
  state.status = "unvalidated";
3042
3074
  state.validateMessage = "";
3043
3075
  };
3076
+ const endValidate = () => emit("end-validate", {
3077
+ status: state.status
3078
+ });
3044
3079
  const validate = (rules = props.rules) => new Promise((resolve) => {
3045
3080
  resetValidation();
3046
3081
  if (rules) {
3082
+ emit("start-validate");
3047
3083
  runRules(rules).then(() => {
3048
3084
  if (state.status === "failed") {
3049
3085
  resolve({
3050
3086
  name: props.name,
3051
3087
  message: state.validateMessage
3052
3088
  });
3089
+ endValidate();
3053
3090
  } else {
3054
3091
  state.status = "passed";
3055
3092
  resolve();
3093
+ endValidate();
3056
3094
  }
3057
3095
  });
3058
3096
  } else {
@@ -3681,6 +3719,7 @@
3681
3719
  };
3682
3720
  useCustomFieldValue(() => props.modelValue);
3683
3721
  return () => {
3722
+ var _a;
3684
3723
  const {
3685
3724
  size,
3686
3725
  loading,
@@ -3706,7 +3745,7 @@
3706
3745
  "onClick": onClick
3707
3746
  }, [vue.createVNode("div", {
3708
3747
  "class": bem$18("node")
3709
- }, [renderLoading()])]);
3748
+ }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
3710
3749
  };
3711
3750
  }
3712
3751
  });
@@ -4596,17 +4635,6 @@
4596
4635
  }
4597
4636
  });
4598
4637
  };
4599
- const useHeight = (element) => {
4600
- const height2 = vue.ref();
4601
- const setHeight = () => {
4602
- height2.value = useRect(element).height;
4603
- };
4604
- vue.onMounted(() => {
4605
- vue.nextTick(setHeight);
4606
- setTimeout(setHeight, 100);
4607
- });
4608
- return height2;
4609
- };
4610
4638
  const [name$13] = createNamespace("calendar-day");
4611
4639
  var stdin_default$1a = vue.defineComponent({
4612
4640
  name: name$13,
@@ -5078,6 +5106,9 @@
5078
5106
  const months = vue.computed(() => {
5079
5107
  const months2 = [];
5080
5108
  const cursor = new Date(props.minDate);
5109
+ if (props.lazyRender && !props.show && props.poppable) {
5110
+ return months2;
5111
+ }
5081
5112
  cursor.setDate(1);
5082
5113
  do {
5083
5114
  months2.push(new Date(cursor));
@@ -8955,8 +8986,10 @@
8955
8986
  showCancelButton: Boolean,
8956
8987
  cancelButtonText: String,
8957
8988
  cancelButtonColor: String,
8989
+ cancelButtonDisabled: Boolean,
8958
8990
  confirmButtonText: String,
8959
8991
  confirmButtonColor: String,
8992
+ confirmButtonDisabled: Boolean,
8960
8993
  showConfirmButton: truthProp,
8961
8994
  closeOnClickOverlay: Boolean
8962
8995
  });
@@ -9077,6 +9110,7 @@
9077
9110
  color: props.cancelButtonColor
9078
9111
  },
9079
9112
  "loading": loading.cancel,
9113
+ "disabled": props.cancelButtonDisabled,
9080
9114
  "onClick": onCancel
9081
9115
  }, null), props.showConfirmButton && vue.createVNode(Button, {
9082
9116
  "size": "large",
@@ -9088,6 +9122,7 @@
9088
9122
  color: props.confirmButtonColor
9089
9123
  },
9090
9124
  "loading": loading.confirm,
9125
+ "disabled": props.confirmButtonDisabled,
9091
9126
  "onClick": onConfirm
9092
9127
  }, null)]);
9093
9128
  const renderRoundButtons = () => vue.createVNode(ActionBar, {
@@ -9099,6 +9134,7 @@
9099
9134
  "class": bem$A("cancel"),
9100
9135
  "color": props.cancelButtonColor,
9101
9136
  "loading": loading.cancel,
9137
+ "disabled": props.cancelButtonDisabled,
9102
9138
  "onClick": onCancel
9103
9139
  }, null), props.showConfirmButton && vue.createVNode(ActionBarButton, {
9104
9140
  "type": "danger",
@@ -9106,6 +9142,7 @@
9106
9142
  "class": bem$A("confirm"),
9107
9143
  "color": props.confirmButtonColor,
9108
9144
  "loading": loading.confirm,
9145
+ "disabled": props.confirmButtonDisabled,
9109
9146
  "onClick": onConfirm
9110
9147
  }, null)]
9111
9148
  });
@@ -9190,8 +9227,10 @@
9190
9227
  messageAlign: "",
9191
9228
  cancelButtonText: "",
9192
9229
  cancelButtonColor: null,
9230
+ cancelButtonDisabled: false,
9193
9231
  confirmButtonText: "",
9194
9232
  confirmButtonColor: null,
9233
+ confirmButtonDisabled: false,
9195
9234
  showConfirmButton: true,
9196
9235
  showCancelButton: false,
9197
9236
  closeOnPopstate: true,
@@ -10572,15 +10611,6 @@
10572
10611
  }
10573
10612
  });
10574
10613
  const List = withInstall(stdin_default$v);
10575
- function usePlaceholder(contentRef, bem2) {
10576
- const height2 = useHeight(contentRef);
10577
- return (renderContent) => vue.createVNode("div", {
10578
- "class": bem2("placeholder"),
10579
- "style": {
10580
- height: height2.value ? `${height2.value}px` : void 0
10581
- }
10582
- }, [renderContent()]);
10583
- }
10584
10614
  const [name$p, bem$p] = createNamespace("nav-bar");
10585
10615
  const navBarProps = {
10586
10616
  title: String,
@@ -12592,7 +12622,7 @@
12592
12622
  var stdin_default$l = vue.defineComponent({
12593
12623
  name: name$g,
12594
12624
  props: pullRefreshProps,
12595
- emits: ["refresh", "update:modelValue"],
12625
+ emits: ["change", "refresh", "update:modelValue"],
12596
12626
  setup(props, {
12597
12627
  emit,
12598
12628
  slots
@@ -12637,6 +12667,10 @@
12637
12667
  } else {
12638
12668
  state.status = "loosing";
12639
12669
  }
12670
+ emit("change", {
12671
+ status: state.status,
12672
+ distance
12673
+ });
12640
12674
  };
12641
12675
  const getStatusText = () => {
12642
12676
  const {
@@ -14021,6 +14055,7 @@
14021
14055
  buttonType: makeStringProp("danger"),
14022
14056
  buttonColor: String,
14023
14057
  suffixLabel: String,
14058
+ placeholder: Boolean,
14024
14059
  decimalLength: makeNumericProp(2),
14025
14060
  safeAreaInsetBottom: truthProp
14026
14061
  };
@@ -14032,6 +14067,8 @@
14032
14067
  emit,
14033
14068
  slots
14034
14069
  }) {
14070
+ const root = vue.ref();
14071
+ const renderPlaceholder = usePlaceholder(root, bem$5);
14035
14072
  const renderText = () => {
14036
14073
  const {
14037
14074
  price,
@@ -14091,9 +14128,10 @@
14091
14128
  "onClick": onClickButton
14092
14129
  }, null);
14093
14130
  };
14094
- return () => {
14131
+ const renderSubmitBar = () => {
14095
14132
  var _a, _b;
14096
14133
  return vue.createVNode("div", {
14134
+ "ref": root,
14097
14135
  "class": [bem$5(), {
14098
14136
  "van-safe-area-bottom": props.safeAreaInsetBottom
14099
14137
  }]
@@ -14101,6 +14139,12 @@
14101
14139
  "class": bem$5("bar")
14102
14140
  }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
14103
14141
  };
14142
+ return () => {
14143
+ if (props.placeholder) {
14144
+ return renderPlaceholder(renderSubmitBar);
14145
+ }
14146
+ return renderSubmitBar();
14147
+ };
14104
14148
  }
14105
14149
  });
14106
14150
  const SubmitBar = withInstall(stdin_default$a);
@@ -15793,7 +15837,7 @@
15793
15837
  });
15794
15838
  }
15795
15839
  };
15796
- const version = "3.5.0-beta.1";
15840
+ const version = "3.5.2";
15797
15841
  function install(app) {
15798
15842
  const components = [
15799
15843
  ActionBar,