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.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
  });
@@ -2999,7 +3003,7 @@
2999
3003
  index += diff;
3000
3004
  }
3001
3005
  };
3002
- const setCurrentIndex = (currentIndex) => {
3006
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
3003
3007
  const newIndex = findAvailableTab(currentIndex);
3004
3008
  if (!isDef(newIndex)) {
3005
3009
  return;
@@ -3007,18 +3011,27 @@
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
  }
3027
+ if (stickyFixed && !props.scrollspy) {
3028
+ setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
3029
+ }
3017
3030
  };
3018
- const setCurrentIndexByName = (name2) => {
3031
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
3019
3032
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
3020
3033
  const index = matched ? children.indexOf(matched) : 0;
3021
- setCurrentIndex(index);
3034
+ setCurrentIndex(index, skipScrollIntoView);
3022
3035
  };
3023
3036
  const scrollToCurrentContent = (immediate = false) => {
3024
3037
  if (props.scrollspy) {
@@ -3109,13 +3122,14 @@
3109
3122
  }
3110
3123
  };
3111
3124
  const renderHeader = () => {
3112
- var _a, _b;
3125
+ var _a, _b, _c;
3113
3126
  const {
3114
3127
  type,
3115
- border
3128
+ border,
3129
+ sticky
3116
3130
  } = props;
3117
- return vue.createVNode("div", {
3118
- "ref": wrapRef,
3131
+ const Header = [vue.createVNode("div", {
3132
+ "ref": sticky ? void 0 : wrapRef,
3119
3133
  "class": [bem$1a("wrap"), {
3120
3134
  [BORDER_TOP_BOTTOM]: type === "line" && border
3121
3135
  }]
@@ -3128,7 +3142,13 @@
3128
3142
  }]),
3129
3143
  "style": navStyle.value,
3130
3144
  "aria-orientation": "horizontal"
3131
- }, [(_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;
3132
3152
  };
3133
3153
  vue.watch([() => props.color, windowWidth], setLine);
3134
3154
  vue.watch(() => props.active, (value) => {
@@ -3145,15 +3165,8 @@
3145
3165
  });
3146
3166
  }
3147
3167
  });
3148
- vue.watch(() => state.currentIndex, () => {
3149
- scrollIntoView();
3150
- setLine();
3151
- if (stickyFixed && !props.scrollspy) {
3152
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
3153
- }
3154
- });
3155
3168
  const init = () => {
3156
- setCurrentIndexByName(props.active);
3169
+ setCurrentIndexByName(props.active, true);
3157
3170
  vue.nextTick(() => {
3158
3171
  state.inited = true;
3159
3172
  if (wrapRef.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();
@@ -3340,6 +3347,16 @@
3340
3347
  }
3341
3348
  return isActive;
3342
3349
  });
3350
+ const hasInactiveClass = vue.ref(!active.value);
3351
+ vue.watch(active, (val) => {
3352
+ if (val) {
3353
+ hasInactiveClass.value = false;
3354
+ } else {
3355
+ doubleRaf(() => {
3356
+ hasInactiveClass.value = true;
3357
+ });
3358
+ }
3359
+ });
3343
3360
  vue.watch(() => props.title, () => {
3344
3361
  parent.setLine();
3345
3362
  parent.scrollIntoView();
@@ -3363,7 +3380,7 @@
3363
3380
  "id": id,
3364
3381
  "role": "tabpanel",
3365
3382
  "class": bem$18("panel-wrapper", {
3366
- inactive: !active.value
3383
+ inactive: hasInactiveClass.value
3367
3384
  }),
3368
3385
  "tabindex": active.value ? 0 : -1,
3369
3386
  "aria-hidden": !active.value,
@@ -4249,7 +4266,8 @@
4249
4266
  state.validateMessage = "";
4250
4267
  };
4251
4268
  const endValidate = () => emit("endValidate", {
4252
- status: state.status
4269
+ status: state.status,
4270
+ message: state.validateMessage
4253
4271
  });
4254
4272
  const validate = (rules = props.rules) => new Promise((resolve) => {
4255
4273
  resetValidation();
@@ -4538,9 +4556,9 @@
4538
4556
  const labelAlign = getProp("labelAlign");
4539
4557
  const Label = renderLabel();
4540
4558
  const LeftIcon = renderLeftIcon();
4559
+ const renderTitle = () => labelAlign === "top" ? [LeftIcon, Label] : Label;
4541
4560
  return vue.createVNode(Cell, {
4542
4561
  "size": props.size,
4543
- "icon": props.leftIcon,
4544
4562
  "class": bem$13({
4545
4563
  error: showError.value,
4546
4564
  disabled,
@@ -4557,8 +4575,8 @@
4557
4575
  }]), props.labelClass],
4558
4576
  "arrowDirection": props.arrowDirection
4559
4577
  }, {
4560
- icon: LeftIcon ? () => LeftIcon : null,
4561
- title: Label ? () => Label : null,
4578
+ icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
4579
+ title: Label || labelAlign === "top" ? renderTitle : null,
4562
4580
  value: renderFieldBody,
4563
4581
  extra: slots.extra
4564
4582
  });
@@ -5746,6 +5764,16 @@
5746
5764
  });
5747
5765
  return filter ? filter(type, options) : options;
5748
5766
  };
