vant 4.8.7 → 4.8.9
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 +1 -1
- package/es/address-list/AddressList.mjs +3 -1
- package/es/address-list/AddressListItem.mjs +3 -3
- package/es/coupon-cell/CouponCell.d.ts +4 -4
- package/es/coupon-cell/CouponCell.mjs +35 -12
- package/es/coupon-cell/index.d.ts +3 -3
- package/es/coupon-list/CouponList.d.ts +3 -13
- package/es/coupon-list/CouponList.mjs +15 -6
- package/es/coupon-list/index.d.ts +2 -9
- package/es/date-picker/DatePicker.d.ts +6 -1
- package/es/date-picker/DatePicker.mjs +12 -0
- package/es/date-picker/index.d.ts +1 -1
- package/es/floating-bubble/FloatingBubble.mjs +3 -1
- package/es/image-preview/ImagePreviewItem.mjs +3 -1
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/picker-group/PickerGroup.mjs +11 -3
- package/es/text-ellipsis/TextEllipsis.mjs +30 -21
- package/es/time-picker/TimePicker.d.ts +6 -1
- package/es/time-picker/TimePicker.mjs +13 -1
- package/es/time-picker/index.d.ts +1 -1
- package/es/utils/basic.d.ts +1 -0
- package/es/utils/basic.mjs +2 -0
- package/lib/address-list/AddressList.js +3 -1
- package/lib/address-list/AddressListItem.js +3 -3
- package/lib/coupon-cell/CouponCell.d.ts +4 -4
- package/lib/coupon-cell/CouponCell.js +34 -11
- package/lib/coupon-cell/index.d.ts +3 -3
- package/lib/coupon-list/CouponList.d.ts +3 -13
- package/lib/coupon-list/CouponList.js +14 -5
- package/lib/coupon-list/index.d.ts +2 -9
- package/lib/date-picker/DatePicker.d.ts +6 -1
- package/lib/date-picker/DatePicker.js +12 -0
- package/lib/date-picker/index.d.ts +1 -1
- package/lib/floating-bubble/FloatingBubble.js +3 -1
- package/lib/image-preview/ImagePreviewItem.js +3 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/picker-group/PickerGroup.js +9 -1
- package/lib/text-ellipsis/TextEllipsis.js +29 -20
- package/lib/time-picker/TimePicker.d.ts +6 -1
- package/lib/time-picker/TimePicker.js +12 -0
- package/lib/time-picker/index.d.ts +1 -1
- package/lib/utils/basic.d.ts +1 -0
- package/lib/utils/basic.js +2 -0
- package/lib/vant.cjs.js +122 -44
- package/lib/vant.es.js +122 -44
- package/lib/vant.js +123 -45
- package/lib/vant.min.js +3 -3
- package/lib/web-types.json +1 -1
- package/package.json +10 -10
package/lib/vant.js
CHANGED
@@ -39,6 +39,7 @@
|
|
39
39
|
}
|
40
40
|
const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
|
41
41
|
const toArray = (item) => Array.isArray(item) ? item : [item];
|
42
|
+
const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);
|
42
43
|
const unknownProp = null;
|
43
44
|
const numericProp = [Number, String];
|
44
45
|
const truthProp = {
|
@@ -2368,7 +2369,7 @@
|
|
2368
2369
|
return propRef;
|
2369
2370
|
};
|
2370
2371
|
/**
|
2371
|
-
* @vue/shared v3.4.
|
2372
|
+
* @vue/shared v3.4.21
|
2372
2373
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
2373
2374
|
* @license MIT
|
2374
2375
|
**/
|
@@ -3760,7 +3761,15 @@
|
|
3760
3761
|
const onCancel = () => emit("cancel");
|
3761
3762
|
return () => {
|
3762
3763
|
var _a, _b;
|
3763
|
-
|
3764
|
+
let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== vue.Comment).map((node) => {
|
3765
|
+
if (node.type === vue.Fragment) {
|
3766
|
+
return node.children;
|
3767
|
+
}
|
3768
|
+
return node;
|
3769
|
+
});
|
3770
|
+
if (childNodes) {
|
3771
|
+
childNodes = flat(childNodes);
|
3772
|
+
}
|
3764
3773
|
const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
|
3765
3774
|
return vue.createVNode("div", {
|
3766
3775
|
"class": bem$1l()
|
@@ -6039,11 +6048,11 @@
|
|
6039
6048
|
slots,
|
6040
6049
|
emit
|
6041
6050
|
}) {
|
6042
|
-
const onClick = () => {
|
6051
|
+
const onClick = (event) => {
|
6043
6052
|
if (props2.switchable) {
|
6044
6053
|
emit("select");
|
6045
6054
|
}
|
6046
|
-
emit("click");
|
6055
|
+
emit("click", event);
|
6047
6056
|
};
|
6048
6057
|
const renderRightIcon = () => vue.createVNode(Icon, {
|
6049
6058
|
"name": props2.rightIcon,
|
@@ -6051,7 +6060,7 @@
|
|
6051
6060
|
"onClick": (event) => {
|
6052
6061
|
event.stopPropagation();
|
6053
6062
|
emit("edit");
|
6054
|
-
emit("click");
|
6063
|
+
emit("click", event);
|
6055
6064
|
}
|
6056
6065
|
}, null);
|
6057
6066
|
const renderTag = () => {
|
@@ -6133,7 +6142,9 @@
|
|
6133
6142
|
}) {
|
6134
6143
|
const renderItem = (item, index, disabled) => {
|
6135
6144
|
const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
|
6136
|
-
const onClick = () => emit("clickItem", item, index
|
6145
|
+
const onClick = (event) => emit("clickItem", item, index, {
|
6146
|
+
event
|
6147
|
+
});
|
6137
6148
|
const onSelect = () => {
|
6138
6149
|
emit(disabled ? "selectDisabled" : "select", item, index);
|
6139
6150
|
if (!disabled) {
|
@@ -9063,33 +9074,56 @@
|
|
9063
9074
|
editable: truthProp,
|
9064
9075
|
coupons: makeArrayProp(),
|
9065
9076
|
currency: makeStringProp("¥"),
|
9066
|
-
chosenCoupon:
|
9077
|
+
chosenCoupon: {
|
9078
|
+
type: [Number, Array],
|
9079
|
+
default: -1
|
9080
|
+
}
|
9067
9081
|
};
|
9068
9082
|
function formatValue({
|
9069
9083
|
coupons,
|
9070
9084
|
chosenCoupon,
|
9071
9085
|
currency
|
9072
9086
|
}) {
|
9073
|
-
const
|
9074
|
-
|
9075
|
-
|
9087
|
+
const getValue = (coupon) => {
|
9088
|
+
let value2 = 0;
|
9089
|
+
const {
|
9090
|
+
value: couponValue,
|
9091
|
+
denominations
|
9092
|
+
} = coupon;
|
9076
9093
|
if (isDef(coupon.value)) {
|
9077
|
-
|
9078
|
-
value
|
9079
|
-
} = coupon);
|
9094
|
+
value2 = couponValue;
|
9080
9095
|
} else if (isDef(coupon.denominations)) {
|
9081
|
-
|
9096
|
+
value2 = denominations;
|
9082
9097
|
}
|
9083
|
-
return
|
9098
|
+
return value2;
|
9099
|
+
};
|
9100
|
+
let value = 0, isExist = false;
|
9101
|
+
if (Array.isArray(chosenCoupon)) {
|
9102
|
+
chosenCoupon.forEach((i) => {
|
9103
|
+
const coupon = coupons[+i];
|
9104
|
+
if (coupon) {
|
9105
|
+
isExist = true;
|
9106
|
+
value += getValue(coupon);
|
9107
|
+
}
|
9108
|
+
});
|
9109
|
+
} else {
|
9110
|
+
const coupon = coupons[+chosenCoupon];
|
9111
|
+
if (coupon) {
|
9112
|
+
isExist = true;
|
9113
|
+
value = getValue(coupon);
|
9114
|
+
}
|
9115
|
+
}
|
9116
|
+
if (!isExist) {
|
9117
|
+
return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
|
9084
9118
|
}
|
9085
|
-
return
|
9119
|
+
return `-${currency} ${(value / 100).toFixed(2)}`;
|
9086
9120
|
}
|
9087
9121
|
var stdin_default$_ = vue.defineComponent({
|
9088
9122
|
name: name$R,
|
9089
9123
|
props: couponCellProps,
|
9090
9124
|
setup(props2) {
|
9091
9125
|
return () => {
|
9092
|
-
const selected = props2.coupons[+props2.chosenCoupon];
|
9126
|
+
const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
|
9093
9127
|
return vue.createVNode(Cell, {
|
9094
9128
|
"class": bem$Q(),
|
9095
9129
|
"value": formatValue(props2),
|
@@ -9427,7 +9461,7 @@
|
|
9427
9461
|
currency: makeStringProp("¥"),
|
9428
9462
|
showCount: truthProp,
|
9429
9463
|
emptyImage: String,
|
9430
|
-
chosenCoupon:
|
9464
|
+
chosenCoupon: [Number, Array],
|
9431
9465
|
enabledTitle: String,
|
9432
9466
|
disabledTitle: String,
|
9433
9467
|
disabledCoupons: makeArrayProp(),
|
@@ -9511,6 +9545,15 @@
|
|
9511
9545
|
} = props2;
|
9512
9546
|
const count = props2.showCount ? ` (${coupons.length})` : "";
|
9513
9547
|
const title = (props2.enabledTitle || t$9("enable")) + count;
|
9548
|
+
const getChosenCoupon = (chosenCoupon = [], value = 0) => {
|
9549
|
+
const unrefChosenCoupon = vue.unref(chosenCoupon);
|
9550
|
+
const index = unrefChosenCoupon.indexOf(value);
|
9551
|
+
if (index === -1) {
|
9552
|
+
return [...unrefChosenCoupon, value];
|
9553
|
+
}
|
9554
|
+
unrefChosenCoupon.splice(index, 1);
|
9555
|
+
return [...unrefChosenCoupon];
|
9556
|
+
};
|
9514
9557
|
return vue.createVNode(Tab, {
|
9515
9558
|
"title": title
|
9516
9559
|
}, {
|
@@ -9527,9 +9570,9 @@
|
|
9527
9570
|
"key": coupon.id,
|
9528
9571
|
"ref": setCouponRefs(index),
|
9529
9572
|
"coupon": coupon,
|
9530
|
-
"chosen": index === props2.chosenCoupon,
|
9573
|
+
"chosen": Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.includes(index) : index === props2.chosenCoupon,
|
9531
9574
|
"currency": props2.currency,
|
9532
|
-
"onClick": () => emit("change", index)
|
9575
|
+
"onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? getChosenCoupon(props2.chosenCoupon, index) : index)
|
9533
9576
|
}, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9534
9577
|
}
|
9535
9578
|
});
|
@@ -9582,13 +9625,13 @@
|
|
9582
9625
|
default: () => [renderCouponTab(), renderDisabledTab()]
|
9583
9626
|
}), vue.createVNode("div", {
|
9584
9627
|
"class": bem$O("bottom")
|
9585
|
-
}, [vue.withDirectives(vue.createVNode(Button, {
|
9628
|
+
}, [slots["list-button"] ? slots["list-button"]() : vue.withDirectives(vue.createVNode(Button, {
|
9586
9629
|
"round": true,
|
9587
9630
|
"block": true,
|
9588
9631
|
"type": "primary",
|
9589
9632
|
"class": bem$O("close"),
|
9590
9633
|
"text": props2.closeButtonText || t$9("close"),
|
9591
|
-
"onClick": () => emit("change", -1)
|
9634
|
+
"onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
|
9592
9635
|
}, null), [[vue.vShow, props2.showCloseButton]])])]);
|
9593
9636
|
}
|
9594
9637
|
});
|
@@ -9621,6 +9664,7 @@
|
|
9621
9664
|
}) {
|
9622
9665
|
const currentValues = vue.ref(props2.modelValue);
|
9623
9666
|
const updatedByExternalSources = vue.ref(false);
|
9667
|
+
const pickerRef = vue.ref();
|
9624
9668
|
const genYearOptions = () => {
|
9625
9669
|
const minYear = props2.minDate.getFullYear();
|
9626
9670
|
const maxYear = props2.maxDate.getFullYear();
|
@@ -9662,6 +9706,11 @@
|
|
9662
9706
|
const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
|
9663
9707
|
return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter);
|
9664
9708
|
};
|
9709
|
+
const confirm = () => {
|
9710
|
+
var _a;
|
9711
|
+
return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
9712
|
+
};
|
9713
|
+
const getSelectedDate = () => currentValues.value;
|
9665
9714
|
const columns = vue.computed(() => props2.columnsType.map((type) => {
|
9666
9715
|
switch (type) {
|
9667
9716
|
case "year":
|
@@ -9692,7 +9741,12 @@
|
|
9692
9741
|
const onChange = (...args) => emit("change", ...args);
|
9693
9742
|
const onCancel = (...args) => emit("cancel", ...args);
|
9694
9743
|
const onConfirm = (...args) => emit("confirm", ...args);
|
9744
|
+
useExpose({
|
9745
|
+
confirm,
|
9746
|
+
getSelectedDate
|
9747
|
+
});
|
9695
9748
|
return () => vue.createVNode(Picker, vue.mergeProps({
|
9749
|
+
"ref": pickerRef,
|
9696
9750
|
"modelValue": currentValues.value,
|
9697
9751
|
"onUpdate:modelValue": ($event) => currentValues.value = $event,
|
9698
9752
|
"columns": columns.value,
|
@@ -10470,7 +10524,9 @@
|
|
10470
10524
|
initialized = true;
|
10471
10525
|
});
|
10472
10526
|
});
|
10473
|
-
vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState
|
10527
|
+
vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState, {
|
10528
|
+
deep: true
|
10529
|
+
});
|
10474
10530
|
const show = vue.ref(true);
|
10475
10531
|
vue.onActivated(() => {
|
10476
10532
|
show.value = true;
|
@@ -11220,7 +11276,9 @@
|
|
11220
11276
|
default: () => [slots.image ? vue.createVNode("div", {
|
11221
11277
|
"class": bem$E("image-wrap")
|
11222
11278
|
}, [slots.image({
|
11223
|
-
src: props2.src
|
11279
|
+
src: props2.src,
|
11280
|
+
onLoad,
|
11281
|
+
style: imageStyle.value
|
11224
11282
|
})]) : vue.createVNode(Image$1, {
|
11225
11283
|
"ref": imageRef,
|
11226
11284
|
"src": props2.src,
|
@@ -16246,6 +16304,7 @@
|
|
16246
16304
|
const expanded = vue.ref(false);
|
16247
16305
|
const hasAction = vue.ref(false);
|
16248
16306
|
const root = vue.ref();
|
16307
|
+
let needRecalculate = false;
|
16249
16308
|
const actionText = vue.computed(() => expanded.value ? props2.collapseText : props2.expandText);
|
16250
16309
|
const pxToNum = (value) => {
|
16251
16310
|
if (!value)
|
@@ -16253,26 +16312,26 @@
|
|
16253
16312
|
const match = value.match(/^\d*(\.\d*)?/);
|
16254
16313
|
return match ? Number(match[0]) : 0;
|
16255
16314
|
};
|
16315
|
+
const cloneContainer = () => {
|
16316
|
+
if (!root.value || !root.value.isConnected)
|
16317
|
+
return;
|
16318
|
+
const originStyle = window.getComputedStyle(root.value);
|
16319
|
+
const container = document.createElement("div");
|
16320
|
+
const styleNames = Array.prototype.slice.apply(originStyle);
|
16321
|
+
styleNames.forEach((name2) => {
|
16322
|
+
container.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
16323
|
+
});
|
16324
|
+
container.style.position = "fixed";
|
16325
|
+
container.style.zIndex = "-9999";
|
16326
|
+
container.style.top = "-9999px";
|
16327
|
+
container.style.height = "auto";
|
16328
|
+
container.style.minHeight = "auto";
|
16329
|
+
container.style.maxHeight = "auto";
|
16330
|
+
container.innerText = props2.content;
|
16331
|
+
document.body.appendChild(container);
|
16332
|
+
return container;
|
16333
|
+
};
|
16256
16334
|
const calcEllipsised = () => {
|
16257
|
-
const cloneContainer = () => {
|
16258
|
-
if (!root.value)
|
16259
|
-
return;
|
16260
|
-
const originStyle = window.getComputedStyle(root.value);
|
16261
|
-
const container2 = document.createElement("div");
|
16262
|
-
const styleNames = Array.prototype.slice.apply(originStyle);
|
16263
|
-
styleNames.forEach((name2) => {
|
16264
|
-
container2.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
16265
|
-
});
|
16266
|
-
container2.style.position = "fixed";
|
16267
|
-
container2.style.zIndex = "-9999";
|
16268
|
-
container2.style.top = "-9999px";
|
16269
|
-
container2.style.height = "auto";
|
16270
|
-
container2.style.minHeight = "auto";
|
16271
|
-
container2.style.maxHeight = "auto";
|
16272
|
-
container2.innerText = props2.content;
|
16273
|
-
document.body.appendChild(container2);
|
16274
|
-
return container2;
|
16275
|
-
};
|
16276
16335
|
const calcEllipsisText = (container2, maxHeight2) => {
|
16277
16336
|
const {
|
16278
16337
|
content,
|
@@ -16324,8 +16383,10 @@
|
|
16324
16383
|
return container2.innerText;
|
16325
16384
|
};
|
16326
16385
|
const container = cloneContainer();
|
16327
|
-
if (!container)
|
16386
|
+
if (!container) {
|
16387
|
+
needRecalculate = true;
|
16328
16388
|
return;
|
16389
|
+
}
|
16329
16390
|
const {
|
16330
16391
|
paddingBottom,
|
16331
16392
|
paddingTop,
|
@@ -16358,6 +16419,12 @@
|
|
16358
16419
|
}, [action]);
|
16359
16420
|
};
|
16360
16421
|
vue.onMounted(calcEllipsised);
|
16422
|
+
vue.onActivated(() => {
|
16423
|
+
if (needRecalculate) {
|
16424
|
+
needRecalculate = false;
|
16425
|
+
calcEllipsised();
|
16426
|
+
}
|
16427
|
+
});
|
16361
16428
|
vue.watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
|
16362
16429
|
useExpose({
|
16363
16430
|
toggle
|
@@ -16402,10 +16469,16 @@
|
|
16402
16469
|
slots
|
16403
16470
|
}) {
|
16404
16471
|
const currentValues = vue.ref(props2.modelValue);
|
16472
|
+
const pickerRef = vue.ref();
|
16405
16473
|
const getValidTime = (time) => {
|
16406
16474
|
const timeLimitArr = time.split(":");
|
16407
16475
|
return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
|
16408
16476
|
};
|
16477
|
+
const confirm = () => {
|
16478
|
+
var _a;
|
16479
|
+
return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
16480
|
+
};
|
16481
|
+
const getSelectedTime = () => currentValues.value;
|
16409
16482
|
const columns = vue.computed(() => {
|
16410
16483
|
let {
|
16411
16484
|
minHour,
|
@@ -16475,7 +16548,12 @@
|
|
16475
16548
|
const onChange = (...args) => emit("change", ...args);
|
16476
16549
|
const onCancel = (...args) => emit("cancel", ...args);
|
16477
16550
|
const onConfirm = (...args) => emit("confirm", ...args);
|
16551
|
+
useExpose({
|
16552
|
+
confirm,
|
16553
|
+
getSelectedTime
|
16554
|
+
});
|
16478
16555
|
return () => vue.createVNode(Picker, vue.mergeProps({
|
16556
|
+
"ref": pickerRef,
|
16479
16557
|
"modelValue": currentValues.value,
|
16480
16558
|
"onUpdate:modelValue": ($event) => currentValues.value = $event,
|
16481
16559
|
"columns": columns.value,
|
@@ -18008,7 +18086,7 @@
|
|
18008
18086
|
});
|
18009
18087
|
}
|
18010
18088
|
};
|
18011
|
-
const version = "4.8.
|
18089
|
+
const version = "4.8.9";
|
18012
18090
|
function install(app) {
|
18013
18091
|
const components = [
|
18014
18092
|
ActionBar,
|