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.es.js CHANGED
@@ -112,7 +112,7 @@ function isHidden(elementRef) {
112
112
  const parentHidden = el.offsetParent === null && style.position !== "fixed";
113
113
  return hidden || parentHidden;
114
114
  }
115
- const { width: windowWidth, height: windowHeight$1 } = useWindowSize();
115
+ const { width: windowWidth, height: windowHeight } = useWindowSize();
116
116
  function addUnit(value) {
117
117
  if (isDef(value)) {
118
118
  return isNumeric(value) ? `${value}px` : String(value);
@@ -160,7 +160,7 @@ function convertVw(value) {
160
160
  }
161
161
  function convertVh(value) {
162
162
  value = value.replace(/vh/g, "");
163
- return +value * windowHeight$1.value / 100;
163
+ return +value * windowHeight.value / 100;
164
164
  }
165
165
  function unitToPx(value) {
166
166
  if (typeof value === "number") {
@@ -436,7 +436,7 @@ const useHeight = (element, withSafeArea) => {
436
436
  }
437
437
  });
438
438
  onPopupReopen(() => nextTick(setHeight));
439
- watch([windowWidth, windowHeight$1], setHeight);
439
+ watch([windowWidth, windowHeight], setHeight);
440
440
  return height;
441
441
  };
442
442
  function usePlaceholder(contentRef, bem2) {
@@ -2096,7 +2096,7 @@ var stdin_default$1F = defineComponent({
2096
2096
  passive: true
2097
2097
  });
2098
2098
  useVisibilityChange(root, onScroll);
2099
- watch([windowWidth, windowHeight$1], () => {
2099
+ watch([windowWidth, windowHeight], () => {
2100
2100
  if (!root.value || isHidden(root) || !state.fixed) {
2101
2101
  return;
2102
2102
  }
@@ -2454,7 +2454,7 @@ var stdin_default$1E = defineComponent({
2454
2454
  watch(() => props2.initialSwipe, (value) => initialize(+value));
2455
2455
  watch(count, () => initialize(state.active));
2456
2456
  watch(() => props2.autoplay, autoplay);
2457
- watch([windowWidth, windowHeight$1, () => props2.width, () => props2.height], resize);
2457
+ watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
2458
2458
  watch(usePageVisibility(), (visible) => {
2459
2459
  if (visible === "visible") {
2460
2460
  autoplay();
@@ -3975,8 +3975,14 @@ const fieldSharedProps = {
3975
3975
  inputAlign: String,
3976
3976
  placeholder: String,
3977
3977
  autocomplete: String,
3978
+ autocapitalize: String,
3979
+ autocorrect: String,
3978
3980
  errorMessage: String,
3979
3981
  enterkeyhint: String,
3982
+ spellcheck: {
3983
+ type: Boolean,
3984
+ default: null
3985
+ },
3980
3986
  clearTrigger: makeStringProp("focus"),
3981
3987
  formatTrigger: makeStringProp("onChange"),
3982
3988
  error: {
@@ -4304,7 +4310,10 @@ var stdin_default$1u = defineComponent({
4304
4310
  autofocus: props2.autofocus,
4305
4311
  placeholder: props2.placeholder,
4306
4312
  autocomplete: props2.autocomplete,
4313
+ autocapitalize: props2.autocapitalize,
4314
+ autocorrect: props2.autocorrect,
4307
4315
  enterkeyhint: props2.enterkeyhint,
4316
+ spellcheck: props2.spellcheck,
4308
4317
  "aria-labelledby": props2.label ? `${id}-label` : void 0,
4309
4318
  onBlur,
4310
4319
  onFocus,
@@ -5286,7 +5295,6 @@ var stdin_default$1o = defineComponent({
5286
5295
  const Tag = withInstall(stdin_default$1o);
5287
5296
  const checkerProps = {
5288
5297
  name: unknownProp,
5289
- shape: makeStringProp("round"),
5290
5298
  disabled: Boolean,
5291
5299
  iconSize: numericProp,
5292
5300
  modelValue: unknownProp,
@@ -5298,6 +5306,7 @@ var stdin_default$1n = defineComponent({
5298
5306
  props: extend({}, checkerProps, {
5299
5307
  bem: makeRequiredProp(Function),
5300
5308
  role: String,
5309
+ shape: makeStringProp("round"),
5301
5310
  parent: Object,
5302
5311
  checked: Boolean,
5303
5312
  bindGroup: truthProp
@@ -5348,6 +5357,7 @@ var stdin_default$1n = defineComponent({
5348
5357
  emit("click", event);
5349
5358
  };
5350
5359
  const renderIcon = () => {
5360
+ var _a, _b;
5351
5361
  const {
5352
5362
  bem: bem2,
5353
5363
  shape,
@@ -5360,15 +5370,24 @@ var stdin_default$1n = defineComponent({
5360
5370
  disabled: disabled.value,
5361
5371
  checked
5362
5372
  }]),
5363
- "style": {
5373
+ "style": shape !== "dot" ? {
5364
5374
  fontSize: addUnit(iconSize)
5375
+ } : {
5376
+ width: addUnit(iconSize),
5377
+ height: addUnit(iconSize),
5378
+ borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
5365
5379
  }
5366
5380
  }, [slots.icon ? slots.icon({
5367
5381
  checked,
5368
5382
  disabled: disabled.value
5369
- }) : createVNode(Icon, {
5383
+ }) : shape !== "dot" ? createVNode(Icon, {
5370
5384
  "name": "success",
5371
5385
  "style": iconStyle.value
5386
+ }, null) : createVNode("div", {
5387
+ "class": bem2("icon--dot__icon"),
5388
+ "style": {
5389
+ backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
5390
+ }
5372
5391
  }, null)]);
5373
5392
  };
5374
5393
  const renderLabel = () => {
@@ -5395,11 +5414,13 @@ var stdin_default$1n = defineComponent({
5395
5414
  };
5396
5415
  }
5397
5416
  });
5398
- const radioProps = checkerProps;
5417
+ const radioProps = extend({}, checkerProps, {
5418
+ shape: makeStringProp("round")
5419
+ });
5399
5420
  const [name$1d, bem$19] = createNamespace("radio");
5400
5421
  var stdin_default$1m = defineComponent({
5401
5422
  name: name$1d,
5402
- props: checkerProps,
5423
+ props: radioProps,
5403
5424
  emits: ["update:modelValue"],
5404
5425
  setup(props2, {
5405
5426
  emit,
@@ -7453,6 +7474,7 @@ var stdin_default$19 = defineComponent({
7453
7474
  });
7454
7475
  const [name$$, bem$_] = createNamespace("checkbox");
7455
7476
  const checkboxProps = extend({}, checkerProps, {
7477
+ shape: makeStringProp("round"),
7456
7478
  bindGroup: truthProp
7457
7479
  });
7458
7480
  var stdin_default$18 = defineComponent({
@@ -8823,7 +8845,7 @@ var stdin_default$X = defineComponent({
8823
8845
  const TABS_HEIGHT = 44;
8824
8846
  const rootHeight = useRect(root).height;
8825
8847
  const headerHeight = useRect(barRef).height + TABS_HEIGHT;
8826
- listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight$1.value) - headerHeight;
8848
+ listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
8827
8849
  };
8828
8850
  const onExchange = () => {
8829
8851
  emit("exchange", currentCode.value);
@@ -8927,7 +8949,7 @@ var stdin_default$X = defineComponent({
8927
8949
  watch(() => props2.code, (value) => {
8928
8950
  currentCode.value = value;
8929
8951
  });
8930
- watch(windowHeight$1, updateListHeight);
8952
+ watch(windowHeight, updateListHeight);
8931
8953
  watch(currentCode, (value) => emit("update:code", value));
8932
8954
  watch(() => props2.displayedCouponIndex, scrollToCoupon);
8933
8955
  onMounted(() => {
@@ -9428,7 +9450,7 @@ var stdin_default$T = defineComponent({
9428
9450
  if (props2.direction === "down") {
9429
9451
  offset.value = rect.bottom;
9430
9452
  } else {
9431
- offset.value = windowHeight$1.value - rect.top;
9453
+ offset.value = windowHeight.value - rect.top;
9432
9454
  }
9433
9455
  }
9434
9456
  };
@@ -9685,10 +9707,10 @@ var stdin_default$S = defineComponent({
9685
9707
  const DropdownItem = withInstall(stdin_default$S);
9686
9708
  const DropdownMenu = withInstall(stdin_default$T);
9687
9709
  const floatingBubbleProps = {
9710
+ gap: makeNumberProp(24),
9711
+ icon: String,
9688
9712
  axis: makeStringProp("y"),
9689
9713
  magnetic: String,
9690
- icon: String,
9691
- gap: makeNumberProp(24),
9692
9714
  offset: {
9693
9715
  type: Object,
9694
9716
  default: () => ({
@@ -9719,8 +9741,8 @@ var stdin_default$R = defineComponent({
9719
9741
  });
9720
9742
  const boundary = computed(() => ({
9721
9743
  top: props2.gap,
9722
- right: windowWidth.value - state.value.height - props2.gap,
9723
- bottom: windowHeight$1.value - state.value.width - props2.gap,
9744
+ right: windowWidth.value - state.value.width - props2.gap,
9745
+ bottom: windowHeight.value - state.value.height - props2.gap,
9724
9746
  left: props2.gap
9725
9747
  }));
9726
9748
  const dragging = ref(false);
@@ -9745,7 +9767,7 @@ var stdin_default$R = defineComponent({
9745
9767
  } = props2;
9746
9768
  state.value = {
9747
9769
  x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
9748
- y: offset.y > -1 ? offset.y : windowHeight$1.value - height - props2.gap,
9770
+ y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
9749
9771
  width,
9750
9772
  height
9751
9773
  };
@@ -9818,9 +9840,7 @@ var stdin_default$R = defineComponent({
9818
9840
  initialized = true;
9819
9841
  });
9820
9842
  });
9821
- watch([windowWidth, windowHeight$1, () => props2.gap, () => props2.offset], () => updateState(), {
9822
- deep: true
9823
- });
9843
+ watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState);
9824
9844
  const show = ref(true);
9825
9845
  onActivated(() => {
9826
9846
  show.value = true;
@@ -9852,9 +9872,6 @@ var stdin_default$R = defineComponent({
9852
9872
  }
9853
9873
  });
9854
9874
  const FloatingBubble = withInstall(stdin_default$R);
9855
- const {
9856
- height: windowHeight
9857
- } = useWindowSize();
9858
9875
  const floatingPanelProps = {
9859
9876
  height: makeNumericProp(0),
9860
9877
  anchors: makeArrayProp(),
@@ -10582,7 +10599,7 @@ var stdin_default$M = defineComponent({
10582
10599
  swipeTo
10583
10600
  });
10584
10601
  onMounted(resize);
10585
- watch([windowWidth, windowHeight$1], resize);
10602
+ watch([windowWidth, windowHeight], resize);
10586
10603
  watch(() => props2.startPosition, (value) => setActive(+value));
10587
10604
  watch(() => props2.show, (value) => {
10588
10605
  const {
@@ -14583,7 +14600,8 @@ const textEllipsisProps = {
14583
14600
  dots: makeStringProp("..."),
14584
14601
  content: makeStringProp(""),
14585
14602
  expandText: makeStringProp(""),
14586
- collapseText: makeStringProp("")
14603
+ collapseText: makeStringProp(""),
14604
+ position: makeStringProp("end")
14587
14605
  };
14588
14606
  var stdin_default$9 = defineComponent({
14589
14607
  name: name$4,
@@ -14596,6 +14614,7 @@ var stdin_default$9 = defineComponent({
14596
14614
  const expanded = ref(false);
14597
14615
  const hasAction = ref(false);
14598
14616
  const root = ref();
14617
+ const actionText = computed(() => expanded.value ? props2.expandText : props2.collapseText);
14599
14618
  const pxToNum = (value) => {
14600
14619
  if (!value)
14601
14620
  return 0;
@@ -14624,24 +14643,53 @@ var stdin_default$9 = defineComponent({
14624
14643
  };
14625
14644
  const calcEllipsisText = (container2, maxHeight2) => {
14626
14645
  const {
14627
- dots,
14628
14646
  content,
14629
- expandText
14647
+ position,
14648
+ dots
14630
14649
  } = props2;
14631
- let left = 0;
14632
- let right = content.length;
14633
- let res = -1;
14634
- while (left <= right) {
14635
- const mid = Math.floor((left + right) / 2);
14636
- container2.innerText = content.slice(0, mid) + dots + expandText;
14637
- if (container2.offsetHeight <= maxHeight2) {
14638
- left = mid + 1;
14639
- res = mid;
14640
- } else {
14641
- right = mid - 1;
14650
+ const end = content.length;
14651
+ const calcEllipse = () => {
14652
+ const tail = (left, right) => {
14653
+ if (right - left <= 1) {
14654
+ if (position === "end") {
14655
+ return content.slice(0, left) + dots;
14656
+ }
14657
+ return dots + content.slice(right, end);
14658
+ }
14659
+ const middle2 = Math.round(left + right >> 1);
14660
+ if (position === "end") {
14661
+ container2.innerText = content.slice(0, middle2) + dots + actionText.value;
14662
+ } else {
14663
+ container2.innerText = dots + content.slice(middle2, end) + actionText.value;
14664
+ }
14665
+ if (container2.offsetHeight > maxHeight2) {
14666
+ if (position === "end") {
14667
+ return tail(left, middle2);
14668
+ }
14669
+ return tail(middle2, right);
14670
+ }
14671
+ if (position === "end") {
14672
+ return tail(middle2, right);
14673
+ }
14674
+ return tail(left, middle2);
14675
+ };
14676
+ container2.innerText = tail(0, end);
14677
+ };
14678
+ const middleTail = (leftPart, rightPart) => {
14679
+ if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
14680
+ return content.slice(0, leftPart[1]) + dots + dots + content.slice(rightPart[1], end);
14642
14681
  }
14643
- }
14644
- return content.slice(0, res) + dots;
14682
+ const leftMiddle = Math.floor(leftPart[0] + leftPart[1] >> 1);
14683
+ const rightMiddle = Math.ceil(rightPart[0] + rightPart[1] >> 1);
14684
+ container2.innerText = props2.content.slice(0, leftMiddle) + props2.dots + actionText.value + props2.dots + props2.content.slice(rightMiddle, end);
14685
+ if (container2.offsetHeight >= maxHeight2) {
14686
+ return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
14687
+ }
14688
+ return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
14689
+ };
14690
+ const middle = 0 + end >> 1;
14691
+ props2.position === "middle" ? container2.innerText = middleTail([0, middle], [middle, end]) : calcEllipse();
14692
+ return container2.innerText;
14645
14693
  };
14646
14694
  const container = cloneContainer();
14647
14695
  if (!container)
@@ -14651,7 +14699,7 @@ var stdin_default$9 = defineComponent({
14651
14699
  paddingTop,
14652
14700
  lineHeight
14653
14701
  } = container.style;
14654
- const maxHeight = (Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom);
14702
+ const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
14655
14703
  if (maxHeight < container.offsetHeight) {
14656
14704
  hasAction.value = true;
14657
14705
  text.value = calcEllipsisText(container, maxHeight);
@@ -14670,7 +14718,7 @@ var stdin_default$9 = defineComponent({
14670
14718
  "onClick": onClickAction
14671
14719
  }, [expanded.value ? props2.collapseText : props2.expandText]);
14672
14720
  onMounted(calcEllipsised);
14673
- watch(() => [props2.content, props2.rows], calcEllipsised);
14721
+ watch(() => [props2.content, props2.rows, props2.position], calcEllipsised);
14674
14722
  useEventListener("resize", calcEllipsised);
14675
14723
  return () => createVNode("div", {
14676
14724
  "ref": root,
@@ -15048,7 +15096,7 @@ var stdin_default$6 = defineComponent({
15048
15096
  if (isImageFile(item)) {
15049
15097
  return createVNode(Image$1, {
15050
15098
  "fit": imageFit,
15051
- "src": item.content || item.url,
15099
+ "src": item.objectUrl || item.content || item.url,
15052
15100
  "class": bem$1("preview-image"),
15053
15101
  "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
15054
15102
  "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
@@ -15166,7 +15214,8 @@ var stdin_default$5 = defineComponent({
15166
15214
  const result = {
15167
15215
  file,
15168
15216
  status: "",
15169
- message: ""
15217
+ message: "",
15218
+ objectUrl: URL.createObjectURL(file)
15170
15219
  };
15171
15220
  if (contents[index]) {
15172
15221
  result.content = contents[index];
@@ -15180,7 +15229,8 @@ var stdin_default$5 = defineComponent({
15180
15229
  const result = {
15181
15230
  file: files,
15182
15231
  status: "",
15183
- message: ""
15232
+ message: "",
15233
+ objectUrl: URL.createObjectURL(files)
15184
15234
  };
15185
15235
  if (content) {
15186
15236
  result.content = content;
@@ -15222,8 +15272,8 @@ var stdin_default$5 = defineComponent({
15222
15272
  if (props2.previewFullImage) {
15223
15273
  const imageFiles = props2.modelValue.filter(isImageFile);
15224
15274
  const images = imageFiles.map((item2) => {
15225
- if (item2.file && !item2.url && item2.status !== "failed") {
15226
- item2.url = URL.createObjectURL(item2.file);
15275
+ if (item2.objectUrl && !item2.url && item2.status !== "failed") {
15276
+ item2.url = item2.objectUrl;
15227
15277
  urls.push(item2.url);
15228
15278
  }
15229
15279
  return item2.url;
@@ -16327,7 +16377,7 @@ const Lazyload = {
16327
16377
  });
16328
16378
  }
16329
16379
  };
16330
- const version = "4.6.0";
16380
+ const version = "4.6.2";
16331
16381
  function install(app) {
16332
16382
  const components = [
16333
16383
  ActionBar,