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