vant 4.6.0 → 4.6.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 (74) hide show
  1. package/README.md +7 -7
  2. package/es/checkbox/Checkbox.d.ts +14 -13
  3. package/es/checkbox/Checkbox.mjs +2 -1
  4. package/es/checkbox/Checker.d.ts +9 -13
  5. package/es/checkbox/Checker.mjs +13 -3
  6. package/es/checkbox/index.d.ts +8 -8
  7. package/es/field/Field.d.ts +25 -0
  8. package/es/field/Field.mjs +9 -0
  9. package/es/field/index.d.ts +13 -0
  10. package/es/floating-bubble/FloatingBubble.d.ts +16 -21
  11. package/es/floating-bubble/FloatingBubble.mjs +6 -8
  12. package/es/floating-bubble/index.css +1 -1
  13. package/es/floating-bubble/index.d.ts +18 -18
  14. package/es/floating-bubble/types.d.ts +13 -1
  15. package/es/floating-panel/FloatingPanel.mjs +2 -5
  16. package/es/index.d.ts +1 -1
  17. package/es/index.mjs +1 -1
  18. package/es/lazyload/vue-lazyload/util.d.ts +2 -2
  19. package/es/pagination/index.css +1 -1
  20. package/es/radio/Radio.d.ts +18 -15
  21. package/es/radio/Radio.mjs +5 -3
  22. package/es/radio/index.css +1 -1
  23. package/es/radio/index.d.ts +11 -9
  24. package/es/radio/types.d.ts +1 -0
  25. package/es/search/Search.d.ts +19 -0
  26. package/es/search/index.d.ts +13 -0
  27. package/es/style/base.css +1 -1
  28. package/es/submit-bar/types.d.ts +0 -1
  29. package/es/text-ellipsis/TextEllipsis.d.ts +13 -0
  30. package/es/text-ellipsis/TextEllipsis.mjs +50 -19
  31. package/es/text-ellipsis/index.d.ts +9 -0
  32. package/es/uploader/Uploader.mjs +6 -4
  33. package/es/uploader/UploaderPreviewItem.mjs +1 -1
  34. package/es/uploader/types.d.ts +1 -0
  35. package/lib/checkbox/Checkbox.d.ts +14 -13
  36. package/lib/checkbox/Checkbox.js +1 -0
  37. package/lib/checkbox/Checker.d.ts +9 -13
  38. package/lib/checkbox/Checker.js +13 -3
  39. package/lib/checkbox/index.d.ts +8 -8
  40. package/lib/field/Field.d.ts +25 -0
  41. package/lib/field/Field.js +9 -0
  42. package/lib/field/index.d.ts +13 -0
  43. package/lib/floating-bubble/FloatingBubble.d.ts +16 -21
  44. package/lib/floating-bubble/FloatingBubble.js +6 -8
  45. package/lib/floating-bubble/index.css +1 -1
  46. package/lib/floating-bubble/index.d.ts +18 -18
  47. package/lib/floating-bubble/types.d.ts +13 -1
  48. package/lib/floating-panel/FloatingPanel.js +1 -4
  49. package/lib/index.css +1 -1
  50. package/lib/index.d.ts +1 -1
  51. package/lib/index.js +1 -1
  52. package/lib/lazyload/vue-lazyload/util.d.ts +2 -2
  53. package/lib/pagination/index.css +1 -1
  54. package/lib/radio/Radio.d.ts +18 -15
  55. package/lib/radio/Radio.js +4 -2
  56. package/lib/radio/index.css +1 -1
  57. package/lib/radio/index.d.ts +11 -9
  58. package/lib/radio/types.d.ts +1 -0
  59. package/lib/search/Search.d.ts +19 -0
  60. package/lib/search/index.d.ts +13 -0
  61. package/lib/style/base.css +1 -1
  62. package/lib/submit-bar/types.d.ts +0 -1
  63. package/lib/text-ellipsis/TextEllipsis.d.ts +13 -0
  64. package/lib/text-ellipsis/TextEllipsis.js +49 -18
  65. package/lib/text-ellipsis/index.d.ts +9 -0
  66. package/lib/uploader/Uploader.js +6 -4
  67. package/lib/uploader/UploaderPreviewItem.js +1 -1
  68. package/lib/uploader/types.d.ts +1 -0
  69. package/lib/vant.cjs.js +99 -49
  70. package/lib/vant.es.js +99 -49
  71. package/lib/vant.js +110 -187
  72. package/lib/vant.min.js +1 -1
  73. package/lib/web-types.json +1 -1
  74. package/package.json +1 -1
