vant 4.6.1 → 4.6.3

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 (104) hide show
  1. package/README.md +1 -1
  2. package/es/address-list/AddressList.d.ts +13 -0
  3. package/es/address-list/AddressList.mjs +3 -2
  4. package/es/address-list/index.d.ts +9 -0
  5. package/es/checkbox/Checkbox.d.ts +14 -23
  6. package/es/checkbox/Checkbox.mjs +2 -1
  7. package/es/checkbox/Checker.d.ts +6 -15
  8. package/es/checkbox/Checker.mjs +18 -6
  9. package/es/checkbox/index.d.ts +2 -9
  10. package/es/checkbox-group/CheckboxGroup.d.ts +14 -1
  11. package/es/checkbox-group/CheckboxGroup.mjs +2 -1
  12. package/es/checkbox-group/index.d.ts +9 -0
  13. package/es/field/Field.d.ts +25 -0
  14. package/es/field/Field.mjs +9 -0
  15. package/es/field/index.d.ts +13 -0
  16. package/es/floating-bubble/FloatingBubble.d.ts +16 -21
  17. package/es/floating-bubble/FloatingBubble.mjs +6 -8
  18. package/es/floating-bubble/index.css +1 -1
  19. package/es/floating-bubble/index.d.ts +19 -19
  20. package/es/floating-bubble/types.d.ts +12 -0
  21. package/es/index.d.ts +1 -1
  22. package/es/index.mjs +1 -1
  23. package/es/pagination/index.css +1 -1
  24. package/es/radio/Radio.d.ts +18 -25
  25. package/es/radio/Radio.mjs +5 -3
  26. package/es/radio/index.css +1 -1
  27. package/es/radio/index.d.ts +4 -9
  28. package/es/radio/types.d.ts +1 -0
  29. package/es/radio-group/RadioGroup.d.ts +4 -0
  30. package/es/radio-group/RadioGroup.mjs +1 -0
  31. package/es/radio-group/index.d.ts +2 -0
  32. package/es/search/Search.d.ts +19 -0
  33. package/es/search/index.d.ts +13 -0
  34. package/es/tab/Tab.mjs +2 -2
  35. package/es/text-ellipsis/TextEllipsis.d.ts +13 -0
  36. package/es/text-ellipsis/TextEllipsis.mjs +50 -19
  37. package/es/text-ellipsis/index.d.ts +9 -0
  38. package/es/utils/basic.d.ts +8 -0
  39. package/es/utils/basic.mjs +28 -7
  40. package/es/utils/create.mjs +1 -2
  41. package/es/utils/deep-assign.mjs +1 -1
  42. package/es/utils/deep-clone.mjs +1 -1
  43. package/es/utils/dom.mjs +1 -1
  44. package/es/utils/format.mjs +1 -1
  45. package/es/utils/index.d.ts +0 -1
  46. package/es/utils/index.mjs +0 -1
  47. package/es/utils/interceptor.mjs +1 -2
  48. package/lib/address-list/AddressList.d.ts +13 -0
  49. package/lib/address-list/AddressList.js +3 -2
  50. package/lib/address-list/index.d.ts +9 -0
  51. package/lib/checkbox/Checkbox.d.ts +14 -23
  52. package/lib/checkbox/Checkbox.js +1 -0
  53. package/lib/checkbox/Checker.d.ts +6 -15
  54. package/lib/checkbox/Checker.js +17 -5
  55. package/lib/checkbox/index.d.ts +2 -9
  56. package/lib/checkbox-group/CheckboxGroup.d.ts +14 -1
  57. package/lib/checkbox-group/CheckboxGroup.js +1 -0
  58. package/lib/checkbox-group/index.d.ts +9 -0
  59. package/lib/field/Field.d.ts +25 -0
  60. package/lib/field/Field.js +9 -0
  61. package/lib/field/index.d.ts +13 -0
  62. package/lib/floating-bubble/FloatingBubble.d.ts +16 -21
  63. package/lib/floating-bubble/FloatingBubble.js +6 -8
  64. package/lib/floating-bubble/index.css +1 -1
  65. package/lib/floating-bubble/index.d.ts +19 -19
  66. package/lib/floating-bubble/types.d.ts +12 -0
  67. package/lib/index.css +1 -1
  68. package/lib/index.d.ts +1 -1
  69. package/lib/index.js +1 -1
  70. package/lib/pagination/index.css +1 -1
  71. package/lib/radio/Radio.d.ts +18 -25
  72. package/lib/radio/Radio.js +4 -2
  73. package/lib/radio/index.css +1 -1
  74. package/lib/radio/index.d.ts +4 -9
  75. package/lib/radio/types.d.ts +1 -0
  76. package/lib/radio-group/RadioGroup.d.ts +4 -0
  77. package/lib/radio-group/RadioGroup.js +1 -0
  78. package/lib/radio-group/index.d.ts +2 -0
  79. package/lib/search/Search.d.ts +19 -0
  80. package/lib/search/index.d.ts +13 -0
  81. package/lib/tab/Tab.js +2 -2
  82. package/lib/text-ellipsis/TextEllipsis.d.ts +13 -0
  83. package/lib/text-ellipsis/TextEllipsis.js +49 -18
  84. package/lib/text-ellipsis/index.d.ts +9 -0
  85. package/lib/utils/basic.d.ts +8 -0
  86. package/lib/utils/basic.js +29 -8
  87. package/lib/utils/create.js +1 -2
  88. package/lib/utils/deep-assign.js +3 -3
  89. package/lib/utils/deep-clone.js +3 -3
  90. package/lib/utils/dom.js +2 -2
  91. package/lib/utils/format.js +4 -4
  92. package/lib/utils/index.d.ts +0 -1
  93. package/lib/utils/index.js +0 -1
  94. package/lib/utils/interceptor.js +1 -2
  95. package/lib/vant.cjs.js +107 -48
  96. package/lib/vant.es.js +107 -48
  97. package/lib/vant.js +172 -59
  98. package/lib/vant.min.js +1 -1
  99. package/lib/web-types.json +1 -1
  100. package/package.json +1 -1
  101. package/es/utils/validate.d.ts +0 -9
  102. package/es/utils/validate.mjs +0 -22
  103. package/lib/utils/validate.d.ts +0 -9
  104. package/lib/utils/validate.js +0 -41
