vant 4.8.8 → 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/lib/vant.js CHANGED
@@ -2369,7 +2369,7 @@
2369
2369
  return propRef;
2370
2370
  };
2371
2371
  /**
2372
- * @vue/shared v3.4.15
2372
+ * @vue/shared v3.4.21
2373
2373
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
2374
2374
  * @license MIT
2375
2375
  **/
@@ -9074,33 +9074,56 @@
9074
9074
  editable: truthProp,
9075
9075
  coupons: makeArrayProp(),
9076
9076
  currency: makeStringProp("¥"),
9077
- chosenCoupon: makeNumericProp(-1)
9077
+ chosenCoupon: {
9078
+ type: [Number, Array],
9079
+ default: -1
9080
+ }
9078
9081
  };
9079
9082
  function formatValue({
9080
9083
  coupons,
9081
9084
  chosenCoupon,
9082
9085
  currency
9083
9086
  }) {
9084
- const coupon = coupons[+chosenCoupon];
9085
- if (coupon) {
9086
- let value = 0;
9087
+ const getValue = (coupon) => {
9088
+ let value2 = 0;
9089
+ const {
9090
+ value: couponValue,
9091
+ denominations
9092
+ } = coupon;
9087
9093
  if (isDef(coupon.value)) {
9088
- ({
9089
- value
9090
- } = coupon);
9094
+ value2 = couponValue;
9091
9095
  } else if (isDef(coupon.denominations)) {
9092
- value = coupon.denominations;
9096
+ value2 = denominations;
9093
9097
  }
9094
- return `-${currency} ${(value / 100).toFixed(2)}`;
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);
9095
9118
  }
9096
- return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
9119
+ return `-${currency} ${(value / 100).toFixed(2)}`;
9097
9120
  }
9098
9121
  var stdin_default$_ = vue.defineComponent({
9099
9122
  name: name$R,
9100
9123
  props: couponCellProps,
9101
9124
  setup(props2) {
9102
9125
  return () => {
9103
- const selected = props2.coupons[+props2.chosenCoupon];
9126
+ const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
9104
9127
  return vue.createVNode(Cell, {
9105
9128
  "class": bem$Q(),
9106
9129
  "value": formatValue(props2),
@@ -9438,7 +9461,7 @@
9438
9461
  currency: makeStringProp("¥"),
9439
9462
  showCount: truthProp,
9440
9463
  emptyImage: String,
9441
- chosenCoupon: makeNumberProp(-1),
9464
+ chosenCoupon: [Number, Array],
9442
9465
  enabledTitle: String,
9443
9466
  disabledTitle: String,
9444
9467
  disabledCoupons: makeArrayProp(),
@@ -9522,6 +9545,15 @@
9522
9545
  } = props2;
9523
9546
  const count = props2.showCount ? ` (${coupons.length})` : "";
9524
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
+ };
9525
9557
  return vue.createVNode(Tab, {
9526
9558
  "title": title
9527
9559
  }, {
@@ -9538,9 +9570,9 @@
9538
9570
  "key": coupon.id,
9539
9571
  "ref": setCouponRefs(index),
9540
9572
  "coupon": coupon,
9541
- "chosen": index === props2.chosenCoupon,
9573
+ "chosen": Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.includes(index) : index === props2.chosenCoupon,
9542
9574
  "currency": props2.currency,
9543
- "onClick": () => emit("change", index)
9575
+ "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? getChosenCoupon(props2.chosenCoupon, index) : index)
9544
9576
  }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
9545
9577
  }
9546
9578
  });
@@ -9593,13 +9625,13 @@
9593
9625
  default: () => [renderCouponTab(), renderDisabledTab()]
9594
9626
  }), vue.createVNode("div", {
9595
9627
  "class": bem$O("bottom")
9596
- }, [vue.withDirectives(vue.createVNode(Button, {
9628
+ }, [slots["list-button"] ? slots["list-button"]() : vue.withDirectives(vue.createVNode(Button, {
9597
9629
  "round": true,
9598
9630
  "block": true,
9599
9631
  "type": "primary",
9600
9632
  "class": bem$O("close"),
9601
9633
  "text": props2.closeButtonText || t$9("close"),
9602
- "onClick": () => emit("change", -1)
9634
+ "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
9603
9635
  }, null), [[vue.vShow, props2.showCloseButton]])])]);
9604
9636
  }
9605
9637
  });
@@ -9632,6 +9664,7 @@
9632
9664
  }) {
9633
9665
  const currentValues = vue.ref(props2.modelValue);
9634
9666
  const updatedByExternalSources = vue.ref(false);
9667
+ const pickerRef = vue.ref();
9635
9668
  const genYearOptions = () => {
9636
9669
  const minYear = props2.minDate.getFullYear();
9637
9670
  const maxYear = props2.maxDate.getFullYear();
@@ -9673,6 +9706,11 @@
9673
9706
  const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
9674
9707
  return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter);
9675
9708
  };
9709
+ const confirm = () => {
9710
+ var _a;
9711
+ return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
9712
+ };
9713
+ const getSelectedDate = () => currentValues.value;
9676
9714
  const columns = vue.computed(() => props2.columnsType.map((type) => {
9677
9715
  switch (type) {
9678
9716
  case "year":
@@ -9703,7 +9741,12 @@
9703
9741
  const onChange = (...args) => emit("change", ...args);
9704
9742
  const onCancel = (...args) => emit("cancel", ...args);
9705
9743
  const onConfirm = (...args) => emit("confirm", ...args);
9744
+ useExpose({
9745
+ confirm,
9746
+ getSelectedDate
9747
+ });
9706
9748
  return () => vue.createVNode(Picker, vue.mergeProps({
9749
+ "ref": pickerRef,
9707
9750
  "modelValue": currentValues.value,
9708
9751
  "onUpdate:modelValue": ($event) => currentValues.value = $event,
9709
9752
  "columns": columns.value,
@@ -16426,10 +16469,16 @@
16426
16469
  slots
16427
16470
  }) {
16428
16471
  const currentValues = vue.ref(props2.modelValue);
16472
+ const pickerRef = vue.ref();
16429
16473
  const getValidTime = (time) => {
16430
16474
  const timeLimitArr = time.split(":");
16431
16475
  return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
16432
16476
  };
16477
+ const confirm = () => {
16478
+ var _a;
16479
+ return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
16480
+ };
16481
+ const getSelectedTime = () => currentValues.value;
16433
16482
  const columns = vue.computed(() => {
16434
16483
  let {
16435
16484
  minHour,
@@ -16499,7 +16548,12 @@
16499
16548
  const onChange = (...args) => emit("change", ...args);
16500
16549
  const onCancel = (...args) => emit("cancel", ...args);
16501
16550
  const onConfirm = (...args) => emit("confirm", ...args);
16551
+ useExpose({
16552
+ confirm,
16553
+ getSelectedTime
16554
+ });
16502
16555
  return () => vue.createVNode(Picker, vue.mergeProps({
16556
+ "ref": pickerRef,
16503
16557
  "modelValue": currentValues.value,
16504
16558
  "onUpdate:modelValue": ($event) => currentValues.value = $event,
16505
16559
  "columns": columns.value,
@@ -18032,7 +18086,7 @@
18032
18086
  });
18033
18087
  }
18034
18088
  };
18035
- const version = "4.8.8";
18089
+ const version = "4.8.9";
18036
18090
  function install(app) {
18037
18091
  const components = [
18038
18092
  ActionBar,