package/lib/vant.cjs.js CHANGED
@@ -114,7 +114,7 @@ function isHidden(elementRef) {
114
114
  const parentHidden = el.offsetParent === null && style.position !== "fixed";
115
115
  return hidden || parentHidden;
116
116
  }
117
- const { width: windowWidth, height: windowHeight$1 } = use.useWindowSize();
117
+ const { width: windowWidth, height: windowHeight } = use.useWindowSize();
118
118
  function addUnit(value) {
119
119
  if (isDef(value)) {
120
120
  return isNumeric(value) ? `${value}px` : String(value);
@@ -162,7 +162,7 @@ function convertVw(value) {
162
162
  }
163
163
  function convertVh(value) {
164
164
  value = value.replace(/vh/g, "");
165
- return +value * windowHeight$1.value / 100;
165
+ return +value * windowHeight.value / 100;
166
166
  }
167
167
  function unitToPx(value) {
168
168
  if (typeof value === "number") {
@@ -438,7 +438,7 @@ const useHeight = (element, withSafeArea) => {
438
438
  }
439
439
  });
440
440
  onPopupReopen(() => vue.nextTick(setHeight));
441
- vue.watch([windowWidth, windowHeight$1], setHeight);
441
+ vue.watch([windowWidth, windowHeight], setHeight);
442
442
  return height;
443
443
  };
444
444
  function usePlaceholder(contentRef, bem2) {
@@ -2098,7 +2098,7 @@ var stdin_default$1F = vue.defineComponent({
2098
2098
  passive: true
2099
2099
  });
2100
2100
  useVisibilityChange(root, onScroll);
2101
- vue.watch([windowWidth, windowHeight$1], () => {
2101
+ vue.watch([windowWidth, windowHeight], () => {
2102
2102
  if (!root.value || isHidden(root) || !state.fixed) {
2103
2103
  return;
2104
2104
  }
@@ -2456,7 +2456,7 @@ var stdin_default$1E = vue.defineComponent({
2456
2456
  vue.watch(() => props2.initialSwipe, (value) => initialize(+value));
2457
2457
  vue.watch(count, () => initialize(state.active));
2458
2458
  vue.watch(() => props2.autoplay, autoplay);
2459
- vue.watch([windowWidth, windowHeight$1, () => props2.width, () => props2.height], resize);
2459
+ vue.watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
2460
2460
  vue.watch(use.usePageVisibility(), (visible) => {
2461
2461
  if (visible === "visible") {
2462
2462
  autoplay();
@@ -3977,8 +3977,14 @@ const fieldSharedProps = {
3977
3977
  inputAlign: String,
3978
3978
  placeholder: String,
3979
3979
  autocomplete: String,
3980
+ autocapitalize: String,
3981
+ autocorrect: String,
3980
3982
  errorMessage: String,
3981
3983
  enterkeyhint: String,
3984
+ spellcheck: {
3985
+ type: Boolean,
3986
+ default: null
3987
+ },
3982
3988
  clearTrigger: makeStringProp("focus"),
3983
3989
  formatTrigger: makeStringProp("onChange"),
3984
3990
  error: {
@@ -4306,7 +4312,10 @@ var stdin_default$1u = vue.defineComponent({
4306
4312
  autofocus: props2.autofocus,
4307
4313
  placeholder: props2.placeholder,
4308
4314
  autocomplete: props2.autocomplete,
4315
+ autocapitalize: props2.autocapitalize,
4316
+ autocorrect: props2.autocorrect,
4309
4317
  enterkeyhint: props2.enterkeyhint,
4318
+ spellcheck: props2.spellcheck,
4310
4319
  "aria-labelledby": props2.label ? `${id}-label` : void 0,
4311
4320
  onBlur,
4312
4321
  onFocus,
@@ -5288,7 +5297,6 @@ var stdin_default$1o = vue.defineComponent({
5288
5297
  const Tag = withInstall(stdin_default$1o);
5289
5298
  const checkerProps = {
5290
5299
  name: unknownProp,
5291
- shape: makeStringProp("round"),
5292
5300
  disabled: Boolean,
5293
5301
  iconSize: numericProp,
5294
5302
  modelValue: unknownProp,
@@ -5300,6 +5308,7 @@ var stdin_default$1n = vue.defineComponent({
5300
5308
  props: extend({}, checkerProps, {
5301
5309
  bem: makeRequiredProp(Function),
5302
5310
  role: String,
5311
+ shape: makeStringProp("round"),
5303
5312
  parent: Object,
5304
5313
  checked: Boolean,
5305
5314
  bindGroup: truthProp
@@ -5350,6 +5359,7 @@ var stdin_default$1n = vue.defineComponent({
5350
5359
  emit("click", event);
5351
5360
  };
5352
5361
  const renderIcon = () => {
5362
+ var _a, _b;
5353
5363
  const {
5354
5364
  bem: bem2,
5355
5365
  shape,
@@ -5362,15 +5372,24 @@ var stdin_default$1n = vue.defineComponent({
5362
5372
  disabled: disabled.value,
5363
5373
  checked
5364
5374
  }]),
5365
- "style": {
5375
+ "style": shape !== "dot" ? {
5366
5376
  fontSize: addUnit(iconSize)
5377
+ } : {
5378
+ width: addUnit(iconSize),
5379
+ height: addUnit(iconSize),
5380
+ borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
5367
5381
  }
5368
5382
  }, [slots.icon ? slots.icon({
5369
5383
  checked,
5370
5384
  disabled: disabled.value
5371
- }) : vue.createVNode(Icon, {
5385
+ }) : shape !== "dot" ? vue.createVNode(Icon, {
5372
5386
  "name": "success",
5373
5387
  "style": iconStyle.value
5388
+ }, null) : vue.createVNode("div", {
5389
+ "class": bem2("icon--dot__icon"),
5390
+ "style": {
5391
+ backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
5392
+ }
5374
5393
  }, null)]);
5375
5394
  };
5376
5395
  const renderLabel = () => {
@@ -5397,11 +5416,13 @@ var stdin_default$1n = vue.defineComponent({
5397
5416
  };
5398
5417
  }
5399
5418
  });
5400
- const radioProps = checkerProps;
5419
+ const radioProps = extend({}, checkerProps, {
5420
+ shape: makeStringProp("round")
5421
+ });
5401
5422
  const [name$1d, bem$19] = createNamespace("radio");
5402
5423
  var stdin_default$1m = vue.defineComponent({
5403
5424
  name: name$1d,
5404
- props: checkerProps,
5425
+ props: radioProps,
5405
5426
  emits: ["update:modelValue"],
5406
5427
  setup(props2, {
5407
5428
  emit,
@@ -7455,6 +7476,7 @@ var stdin_default$19 = vue.defineComponent({
7455
7476
  });
7456
7477
  const [name$$, bem$_] = createNamespace("checkbox");
7457
7478
  const checkboxProps = extend({}, checkerProps, {
7479
+ shape: makeStringProp("round"),
7458
7480
  bindGroup: truthProp
7459
7481
  });
7460
7482
  var stdin_default$18 = vue.defineComponent({
@@ -8825,7 +8847,7 @@ var stdin_default$X = vue.defineComponent({
8825
8847
  const TABS_HEIGHT = 44;
8826
8848
  const rootHeight = use.useRect(root).height;
8827
8849
  const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
8828
- listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight$1.value) - headerHeight;
8850
+ listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
8829
8851
  };
8830
8852
  const onExchange = () => {
8831
8853
  emit("exchange", currentCode.value);
@@ -8929,7 +8951,7 @@ var stdin_default$X = vue.defineComponent({
8929
8951
  vue.watch(() => props2.code, (value) => {
8930
8952
  currentCode.value = value;
8931
8953
  });
8932
- vue.watch(windowHeight$1, updateListHeight);
8954
+ vue.watch(windowHeight, updateListHeight);
8933
8955
  vue.watch(currentCode, (value) => emit("update:code", value));
8934
8956
  vue.watch(() => props2.displayedCouponIndex, scrollToCoupon);
8935
8957
  vue.onMounted(() => {
@@ -9430,7 +9452,7 @@ var stdin_default$T = vue.defineComponent({
9430
9452
  if (props2.direction === "down") {
9431
9453
  offset.value = rect.bottom;
9432
9454
  } else {
9433
- offset.value = windowHeight$1.value - rect.top;
9455
+ offset.value = windowHeight.value - rect.top;
9434
9456
  }
9435
9457
  }
9436
9458
  };
@@ -9687,10 +9709,10 @@ var stdin_default$S = vue.defineComponent({
9687
9709
  const DropdownItem = withInstall(stdin_default$S);
9688
9710
  const DropdownMenu = withInstall(stdin_default$T);
9689
9711
  const floatingBubbleProps = {
9712
+ gap: makeNumberProp(24),
9713
+ icon: String,
9690
9714
  axis: makeStringProp("y"),
9691
9715
  magnetic: String,
9692
- icon: String,
9693
- gap: makeNumberProp(24),
9694
9716
  offset: {
9695
9717
  type: Object,
9696
9718
  default: () => ({
@@ -9721,8 +9743,8 @@ var stdin_default$R = vue.defineComponent({
9721
9743
  });
9722
9744
  const boundary = vue.computed(() => ({
9723
9745
  top: props2.gap,
9724
- right: windowWidth.value - state.value.height - props2.gap,
9725
- bottom: windowHeight$1.value - state.value.width - props2.gap,
9746
+ right: windowWidth.value - state.value.width - props2.gap,
9747
+ bottom: windowHeight.value - state.value.height - props2.gap,
9726
9748
  left: props2.gap
9727
9749
  }));
9728
9750
  const dragging = vue.ref(false);
@@ -9747,7 +9769,7 @@ var stdin_default$R = vue.defineComponent({
9747
9769
  } = props2;
9748
9770
  state.value = {
9749
9771
  x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
9750
- y: offset.y > -1 ? offset.y : windowHeight$1.value - height - props2.gap,
9772
+ y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
9751
9773
  width,
9752
9774
  height
9753
9775
  };
@@ -9820,9 +9842,7 @@ var stdin_default$R = vue.defineComponent({
9820
9842
  initialized = true;
9821
9843
  });
9822
9844
  });
9823
- vue.watch([windowWidth, windowHeight$1, () => props2.gap, () => props2.offset], () => updateState(), {
9824
- deep: true
9825
- });
9845
+ vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState);
9826
9846
  const show = vue.ref(true);
9827
9847
  vue.onActivated(() => {
9828
9848
  show.value = true;
@@ -9854,9 +9874,6 @@ var stdin_default$R = vue.defineComponent({
9854
9874
  }
9855
9875
  });
9856
9876
  const FloatingBubble = withInstall(stdin_default$R);
9857
- const {
9858
- height: windowHeight
9859
- } = use.useWindowSize();
9860
9877
  const floatingPanelProps = {
9861
9878
  height: makeNumericProp(0),
9862
9879
  anchors: makeArrayProp(),
@@ -10584,7 +10601,7 @@ var stdin_default$M = vue.defineComponent({
10584
10601
  swipeTo
10585
10602
  });
10586
10603
  vue.onMounted(resize);
10587
- vue.watch([windowWidth, windowHeight$1], resize);
10604
+ vue.watch([windowWidth, windowHeight], resize);
10588
10605
  vue.watch(() => props2.startPosition, (value) => setActive(+value));
10589
10606
  vue.watch(() => props2.show, (value) => {
10590
10607
  const {
@@ -14585,7 +14602,8 @@ const textEllipsisProps = {
14585
14602
  dots: makeStringProp("..."),
14586
14603
  content: makeStringProp(""),
14587
14604
  expandText: makeStringProp(""),
14588
- collapseText: makeStringProp("")
14605
+ collapseText: makeStringProp(""),
14606
+ position: makeStringProp("end")
14589
14607
  };
14590
14608
  var stdin_default$9 = vue.defineComponent({
14591
14609
  name: name$4,
@@ -14598,6 +14616,7 @@ var stdin_default$9 = vue.defineComponent({
14598
14616
  const expanded = vue.ref(false);
14599
14617
  const hasAction = vue.ref(false);
14600
14618
  const root = vue.ref();
14619
+ const actionText = vue.computed(() => expanded.value ? props2.expandText : props2.collapseText);
14601
14620
  const pxToNum = (value) => {
14602
14621
  if (!value)
14603
14622
  return 0;
@@ -14626,24 +14645,53 @@ var stdin_default$9 = vue.defineComponent({
14626
14645
  };
14627
14646
  const calcEllipsisText = (container2, maxHeight2) => {
14628
14647
  const {
14629
- dots,
14630
14648
  content,
14631
- expandText
14649
+ position,
14650
+ dots
14632
14651
  } = props2;
14633
- let left = 0;
14634
- let right = content.length;
14635
- let res = -1;
14636
- while (left <= right) {
14637
- const mid = Math.floor((left + right) / 2);
14638
- container2.innerText = content.slice(0, mid) + dots + expandText;
14639
- if (container2.offsetHeight <= maxHeight2) {
14640
- left = mid + 1;
14641
- res = mid;
14642
- } else {
14643
- right = mid - 1;
14652
+ const end = content.length;
14653
+ const calcEllipse = () => {
14654
+ const tail = (left, right) => {
14655
+ if (right - left <= 1) {
14656
+ if (position === "end") {
14657
+ return content.slice(0, left) + dots;
14658
+ }
14659
+ return dots + content.slice(right, end);
14660
+ }
14661
+ const middle2 = Math.round(left + right >> 1);
14662
+ if (position === "end") {
14663
+ container2.innerText = content.slice(0, middle2) + dots + actionText.value;
14664
+ } else {
14665
+ container2.innerText = dots + content.slice(middle2, end) + actionText.value;
14666
+ }
14667
+ if (container2.offsetHeight > maxHeight2) {
14668
+ if (position === "end") {
14669
+ return tail(left, middle2);
14670
+ }
14671
+ return tail(middle2, right);
14672
+ }
14673
+ if (position === "end") {
14674
+ return tail(middle2, right);
14675
+ }
14676
+ return tail(left, middle2);
14677
+ };
14678
+ container2.innerText = tail(0, end);
14679
+ };
14680
+ const middleTail = (leftPart, rightPart) => {
14681
+ if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
14682
+ return content.slice(0, leftPart[1]) + dots + dots + content.slice(rightPart[1], end);
14644
14683
  }
14645
- }
14646
- return content.slice(0, res) + dots;
14684
+ const leftMiddle = Math.floor(leftPart[0] + leftPart[1] >> 1);
14685
+ const rightMiddle = Math.ceil(rightPart[0] + rightPart[1] >> 1);
14686
+ container2.innerText = props2.content.slice(0, leftMiddle) + props2.dots + actionText.value + props2.dots + props2.content.slice(rightMiddle, end);
14687
+ if (container2.offsetHeight >= maxHeight2) {
14688
+ return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
14689
+ }
14690
+ return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
14691
+ };
14692
+ const middle = 0 + end >> 1;
14693
+ props2.position === "middle" ? container2.innerText = middleTail([0, middle], [middle, end]) : calcEllipse();
14694
+ return container2.innerText;
14647
14695
  };
14648
14696
  const container = cloneContainer();
14649
14697
  if (!container)
@@ -14653,7 +14701,7 @@ var stdin_default$9 = vue.defineComponent({
14653
14701
  paddingTop,
14654
14702
  lineHeight
14655
14703
  } = container.style;
14656
- const maxHeight = (Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom);
14704
+ const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
14657
14705
  if (maxHeight < container.offsetHeight) {
14658
14706
  hasAction.value = true;
14659
14707
  text.value = calcEllipsisText(container, maxHeight);
@@ -14672,7 +14720,7 @@ var stdin_default$9 = vue.defineComponent({
14672
14720
  "onClick": onClickAction
14673
14721
  }, [expanded.value ? props2.collapseText : props2.expandText]);
14674
14722
  vue.onMounted(calcEllipsised);
14675
- vue.watch(() => [props2.content, props2.rows], calcEllipsised);
14723
+ vue.watch(() => [props2.content, props2.rows, props2.position], calcEllipsised);
14676
14724
  use.useEventListener("resize", calcEllipsised);
14677
14725
  return () => vue.createVNode("div", {
14678
14726
  "ref": root,
@@ -15050,7 +15098,7 @@ var stdin_default$6 = vue.defineComponent({
15050
15098
  if (isImageFile(item)) {
15051
15099
  return vue.createVNode(Image$1, {
15052
15100
  "fit": imageFit,
15053
- "src": item.content || item.url,
15101
+ "src": item.objectUrl || item.content || item.url,
15054
15102
  "class": bem$1("preview-image"),
15055
15103
  "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
15056
15104
  "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
@@ -15168,7 +15216,8 @@ var stdin_default$5 = vue.defineComponent({
15168
15216
  const result = {
15169
15217
  file,
15170
15218
  status: "",
15171
- message: ""
15219
+ message: "",
15220
+ objectUrl: URL.createObjectURL(file)
15172
15221
  };
15173
15222
  if (contents[index]) {
15174
15223
  result.content = contents[index];
@@ -15182,7 +15231,8 @@ var stdin_default$5 = vue.defineComponent({
15182
15231
  const result = {
15183
15232
  file: files,
15184
15233
  status: "",
15185
- message: ""
15234
+ message: "",
15235
+ objectUrl: URL.createObjectURL(files)
15186
15236
  };
15187
15237
  if (content) {
15188
15238
  result.content = content;
@@ -15224,8 +15274,8 @@ var stdin_default$5 = vue.defineComponent({
15224
15274
  if (props2.previewFullImage) {
15225
15275
  const imageFiles = props2.modelValue.filter(isImageFile);
15226
15276
  const images = imageFiles.map((item2) => {
15227
- if (item2.file && !item2.url && item2.status !== "failed") {
15228
- item2.url = URL.createObjectURL(item2.file);
15277
+ if (item2.objectUrl && !item2.url && item2.status !== "failed") {
15278
+ item2.url = item2.objectUrl;
15229
15279
  urls.push(item2.url);
15230
15280
  }
15231
15281
  return item2.url;
@@ -16329,7 +16379,7 @@ const Lazyload = {
16329
16379
  });
16330
16380
  }
16331
16381
  };
16332
- const version = "4.6.0";
16382
+ const version = "4.6.2";
16333
16383
  function install(app) {
16334
16384
  const components = [
16335
16385
  ActionBar,