package/lib/vant.es.js CHANGED
@@ -1,10 +1,14 @@
1
- import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, normalizeClass, normalizeStyle, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Comment, Text, h } from "vue";
1
+ import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Comment, Text, h } from "vue";
2
2
  import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, cancelRaf, raf, useScrollParent, usePageVisibility, doubleRaf, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, inBrowser as inBrowser$1, useToggle, useCountDown, useClickAway } from "@vant/use";
3
- import { stringifyStyle } from "@vue/shared";
3
+ import { normalizeClass, stringifyStyle, normalizeStyle } from "@vue/shared";
4
4
  import { offsetModifier, createPopper } from "@vant/popperjs";
5
+ function noop() {
6
+ }
7
+ const extend = Object.assign;
8
+ const inBrowser = typeof window !== "undefined";
9
+ const isObject = (val) => val !== null && typeof val === "object";
5
10
  const isDef = (val) => val !== void 0 && val !== null;
6
11
  const isFunction = (val) => typeof val === "function";
7
- const isObject = (val) => val !== null && typeof val === "object";
8
12
  const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
9
13
  const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
10
14
  function isMobile(value) {
@@ -13,10 +17,6 @@ function isMobile(value) {
13
17
  }
14
18
  const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
15
19
  const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
16
- function noop() {
17
- }
18
- const extend = Object.assign;
19
- const inBrowser = typeof window !== "undefined";
20
20
  function get(object, path) {
21
21
  const keys = path.split(".");
22
22
  let result = object;
@@ -27,12 +27,15 @@ function get(object, path) {
27
27
  return result;
28
28
  }
29
29
  function pick(obj, keys, ignoreUndefined) {
30
- return keys.reduce((ret, key) => {
31
- if (!ignoreUndefined || obj[key] !== void 0) {
32
- ret[key] = obj[key];
33
- }
34
- return ret;
35
- }, {});
30
+ return keys.reduce(
31
+ (ret, key) => {
32
+ if (!ignoreUndefined || obj[key] !== void 0) {
33
+ ret[key] = obj[key];
34
+ }
35
+ return ret;
36
+ },
37
+ {}
38
+ );
36
39
  }
37
40
  const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
38
41
  const toArray = (item) => Array.isArray(item) ? item : [item];
@@ -3975,8 +3978,14 @@ const fieldSharedProps = {
3975
3978
  inputAlign: String,
3976
3979
  placeholder: String,
3977
3980
  autocomplete: String,
3981
+ autocapitalize: String,
3982
+ autocorrect: String,
3978
3983
  errorMessage: String,
3979
3984
  enterkeyhint: String,
3985
+ spellcheck: {
3986
+ type: Boolean,
3987
+ default: null
3988
+ },
3980
3989
  clearTrigger: makeStringProp("focus"),
3981
3990
  formatTrigger: makeStringProp("onChange"),
3982
3991
  error: {
@@ -4304,7 +4313,10 @@ var stdin_default$1u = defineComponent({
4304
4313
  autofocus: props2.autofocus,
4305
4314
  placeholder: props2.placeholder,
4306
4315
  autocomplete: props2.autocomplete,
4316
+ autocapitalize: props2.autocapitalize,
4317
+ autocorrect: props2.autocorrect,
4307
4318
  enterkeyhint: props2.enterkeyhint,
4319
+ spellcheck: props2.spellcheck,
4308
4320
  "aria-labelledby": props2.label ? `${id}-label` : void 0,
4309
4321
  onBlur,
4310
4322
  onFocus,
@@ -5177,6 +5189,7 @@ var stdin_default$1q = defineComponent({
5177
5189
  const AddressEdit = withInstall(stdin_default$1q);
5178
5190
  const [name$1f, bem$1b] = createNamespace("radio-group");
5179
5191
  const radioGroupProps = {
5192
+ shape: String,
5180
5193
  disabled: Boolean,
5181
5194
  iconSize: numericProp,
5182
5195
  direction: String,
@@ -5286,7 +5299,6 @@ var stdin_default$1o = defineComponent({
5286
5299
  const Tag = withInstall(stdin_default$1o);
5287
5300
  const checkerProps = {
5288
5301
  name: unknownProp,
5289
- shape: makeStringProp("round"),
5290
5302
  disabled: Boolean,
5291
5303
  iconSize: numericProp,
5292
5304
  modelValue: unknownProp,
@@ -5298,6 +5310,7 @@ var stdin_default$1n = defineComponent({
5298
5310
  props: extend({}, checkerProps, {
5299
5311
  bem: makeRequiredProp(Function),
5300
5312
  role: String,
5313
+ shape: String,
5301
5314
  parent: Object,
5302
5315
  checked: Boolean,
5303
5316
  bindGroup: truthProp
@@ -5336,6 +5349,9 @@ var stdin_default$1n = defineComponent({
5336
5349
  };
5337
5350
  }
5338
5351
  });
5352
+ const shape = computed(() => {
5353
+ return props2.shape || getParentProp("shape") || "round";
5354
+ });
5339
5355
  const onClick = (event) => {
5340
5356
  const {
5341
5357
  target
@@ -5348,27 +5364,36 @@ var stdin_default$1n = defineComponent({
5348
5364
  emit("click", event);
5349
5365
  };
5350
5366
  const renderIcon = () => {
5367
+ var _a, _b;
5351
5368
  const {
5352
5369
  bem: bem2,
5353
- shape,
5354
5370
  checked
5355
5371
  } = props2;
5356
5372
  const iconSize = props2.iconSize || getParentProp("iconSize");
5357
5373
  return createVNode("div", {
5358
5374
  "ref": iconRef,
5359
- "class": bem2("icon", [shape, {
5375
+ "class": bem2("icon", [shape.value, {
5360
5376
  disabled: disabled.value,
5361
5377
  checked
5362
5378
  }]),
5363
- "style": {
5379
+ "style": shape.value !== "dot" ? {
5364
5380
  fontSize: addUnit(iconSize)
5381
+ } : {
5382
+ width: addUnit(iconSize),
5383
+ height: addUnit(iconSize),
5384
+ borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
5365
5385
  }
5366
5386
  }, [slots.icon ? slots.icon({
5367
5387
  checked,
5368
5388
  disabled: disabled.value
5369
- }) : createVNode(Icon, {
5389
+ }) : shape.value !== "dot" ? createVNode(Icon, {
5370
5390
  "name": "success",
5371
5391
  "style": iconStyle.value
5392
+ }, null) : createVNode("div", {
5393
+ "class": bem2("icon--dot__icon"),
5394
+ "style": {
5395
+ backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
5396
+ }
5372
5397
  }, null)]);
5373
5398
  };
5374
5399
  const renderLabel = () => {
@@ -5395,11 +5420,13 @@ var stdin_default$1n = defineComponent({
5395
5420
  };
5396
5421
  }
5397
5422
  });
5398
- const radioProps = checkerProps;
5423
+ const radioProps = extend({}, checkerProps, {
5424
+ shape: String
5425
+ });
5399
5426
  const [name$1d, bem$19] = createNamespace("radio");
5400
5427
  var stdin_default$1m = defineComponent({
5401
5428
  name: name$1d,
5402
- props: checkerProps,
5429
+ props: radioProps,
5403
5430
  emits: ["update:modelValue"],
5404
5431
  setup(props2, {
5405
5432
  emit,
@@ -5523,6 +5550,7 @@ const addressListProps = {
5523
5550
  switchable: truthProp,
5524
5551
  disabledText: String,
5525
5552
  disabledList: makeArrayProp(),
5553
+ showAddButton: truthProp,
5526
5554
  addButtonText: String,
5527
5555
  defaultTagText: String,
5528
5556
  rightIcon: makeStringProp("edit")
@@ -5564,7 +5592,7 @@ var stdin_default$1k = defineComponent({
5564
5592
  return list.map((item, index) => renderItem(item, index, disabled));
5565
5593
  }
5566
5594
  };
5567
- const renderBottom = () => createVNode("div", {
5595
+ const renderBottom = () => props2.showAddButton ? createVNode("div", {
5568
5596
  "class": [bem$17("bottom"), "van-safe-area-bottom"]
5569
5597
  }, [createVNode(Button, {
5570
5598
  "round": true,
@@ -5573,7 +5601,7 @@ var stdin_default$1k = defineComponent({
5573
5601
  "text": props2.addButtonText || t$h("add"),
5574
5602
  "class": bem$17("add"),
5575
5603
  "onClick": () => emit("add")
5576
- }, null)]);
5604
+ }, null)]) : void 0;
5577
5605
  return () => {
5578
5606
  var _a, _b;
5579
5607
  const List2 = renderList(props2.list);
@@ -7392,6 +7420,7 @@ const CellGroup = withInstall(stdin_default$1a);
7392
7420
  const [name$10, bem$$] = createNamespace("checkbox-group");
7393
7421
  const checkboxGroupProps = {
7394
7422
  max: numericProp,
7423
+ shape: makeStringProp("round"),
7395
7424
  disabled: Boolean,
7396
7425
  iconSize: numericProp,
7397
7426
  direction: String,
@@ -7453,6 +7482,7 @@ var stdin_default$19 = defineComponent({
7453
7482
  });
7454
7483
  const [name$$, bem$_] = createNamespace("checkbox");
7455
7484
  const checkboxProps = extend({}, checkerProps, {
7485
+ shape: String,
7456
7486
  bindGroup: truthProp
7457
7487
  });
7458
7488
  var stdin_default$18 = defineComponent({
@@ -9685,10 +9715,10 @@ var stdin_default$S = defineComponent({
9685
9715
  const DropdownItem = withInstall(stdin_default$S);
9686
9716
  const DropdownMenu = withInstall(stdin_default$T);
9687
9717
  const floatingBubbleProps = {
9718
+ gap: makeNumberProp(24),
9719
+ icon: String,
9688
9720
  axis: makeStringProp("y"),
9689
9721
  magnetic: String,
9690
- icon: String,
9691
- gap: makeNumberProp(24),
9692
9722
  offset: {
9693
9723
  type: Object,
9694
9724
  default: () => ({
@@ -9719,8 +9749,8 @@ var stdin_default$R = defineComponent({
9719
9749
  });
9720
9750
  const boundary = computed(() => ({
9721
9751
  top: props2.gap,
9722
- right: windowWidth.value - state.value.height - props2.gap,
9723
- bottom: windowHeight.value - state.value.width - props2.gap,
9752
+ right: windowWidth.value - state.value.width - props2.gap,
9753
+ bottom: windowHeight.value - state.value.height - props2.gap,
9724
9754
  left: props2.gap
9725
9755
  }));
9726
9756
  const dragging = ref(false);
@@ -9818,9 +9848,7 @@ var stdin_default$R = defineComponent({
9818
9848
  initialized = true;
9819
9849
  });
9820
9850
  });
9821
- watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], () => updateState(), {
9822
- deep: true
9823
- });
9851
+ watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState);
9824
9852
  const show = ref(true);
9825
9853
  onActivated(() => {
9826
9854
  show.value = true;
@@ -14580,7 +14608,8 @@ const textEllipsisProps = {
14580
14608
  dots: makeStringProp("..."),
14581
14609
  content: makeStringProp(""),
14582
14610
  expandText: makeStringProp(""),
14583
- collapseText: makeStringProp("")
14611
+ collapseText: makeStringProp(""),
14612
+ position: makeStringProp("end")
14584
14613
  };
14585
14614
  var stdin_default$9 = defineComponent({
14586
14615
  name: name$4,
@@ -14593,6 +14622,7 @@ var stdin_default$9 = defineComponent({
14593
14622
  const expanded = ref(false);
14594
14623
  const hasAction = ref(false);
14595
14624
  const root = ref();
14625
+ const actionText = computed(() => expanded.value ? props2.expandText : props2.collapseText);
14596
14626
  const pxToNum = (value) => {
14597
14627
  if (!value)
14598
14628
  return 0;
@@ -14621,24 +14651,53 @@ var stdin_default$9 = defineComponent({
14621
14651
  };
14622
14652
  const calcEllipsisText = (container2, maxHeight2) => {
14623
14653
  const {
14624
- dots,
14625
14654
  content,
14626
- expandText
14655
+ position,
14656
+ dots
14627
14657
  } = props2;
14628
- let left = 0;
14629
- let right = content.length;
14630
- let res = -1;
14631
- while (left <= right) {
14632
- const mid = Math.floor((left + right) / 2);
14633
- container2.innerText = content.slice(0, mid) + dots + expandText;
14634
- if (container2.offsetHeight <= maxHeight2) {
14635
- left = mid + 1;
14636
- res = mid;
14637
- } else {
14638
- right = mid - 1;
14658
+ const end = content.length;
14659
+ const calcEllipse = () => {
14660
+ const tail = (left, right) => {
14661
+ if (right - left <= 1) {
14662
+ if (position === "end") {
14663
+ return content.slice(0, left) + dots;
14664
+ }
14665
+ return dots + content.slice(right, end);
14666
+ }
14667
+ const middle2 = Math.round(left + right >> 1);
14668
+ if (position === "end") {
14669
+ container2.innerText = content.slice(0, middle2) + dots + actionText.value;
14670
+ } else {
14671
+ container2.innerText = dots + content.slice(middle2, end) + actionText.value;
14672
+ }
14673
+ if (container2.offsetHeight > maxHeight2) {
14674
+ if (position === "end") {
14675
+ return tail(left, middle2);
14676
+ }
14677
+ return tail(middle2, right);
14678
+ }
14679
+ if (position === "end") {
14680
+ return tail(middle2, right);
14681
+ }
14682
+ return tail(left, middle2);
14683
+ };
14684
+ container2.innerText = tail(0, end);
14685
+ };
14686
+ const middleTail = (leftPart, rightPart) => {
14687
+ if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
14688
+ return content.slice(0, leftPart[1]) + dots + dots + content.slice(rightPart[1], end);
14639
14689
  }
14640
- }
14641
- return content.slice(0, res) + dots;
14690
+ const leftMiddle = Math.floor(leftPart[0] + leftPart[1] >> 1);
14691
+ const rightMiddle = Math.ceil(rightPart[0] + rightPart[1] >> 1);
14692
+ container2.innerText = props2.content.slice(0, leftMiddle) + props2.dots + actionText.value + props2.dots + props2.content.slice(rightMiddle, end);
14693
+ if (container2.offsetHeight >= maxHeight2) {
14694
+ return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
14695
+ }
14696
+ return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
14697
+ };
14698
+ const middle = 0 + end >> 1;
14699
+ props2.position === "middle" ? container2.innerText = middleTail([0, middle], [middle, end]) : calcEllipse();
14700
+ return container2.innerText;
14642
14701
  };
14643
14702
  const container = cloneContainer();
14644
14703
  if (!container)
@@ -14648,7 +14707,7 @@ var stdin_default$9 = defineComponent({
14648
14707
  paddingTop,
14649
14708
  lineHeight
14650
14709
  } = container.style;
14651
- const maxHeight = (Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom);
14710
+ const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
14652
14711
  if (maxHeight < container.offsetHeight) {
14653
14712
  hasAction.value = true;
14654
14713
  text.value = calcEllipsisText(container, maxHeight);
@@ -14667,7 +14726,7 @@ var stdin_default$9 = defineComponent({
14667
14726
  "onClick": onClickAction
14668
14727
  }, [expanded.value ? props2.collapseText : props2.expandText]);
14669
14728
  onMounted(calcEllipsised);
14670
- watch(() => [props2.content, props2.rows], calcEllipsised);
14729
+ watch(() => [props2.content, props2.rows, props2.position], calcEllipsised);
14671
14730
  useEventListener("resize", calcEllipsised);
14672
14731
  return () => createVNode("div", {
14673
14732
  "ref": root,
@@ -16326,7 +16385,7 @@ const Lazyload = {
16326
16385
  });
16327
16386
  }
16328
16387
  };
16329
- const version = "4.6.1";
16388
+ const version = "4.6.3";
16330
16389
  function install(app) {
16331
16390
  const components = [
16332
16391
  ActionBar,