5767
+ const formatValueRange = (values, columns) => values.map((value, index) => {
5768
+ const column = columns[index];
5769
+ if (column.length) {
5770
+ const maxValue = +column[column.length - 1].value;
5771
+ if (+value > maxValue) {
5772
+ return String(maxValue);
5773
+ }
5774
+ }
5775
+ return value;
5776
+ });
5749
5777
  const [name$Y] = createNamespace("calendar-day");
5750
5778
  var stdin_default$13 = vue.defineComponent({
5751
5779
  name: name$Y,
@@ -8664,9 +8692,12 @@
8664
8692
  }
8665
8693
  });
8666
8694
  vue.watch(() => props.modelValue, (newValues) => {
8695
+ newValues = formatValueRange(newValues, columns.value);
8667
8696
  if (!isSameValue(newValues, currentValues.value)) {
8668
8697
  currentValues.value = newValues;
8669
8698
  }
8699
+ }, {
8700
+ immediate: true
8670
8701
  });
8671
8702
  const onChange = (...args) => emit("change", ...args);
8672
8703
  const onCancel = (...args) => emit("cancel", ...args);
@@ -10338,7 +10369,8 @@
10338
10369
  rightText: String,
10339
10370
  leftArrow: Boolean,
10340
10371
  placeholder: Boolean,
10341
- safeAreaInsetTop: Boolean
10372
+ safeAreaInsetTop: Boolean,
10373
+ clickable: truthProp
10342
10374
  };
10343
10375
  var stdin_default$w = vue.defineComponent({
10344
10376
  name: name$r,
@@ -10393,12 +10425,12 @@
10393
10425
  }, [vue.createVNode("div", {
10394
10426
  "class": bem$q("content")
10395
10427
  }, [hasLeft && vue.createVNode("div", {
10396
- "class": [bem$q("left"), HAPTICS_FEEDBACK],
10428
+ "class": [bem$q("left"), props.clickable ? HAPTICS_FEEDBACK : ""],
10397
10429
  "onClick": onClickLeft
10398
10430
  }, [renderLeft()]), vue.createVNode("div", {
10399
10431
  "class": [bem$q("title"), "van-ellipsis"]
10400
10432
  }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
10401
- "class": [bem$q("right"), HAPTICS_FEEDBACK],
10433
+ "class": [bem$q("right"), props.clickable ? HAPTICS_FEEDBACK : ""],
10402
10434
  "onClick": onClickRight
10403
10435
  }, [renderRight()])])]);
10404
10436
  };
@@ -10654,7 +10686,7 @@
10654
10686
  instance.open(options);
10655
10687
  clearTimeout(timer);
10656
10688
  if (options.duration > 0) {
10657
- timer = window.setTimeout(closeNotify, options.duration);
10689
+ timer = setTimeout(closeNotify, options.duration);
10658
10690
  }
10659
10691
  return instance;
10660
10692
  }
@@ -13634,6 +13666,7 @@
13634
13666
  showMinus: truthProp,
13635
13667
  showInput: truthProp,
13636
13668
  longPress: truthProp,
13669
+ autoFixed: truthProp,
13637
13670
  allowEmpty: Boolean,
13638
13671
  modelValue: numericProp,
13639
13672
  inputWidth: numericProp,
@@ -13653,7 +13686,7 @@
13653
13686
  setup(props, {
13654
13687
  emit
13655
13688
  }) {
13656
- const format2 = (value) => {
13689
+ const format2 = (value, autoFixed = true) => {
13657
13690
  const {
13658
13691
  min,
13659
13692
  max,
@@ -13666,7 +13699,7 @@
13666
13699
  value = formatNumber(String(value), !props.integer);
13667
13700
  value = value === "" ? 0 : +value;
13668
13701
  value = Number.isNaN(value) ? +min : value;
13669
- value = Math.max(Math.min(+max, value), +min);
13702
+ value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
13670
13703
  if (isDef(decimalLength)) {
13671
13704
  value = value.toFixed(+decimalLength);
13672
13705
  }
@@ -13750,7 +13783,7 @@
13750
13783
  };
13751
13784
  const onBlur = (event) => {
13752
13785
  const input = event.target;
13753
- const value = format2(input.value);
13786
+ const value = format2(input.value, props.autoFixed);
13754
13787
  input.value = String(value);
13755
13788
  current2.value = value;
13756
13789
  vue.nextTick(() => {
@@ -14346,13 +14379,14 @@
14346
14379
  if (!isSameValue(newValues, props.modelValue)) {
14347
14380
  emit("update:modelValue", newValues);
14348
14381
  }
14349
- }, {
14350
- immediate: true
14351
14382
  });
14352
14383
  vue.watch(() => props.modelValue, (newValues) => {
14384
+ newValues = formatValueRange(newValues, columns.value);
14353
14385
  if (!isSameValue(newValues, currentValues.value)) {
14354
14386
  currentValues.value = newValues;
14355
14387
  }
14388
+ }, {
14389
+ immediate: true
14356
14390
  });
14357
14391
  const onChange = (...args) => emit("change", ...args);
14358
14392
  const onCancel = (...args) => emit("cancel", ...args);
@@ -15756,7 +15790,7 @@
15756
15790
  });
15757
15791
  }
15758
15792
  };
15759
- const version = "4.0.0-rc.3";
15793
+ const version = "4.0.0-rc.5";
15760
15794
  function install(app) {
15761
15795
  const components = [
15762
15796
  ActionBar,