vant 4.3.1 → 4.4.0

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 (113) hide show
  1. package/es/address-edit/AddressEdit.mjs +1 -0
  2. package/es/area/Area.d.ts +6 -8
  3. package/es/area/Area.mjs +1 -1
  4. package/es/area/index.d.ts +4 -6
  5. package/es/back-top/BackTop.d.ts +1 -1
  6. package/es/back-top/BackTop.mjs +6 -3
  7. package/es/back-top/index.css +1 -1
  8. package/es/back-top/index.d.ts +1 -1
  9. package/es/barrage/Barrage.d.ts +93 -0
  10. package/es/barrage/Barrage.mjs +134 -0
  11. package/es/barrage/index.css +1 -0
  12. package/es/barrage/index.d.ts +69 -0
  13. package/es/barrage/index.mjs +10 -0
  14. package/es/barrage/style/index.d.ts +1 -0
  15. package/es/barrage/style/index.mjs +2 -0
  16. package/es/barrage/types.d.ts +7 -0
  17. package/es/barrage/types.mjs +0 -0
  18. package/es/cascader/Cascader.mjs +14 -0
  19. package/es/checkbox/Checker.d.ts +2 -0
  20. package/es/checkbox/Checker.mjs +13 -1
  21. package/es/contact-list/ContactList.mjs +1 -1
  22. package/es/contact-list/index.css +1 -1
  23. package/es/date-picker/DatePicker.mjs +5 -2
  24. package/es/date-picker/utils.d.ts +1 -1
  25. package/es/dialog/index.css +1 -1
  26. package/es/divider/Divider.d.ts +4 -0
  27. package/es/divider/Divider.mjs +4 -2
  28. package/es/divider/index.css +1 -1
  29. package/es/divider/index.d.ts +3 -0
  30. package/es/field/Field.mjs +4 -0
  31. package/es/image-preview/ImagePreviewItem.mjs +60 -26
  32. package/es/index.d.ts +2 -1
  33. package/es/index.mjs +4 -1
  34. package/es/notice-bar/NoticeBar.d.ts +1 -1
  35. package/es/notice-bar/index.d.ts +1 -1
  36. package/es/picker-group/PickerGroup.d.ts +15 -1
  37. package/es/picker-group/PickerGroup.mjs +8 -6
  38. package/es/picker-group/index.d.ts +11 -1
  39. package/es/signature/Signature.d.ts +13 -0
  40. package/es/signature/Signature.mjs +24 -8
  41. package/es/signature/index.css +1 -1
  42. package/es/signature/index.d.ts +9 -0
  43. package/es/step/index.css +1 -1
  44. package/es/submit-bar/index.css +1 -1
  45. package/es/tabs/Tabs.mjs +8 -2
  46. package/es/tabs/utils.d.ts +2 -2
  47. package/es/tabs/utils.mjs +14 -4
  48. package/es/uploader/Uploader.d.ts +6 -1
  49. package/es/uploader/Uploader.mjs +25 -10
  50. package/es/uploader/UploaderPreviewItem.d.ts +5 -1
  51. package/es/uploader/UploaderPreviewItem.mjs +6 -3
  52. package/es/uploader/index.d.ts +5 -1
  53. package/es/uploader/types.d.ts +1 -0
  54. package/lib/address-edit/AddressEdit.js +1 -0
  55. package/lib/area/Area.d.ts +6 -8
  56. package/lib/area/Area.js +1 -1
  57. package/lib/area/index.d.ts +4 -6
  58. package/lib/back-top/BackTop.d.ts +1 -1
  59. package/lib/back-top/BackTop.js +6 -3
  60. package/lib/back-top/index.css +1 -1
  61. package/lib/back-top/index.d.ts +1 -1
  62. package/lib/barrage/Barrage.d.ts +93 -0
  63. package/lib/barrage/Barrage.js +153 -0
  64. package/lib/barrage/index.css +1 -0
  65. package/lib/barrage/index.d.ts +69 -0
  66. package/lib/barrage/index.js +39 -0
  67. package/lib/barrage/style/index.d.ts +1 -0
  68. package/lib/barrage/style/index.js +2 -0
  69. package/lib/barrage/types.d.ts +7 -0
  70. package/lib/barrage/types.js +15 -0
  71. package/lib/cascader/Cascader.js +14 -0
  72. package/lib/checkbox/Checker.d.ts +2 -0
  73. package/lib/checkbox/Checker.js +13 -1
  74. package/lib/contact-list/ContactList.js +1 -1
  75. package/lib/contact-list/index.css +1 -1
  76. package/lib/date-picker/DatePicker.js +5 -2
  77. package/lib/date-picker/utils.d.ts +1 -1
  78. package/lib/dialog/index.css +1 -1
  79. package/lib/divider/Divider.d.ts +4 -0
  80. package/lib/divider/Divider.js +4 -2
  81. package/lib/divider/index.css +1 -1
  82. package/lib/divider/index.d.ts +3 -0
  83. package/lib/field/Field.js +4 -0
  84. package/lib/image-preview/ImagePreviewItem.js +59 -25
  85. package/lib/index.css +1 -1
  86. package/lib/index.d.ts +2 -1
  87. package/lib/index.js +4 -1
  88. package/lib/notice-bar/NoticeBar.d.ts +1 -1
  89. package/lib/notice-bar/index.d.ts +1 -1
  90. package/lib/picker-group/PickerGroup.d.ts +15 -1
  91. package/lib/picker-group/PickerGroup.js +6 -4
  92. package/lib/picker-group/index.d.ts +11 -1
  93. package/lib/signature/Signature.d.ts +13 -0
  94. package/lib/signature/Signature.js +23 -7
  95. package/lib/signature/index.css +1 -1
  96. package/lib/signature/index.d.ts +9 -0
  97. package/lib/step/index.css +1 -1
  98. package/lib/submit-bar/index.css +1 -1
  99. package/lib/tabs/Tabs.js +8 -2
  100. package/lib/tabs/utils.d.ts +2 -2
  101. package/lib/tabs/utils.js +13 -3
  102. package/lib/uploader/Uploader.d.ts +6 -1
  103. package/lib/uploader/Uploader.js +25 -10
  104. package/lib/uploader/UploaderPreviewItem.d.ts +5 -1
  105. package/lib/uploader/UploaderPreviewItem.js +6 -3
  106. package/lib/uploader/index.d.ts +5 -1
  107. package/lib/uploader/types.d.ts +1 -0
  108. package/lib/vant.cjs.js +611 -358
  109. package/lib/vant.es.js +612 -359
  110. package/lib/vant.js +611 -358
  111. package/lib/vant.min.js +1 -1
  112. package/lib/web-types.json +1 -1
  113. package/package.json +1 -1
@@ -1 +1 @@
1
- :root{--van-dialog-width: 320px;--van-dialog-small-screen-width: 90%;--van-dialog-font-size: var(--van-font-size-lg);--van-dialog-transition: var(--van-duration-base);--van-dialog-radius: 16px;--van-dialog-background: var(--van-background-2);--van-dialog-header-font-weight: var(--van-font-bold);--van-dialog-header-line-height: 24px;--van-dialog-header-padding-top: 26px;--van-dialog-header-isolated-padding: var(--van-padding-lg) 0;--van-dialog-message-padding: var(--van-padding-lg);--van-dialog-message-font-size: var(--van-font-size-md);--van-dialog-message-line-height: var(--van-line-height-md);--van-dialog-message-max-height: 60vh;--van-dialog-has-title-message-text-color: var(--van-gray-7);--van-dialog-has-title-message-padding-top: var(--van-padding-xs);--van-dialog-button-height: 48px;--van-dialog-round-button-height: 36px;--van-dialog-confirm-button-text-color: var(--van-primary-color)}.van-dialog{top:45%;width:var(--van-dialog-width);overflow:hidden;font-size:var(--van-dialog-font-size);background:var(--van-dialog-background);border-radius:var(--van-dialog-radius);-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:var(--van-dialog-transition);transition-property:transform,opacity}@media (max-width: 321px){.van-dialog{width:var(--van-dialog-small-screen-width)}}.van-dialog__header{color:var(--van-text-color);padding-top:var(--van-dialog-header-padding-top);font-weight:var(--van-dialog-header-font-weight);line-height:var(--van-dialog-header-line-height);text-align:center}.van-dialog__header--isolated{padding:var(--van-dialog-header-isolated-padding)}.van-dialog__content--isolated{display:flex;align-items:center;min-height:104px}.van-dialog__message{color:var(--van-text-color);flex:1;max-height:var(--van-dialog-message-max-height);padding:26px var(--van-dialog-message-padding);overflow-y:auto;font-size:var(--van-dialog-message-font-size);line-height:var(--van-dialog-message-line-height);white-space:pre-wrap;text-align:center;word-wrap:break-word;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:var(--van-dialog-has-title-message-padding-top);color:var(--van-dialog-has-title-message-text-color)}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-dialog__confirm,.van-dialog__cancel{flex:1;height:var(--van-dialog-button-height);margin:0;border:0}.van-dialog__confirm,.van-dialog__confirm:active{color:var(--van-dialog-confirm-button-text-color)}.van-dialog--round-button .van-dialog__footer{position:relative;height:auto;padding:var(--van-padding-xs) var(--van-padding-lg) var(--van-padding-md)}.van-dialog--round-button .van-dialog__message{padding-bottom:var(--van-padding-md);color:var(--van-text-color)}.van-dialog--round-button .van-dialog__confirm,.van-dialog--round-button .van-dialog__cancel{height:var(--van-dialog-round-button-height)}.van-dialog--round-button .van-dialog__confirm{color:var(--van-white)}.van-dialog-bounce-enter-from{transform:translate3d(0,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{transform:translate3d(0,-50%,0) scale(.9);opacity:0}
1
+ :root{--van-dialog-width: 320px;--van-dialog-small-screen-width: 90%;--van-dialog-font-size: var(--van-font-size-lg);--van-dialog-transition: var(--van-duration-base);--van-dialog-radius: 16px;--van-dialog-background: var(--van-background-2);--van-dialog-header-font-weight: var(--van-font-bold);--van-dialog-header-line-height: 24px;--van-dialog-header-padding-top: 26px;--van-dialog-header-isolated-padding: var(--van-padding-lg) 0;--van-dialog-message-padding: var(--van-padding-lg);--van-dialog-message-font-size: var(--van-font-size-md);--van-dialog-message-line-height: var(--van-line-height-md);--van-dialog-message-max-height: 60vh;--van-dialog-has-title-message-text-color: var(--van-gray-7);--van-dialog-has-title-message-padding-top: var(--van-padding-xs);--van-dialog-button-height: 48px;--van-dialog-round-button-height: 36px;--van-dialog-confirm-button-text-color: var(--van-primary-color)}.van-dialog{top:45%;width:var(--van-dialog-width);overflow:hidden;font-size:var(--van-dialog-font-size);background:var(--van-dialog-background);border-radius:var(--van-dialog-radius);-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:var(--van-dialog-transition);transition-property:transform,opacity}@media (max-width: 321px){.van-dialog{width:var(--van-dialog-small-screen-width)}}.van-dialog__header{color:var(--van-text-color);padding-top:var(--van-dialog-header-padding-top);font-weight:var(--van-dialog-header-font-weight);line-height:var(--van-dialog-header-line-height);text-align:center}.van-dialog__header--isolated{padding:var(--van-dialog-header-isolated-padding)}.van-dialog__content--isolated{display:flex;align-items:center;min-height:104px}.van-dialog__message{color:var(--van-text-color);flex:1;max-height:var(--van-dialog-message-max-height);padding:26px var(--van-dialog-message-padding);overflow-y:auto;font-size:var(--van-dialog-message-font-size);line-height:var(--van-dialog-message-line-height);white-space:pre-wrap;text-align:center;word-wrap:break-word;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:var(--van-dialog-has-title-message-padding-top);color:var(--van-dialog-has-title-message-text-color)}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__message--justify{text-align:justify}.van-dialog__footer{display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-dialog__confirm,.van-dialog__cancel{flex:1;height:var(--van-dialog-button-height);margin:0;border:0;border-radius:0}.van-dialog__confirm,.van-dialog__confirm:active{color:var(--van-dialog-confirm-button-text-color)}.van-dialog--round-button .van-dialog__footer{position:relative;height:auto;padding:var(--van-padding-xs) var(--van-padding-lg) var(--van-padding-md)}.van-dialog--round-button .van-dialog__message{padding-bottom:var(--van-padding-md);color:var(--van-text-color)}.van-dialog--round-button .van-dialog__confirm,.van-dialog--round-button .van-dialog__cancel{height:var(--van-dialog-round-button-height)}.van-dialog--round-button .van-dialog__confirm{color:var(--van-white)}.van-dialog--round-button .van-action-bar-button--first{border-top-left-radius:var(--van-radius-max);border-bottom-left-radius:var(--van-radius-max)}.van-dialog--round-button .van-action-bar-button--last{border-top-right-radius:var(--van-radius-max);border-bottom-right-radius:var(--van-radius-max)}.van-dialog-bounce-enter-from{transform:translate3d(0,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{transform:translate3d(0,-50%,0) scale(.9);opacity:0}
@@ -6,6 +6,7 @@ export declare const dividerProps: {
6
6
  type: BooleanConstructor;
7
7
  default: true;
8
8
  };
9
+ vertical: BooleanConstructor;
9
10
  contentPosition: {
10
11
  type: import("vue").PropType<DividerContentPosition>;
11
12
  default: DividerContentPosition;
@@ -18,6 +19,7 @@ declare const _default: import("vue").DefineComponent<{
18
19
  type: BooleanConstructor;
19
20
  default: true;
20
21
  };
22
+ vertical: BooleanConstructor;
21
23
  contentPosition: {
22
24
  type: import("vue").PropType<DividerContentPosition>;
23
25
  default: DividerContentPosition;
@@ -28,11 +30,13 @@ declare const _default: import("vue").DefineComponent<{
28
30
  type: BooleanConstructor;
29
31
  default: true;
30
32
  };
33
+ vertical: BooleanConstructor;
31
34
  contentPosition: {
32
35
  type: import("vue").PropType<DividerContentPosition>;
33
36
  default: DividerContentPosition;
34
37
  };
35
38
  }>>, {
39
+ vertical: boolean;
36
40
  hairline: boolean;
37
41
  dashed: boolean;
38
42
  contentPosition: DividerContentPosition;
@@ -5,6 +5,7 @@ const [name, bem] = createNamespace("divider");
5
5
  const dividerProps = {
6
6
  dashed: Boolean,
7
7
  hairline: truthProp,
8
+ vertical: Boolean,
8
9
  contentPosition: makeStringProp("center")
9
10
  };
10
11
  var stdin_default = defineComponent({
@@ -20,9 +21,10 @@ var stdin_default = defineComponent({
20
21
  "class": bem({
21
22
  dashed: props.dashed,
22
23
  hairline: props.hairline,
23
- [`content-${props.contentPosition}`]: !!slots.default
24
+ vertical: props.vertical,
25
+ [`content-${props.contentPosition}`]: !!slots.default && !props.vertical
24
26
  })
25
- }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
27
+ }, [!props.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
26
28
  };
27
29
  }
28
30
  });
@@ -1 +1 @@
1
- :root{--van-divider-margin: var(--van-padding-md) 0;--van-divider-text-color: var(--van-text-color-2);--van-divider-font-size: var(--van-font-size-md);--van-divider-line-height: 24px;--van-divider-border-color: var(--van-border-color);--van-divider-content-padding: var(--van-padding-md);--van-divider-content-left-width: 10%;--van-divider-content-right-width: 10%}.van-divider{display:flex;align-items:center;margin:var(--van-divider-margin);color:var(--van-divider-text-color);font-size:var(--van-divider-font-size);line-height:var(--van-divider-line-height);border-color:var(--van-divider-border-color);border-style:solid;border-width:0}.van-divider:before,.van-divider:after{display:block;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:var(--van-border-width) 0 0}.van-divider:before{content:""}.van-divider--hairline:before,.van-divider--hairline:after{transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--content-center:before,.van-divider--content-left:before,.van-divider--content-right:before{margin-right:var(--van-divider-content-padding)}.van-divider--content-center:after,.van-divider--content-left:after,.van-divider--content-right:after{margin-left:var(--van-divider-content-padding);content:""}.van-divider--content-left:before{max-width:var(--van-divider-content-left-width)}.van-divider--content-right:after{max-width:var(--van-divider-content-right-width)}
1
+ :root{--van-divider-margin: var(--van-padding-md) 0;--van-divider-vertical-margin: 0 var(--van-padding-xs);--van-divider-text-color: var(--van-text-color-2);--van-divider-font-size: var(--van-font-size-md);--van-divider-line-height: 24px;--van-divider-border-color: var(--van-border-color);--van-divider-content-padding: var(--van-padding-md);--van-divider-content-left-width: 10%;--van-divider-content-right-width: 10%}.van-divider{display:flex;align-items:center;margin:var(--van-divider-margin);color:var(--van-divider-text-color);font-size:var(--van-divider-font-size);line-height:var(--van-divider-line-height);border-color:var(--van-divider-border-color);border-style:solid;border-width:0}.van-divider:before,.van-divider:after{display:block;flex:1;box-sizing:border-box;height:1px;border-color:inherit;border-style:inherit;border-width:var(--van-border-width) 0 0}.van-divider:before{content:""}.van-divider--hairline:before,.van-divider--hairline:after{transform:scaleY(.5)}.van-divider--dashed{border-style:dashed}.van-divider--content-center:before,.van-divider--content-left:before,.van-divider--content-right:before{margin-right:var(--van-divider-content-padding)}.van-divider--content-center:after,.van-divider--content-left:after,.van-divider--content-right:after{margin-left:var(--van-divider-content-padding);content:""}.van-divider--content-left:before{max-width:var(--van-divider-content-left-width)}.van-divider--content-right:after{max-width:var(--van-divider-content-right-width)}.van-divider--vertical{display:inline-block;width:var(--van-border-width);height:1em;margin:var(--van-divider-vertical-margin);vertical-align:middle}.van-divider--vertical:before{height:100%;border-width:0 0 0 var(--van-border-width)}.van-divider--vertical:after{display:none}.van-divider--vertical.van-divider--hairline:before{transform:scaleX(.5)}
@@ -4,6 +4,7 @@ export declare const Divider: import("../utils").WithInstall<import("vue").Defin
4
4
  type: BooleanConstructor;
5
5
  default: true;
6
6
  };
7
+ vertical: BooleanConstructor;
7
8
  contentPosition: {
8
9
  type: import("vue").PropType<import("./Divider").DividerContentPosition>;
9
10
  default: import("./Divider").DividerContentPosition;
@@ -14,11 +15,13 @@ export declare const Divider: import("../utils").WithInstall<import("vue").Defin
14
15
  type: BooleanConstructor;
15
16
  default: true;
16
17
  };
18
+ vertical: BooleanConstructor;
17
19
  contentPosition: {
18
20
  type: import("vue").PropType<import("./Divider").DividerContentPosition>;
19
21
  default: import("./Divider").DividerContentPosition;
20
22
  };
21
23
  }>>, {
24
+ vertical: boolean;
22
25
  hairline: boolean;
23
26
  dashed: boolean;
24
27
  contentPosition: import("./Divider").DividerContentPosition;
@@ -428,6 +428,10 @@ var stdin_default = defineComponent({
428
428
  return _createVNode("label", {
429
429
  "id": `${id}-label`,
430
430
  "for": getInputId(),
431
+ "onClick": (event) => {
432
+ preventDefault(event);
433
+ focus();
434
+ },
431
435
  "style": labelAlign === "top" && labelWidth ? {
432
436
  width: addUnit(labelWidth)
433
437
  } : void 0
@@ -2,12 +2,17 @@ import { createVNode as _createVNode } from "vue";
2
2
  import { ref, watch, computed, reactive, defineComponent } from "vue";
3
3
  import { clamp, numericProp, preventDefault, createNamespace, makeRequiredProp, LONG_PRESS_START_TIME } from "../utils/index.mjs";
4
4
  import { useTouch } from "../composables/use-touch.mjs";
5
- import { useEventListener } from "@vant/use";
5
+ import { useEventListener, useRect } from "@vant/use";
6
6
  import { Image } from "../image/index.mjs";
7
7
  import { Loading } from "../loading/index.mjs";
8
8
  import { SwipeItem } from "../swipe-item/index.mjs";
9
9
  const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
10
+ const getCenter = (touches) => ({
11
+ x: (touches[0].clientX + touches[1].clientX) / 2,
12
+ y: (touches[0].clientY + touches[1].clientY) / 2
13
+ });
10
14
  const bem = createNamespace("image-preview")[1];
15
+ const longImageRatio = 2.6;
11
16
  var stdin_default = defineComponent({
12
17
  props: {
13
18
  src: String,
@@ -30,20 +35,14 @@ var stdin_default = defineComponent({
30
35
  moveY: 0,
31
36
  moving: false,
32
37
  zooming: false,
33
- imageRatio: 0,
34
- displayWidth: 0,
35
- displayHeight: 0
38
+ imageRatio: 0
36
39
  });
37
40
  const touch = useTouch();
41
+ const imageRef = ref();
38
42
  const swipeItem = ref();
39
- const vertical = computed(() => {
40
- const {
41
- rootWidth,
42
- rootHeight
43
- } = props;
44
- const rootRatio = rootHeight / rootWidth;
45
- return state.imageRatio > rootRatio;
46
- });
43
+ const vertical = ref(false);
44
+ const isLongImage = ref(false);
45
+ let initialMoveY = 0;
47
46
  const imageStyle = computed(() => {
48
47
  const {
49
48
  scale,
@@ -55,10 +54,8 @@ var stdin_default = defineComponent({
55
54
  const style = {
56
55
  transitionDuration: zooming || moving ? "0s" : ".3s"
57
56
  };
58
- if (scale !== 1) {
59
- const offsetX = moveX / scale;
60
- const offsetY = moveY / scale;
61
- style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
57
+ if (scale !== 1 || isLongImage.value) {
58
+ style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
62
59
  }
63
60
  return style;
64
61
  });
@@ -84,10 +81,26 @@ var stdin_default = defineComponent({
84
81
  }
85
82
  return 0;
86
83
  });
87
- const setScale = (scale) => {
84
+ const setScale = (scale, center) => {
85
+ var _a;
88
86
  scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
89
87
  if (scale !== state.scale) {
88
+ const ratio = scale / state.scale;
90
89
  state.scale = scale;
90
+ if (center) {
91
+ const imageRect = useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
92
+ const origin = {
93
+ x: imageRect.width * 0.5,
94
+ y: imageRect.height * 0.5
95
+ };
96
+ const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
97
+ const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
98
+ state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
99
+ state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
100
+ } else {
101
+ state.moveX = 0;
102
+ state.moveY = isLongImage.value ? initialMoveY : 0;
103
+ }
91
104
  emit("scale", {
92
105
  scale,
93
106
  index: props.active
@@ -96,20 +109,20 @@ var stdin_default = defineComponent({
96
109
  };
97
110
  const resetScale = () => {
98
111
  setScale(1);
99
- state.moveX = 0;
100
- state.moveY = 0;
101
112
  };
102
113
  const toggleScale = () => {
103
114
  const scale = state.scale > 1 ? 1 : 2;
104
- setScale(scale);
105
- state.moveX = 0;
106
- state.moveY = 0;
115
+ setScale(scale, scale === 2 || isLongImage.value ? {
116
+ x: touch.startX.value,
117
+ y: touch.startY.value
118
+ } : void 0);
107
119
  };
108
120
  let fingerNum;
109
121
  let startMoveX;
110
122
  let startMoveY;
111
123
  let startScale;
112
124
  let startDistance;
125
+ let lastCenter;
113
126
  let doubleTapTimer;
114
127
  let touchStartTime;
115
128
  let isImageMoved = false;
@@ -129,11 +142,11 @@ var stdin_default = defineComponent({
129
142
  startMoveY = state.moveY;
130
143
  touchStartTime = Date.now();
131
144
  isImageMoved = false;
132
- state.moving = fingerNum === 1 && state.scale !== 1;
145
+ state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
133
146
  state.zooming = fingerNum === 2 && !offsetX.value;
134
147
  if (state.zooming) {
135
148
  startScale = state.scale;
136
- startDistance = getDistance(event.touches);
149
+ startDistance = getDistance(touches);
137
150
  }
138
151
  };
139
152
  const onTouchMove = (event) => {
@@ -162,7 +175,8 @@ var stdin_default = defineComponent({
162
175
  if (touches.length === 2) {
163
176
  const distance = getDistance(touches);
164
177
  const scale = startScale * distance / startDistance;
165
- setScale(scale);
178
+ lastCenter = getCenter(touches);
179
+ setScale(scale, lastCenter);
166
180
  }
167
181
  }
168
182
  };
@@ -216,7 +230,7 @@ var stdin_default = defineComponent({
216
230
  }
217
231
  const maxZoom = +props.maxZoom;
218
232
  if (state.scale > maxZoom) {
219
- state.scale = maxZoom;
233
+ setScale(maxZoom, lastCenter);
220
234
  }
221
235
  }
222
236
  }
@@ -224,12 +238,30 @@ var stdin_default = defineComponent({
224
238
  checkTap();
225
239
  touch.reset();
226
240
  };
241
+ const resize = () => {
242
+ const {
243
+ rootWidth,
244
+ rootHeight
245
+ } = props;
246
+ const rootRatio = rootHeight / rootWidth;
247
+ const {
248
+ imageRatio
249
+ } = state;
250
+ vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
251
+ isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
252
+ if (isLongImage.value) {
253
+ initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
254
+ state.moveY = initialMoveY;
255
+ }
256
+ resetScale();
257
+ };
227
258
  const onLoad = (event) => {
228
259
  const {
229
260
  naturalWidth,
230
261
  naturalHeight
231
262
  } = event.target;
232
263
  state.imageRatio = naturalHeight / naturalWidth;
264
+ resize();
233
265
  };
234
266
  watch(() => props.active, resetScale);
235
267
  watch(() => props.show, (value) => {
@@ -237,6 +269,7 @@ var stdin_default = defineComponent({
237
269
  resetScale();
238
270
  }
239
271
  });
272
+ watch(() => [props.rootWidth, props.rootHeight], resize);
240
273
  useEventListener("touchmove", onTouchMove, {
241
274
  target: computed(() => {
242
275
  var _a;
@@ -261,6 +294,7 @@ var stdin_default = defineComponent({
261
294
  }, [slots.image({
262
295
  src: props.src
263
296
  })]) : _createVNode(Image, {
297
+ "ref": imageRef,
264
298
  "src": props.src,
265
299
  "fit": "contain",
266
300
  "class": bem("image", {
package/es/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from "./address-list";
7
7
  export * from "./area";
8
8
  export * from "./back-top";
9
9
  export * from "./badge";
10
+ export * from "./barrage";
10
11
  export * from "./button";
11
12
  export * from "./calendar";
12
13
  export * from "./card";
@@ -101,4 +102,4 @@ declare namespace _default {
101
102
  }
102
103
  export default _default;
103
104
  export function install(app: any): void;
104
- export const version: "4.3.1";
105
+ export const version: "4.4.0";
package/es/index.mjs CHANGED
@@ -7,6 +7,7 @@ import { AddressList } from "./address-list/index.mjs";
7
7
  import { Area } from "./area/index.mjs";
8
8
  import { BackTop } from "./back-top/index.mjs";
9
9
  import { Badge } from "./badge/index.mjs";
10
+ import { Barrage } from "./barrage/index.mjs";
10
11
  import { Button } from "./button/index.mjs";
11
12
  import { Calendar } from "./calendar/index.mjs";
12
13
  import { Card } from "./card/index.mjs";
@@ -94,7 +95,7 @@ import { Toast } from "./toast/index.mjs";
94
95
  import { TreeSelect } from "./tree-select/index.mjs";
95
96
  import { Uploader } from "./uploader/index.mjs";
96
97
  import { Watermark } from "./watermark/index.mjs";
97
- const version = "4.3.1";
98
+ const version = "4.4.0";
98
99
  function install(app) {
99
100
  const components = [
100
101
  ActionBar,
@@ -106,6 +107,7 @@ function install(app) {
106
107
  Area,
107
108
  BackTop,
108
109
  Badge,
110
+ Barrage,
109
111
  Button,
110
112
  Calendar,
111
113
  Card,
@@ -211,6 +213,7 @@ export * from "./address-list/index.mjs";
211
213
  export * from "./area/index.mjs";
212
214
  export * from "./back-top/index.mjs";
213
215
  export * from "./badge/index.mjs";
216
+ export * from "./barrage/index.mjs";
214
217
  export * from "./button/index.mjs";
215
218
  export * from "./calendar/index.mjs";
216
219
  export * from "./card/index.mjs";
@@ -64,8 +64,8 @@ declare const _default: import("vue").DefineComponent<{
64
64
  onReplay?: ((...args: any[]) => any) | undefined;
65
65
  }, {
66
66
  scrollable: boolean | null;
67
- speed: string | number;
68
67
  delay: string | number;
68
+ speed: string | number;
69
69
  wrapable: boolean;
70
70
  }>;
71
71
  export default _default;
@@ -42,8 +42,8 @@ export declare const NoticeBar: import("../utils").WithInstall<import("vue").Def
42
42
  onReplay?: ((...args: any[]) => any) | undefined;
43
43
  }, {
44
44
  scrollable: boolean | null;
45
- speed: string | number;
46
45
  delay: string | number;
46
+ speed: string | number;
47
47
  wrapable: boolean;
48
48
  }>>;
49
49
  export default NoticeBar;
@@ -6,6 +6,10 @@ export declare const pickerGroupProps: {
6
6
  type: import("vue").PropType<string[]>;
7
7
  default: () => never[];
8
8
  };
9
+ activeTab: {
10
+ type: (NumberConstructor | StringConstructor)[];
11
+ default: number;
12
+ };
9
13
  nextStepText: StringConstructor;
10
14
  } & {
11
15
  title: StringConstructor;
@@ -18,16 +22,24 @@ declare const _default: import("vue").DefineComponent<{
18
22
  type: import("vue").PropType<string[]>;
19
23
  default: () => never[];
20
24
  };
25
+ activeTab: {
26
+ type: (NumberConstructor | StringConstructor)[];
27
+ default: number;
28
+ };
21
29
  nextStepText: StringConstructor;
22
30
  } & {
23
31
  title: StringConstructor;
24
32
  cancelButtonText: StringConstructor;
25
33
  confirmButtonText: StringConstructor;
26
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "confirm")[], "cancel" | "confirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
34
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "confirm" | "update:activeTab")[], "cancel" | "confirm" | "update:activeTab", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
27
35
  tabs: {
28
36
  type: import("vue").PropType<string[]>;
29
37
  default: () => never[];
30
38
  };
39
+ activeTab: {
40
+ type: (NumberConstructor | StringConstructor)[];
41
+ default: number;
42
+ };
31
43
  nextStepText: StringConstructor;
32
44
  } & {
33
45
  title: StringConstructor;
@@ -36,7 +48,9 @@ declare const _default: import("vue").DefineComponent<{
36
48
  }>> & {
37
49
  onCancel?: ((...args: any[]) => any) | undefined;
38
50
  onConfirm?: ((...args: any[]) => any) | undefined;
51
+ "onUpdate:activeTab"?: ((...args: any[]) => any) | undefined;
39
52
  }, {
40
53
  tabs: string[];
54
+ activeTab: string | number;
41
55
  }>;
42
56
  export default _default;
@@ -1,7 +1,8 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
- import { ref, defineComponent } from "vue";
3
- import { extend, pick, makeArrayProp, createNamespace } from "../utils/index.mjs";
2
+ import { defineComponent } from "vue";
3
+ import { pick, extend, makeArrayProp, makeNumericProp, createNamespace } from "../utils/index.mjs";
4
4
  import { useChildren } from "@vant/use";
5
+ import { useSyncPropRef } from "../composables/use-sync-prop-ref.mjs";
5
6
  import { Tab } from "../tab/index.mjs";
6
7
  import { Tabs } from "../tabs/index.mjs";
7
8
  import Toolbar, { pickerToolbarProps, pickerToolbarSlots } from "../picker/PickerToolbar.mjs";
@@ -9,26 +10,27 @@ const [name, bem] = createNamespace("picker-group");
9
10
  const PICKER_GROUP_KEY = Symbol(name);
10
11
  const pickerGroupProps = extend({
11
12
  tabs: makeArrayProp(),
13
+ activeTab: makeNumericProp(0),
12
14
  nextStepText: String
13
15
  }, pickerToolbarProps);
14
16
  var stdin_default = defineComponent({
15
17
  name,
16
18
  props: pickerGroupProps,
17
- emits: ["confirm", "cancel"],
19
+ emits: ["confirm", "cancel", "update:activeTab"],
18
20
  setup(props, {
19
21
  emit,
20
22
  slots
21
23
  }) {
22
- const activeTab = ref(0);
24
+ const activeTab = useSyncPropRef(() => props.activeTab, (value) => emit("update:activeTab", value));
23
25
  const {
24
26
  children,
25
27
  linkChildren
26
28
  } = useChildren(PICKER_GROUP_KEY);
27
29
  linkChildren();
28
- const showNextButton = () => activeTab.value < props.tabs.length - 1 && props.nextStepText;
30
+ const showNextButton = () => +activeTab.value < props.tabs.length - 1 && props.nextStepText;
29
31
  const onConfirm = () => {
30
32
  if (showNextButton()) {
31
- activeTab.value++;
33
+ activeTab.value = +activeTab.value + 1;
32
34
  } else {
33
35
  emit("confirm", children.map((item) => item.confirm()));
34
36
  }
@@ -4,16 +4,24 @@ export declare const PickerGroup: import("../utils").WithInstall<import("vue").D
4
4
  type: import("vue").PropType<string[]>;
5
5
  default: () => never[];
6
6
  };
7
+ activeTab: {
8
+ type: (NumberConstructor | StringConstructor)[];
9
+ default: number;
10
+ };
7
11
  nextStepText: StringConstructor;
8
12
  } & {
9
13
  title: StringConstructor;
10
14
  cancelButtonText: StringConstructor;
11
15
  confirmButtonText: StringConstructor;
12
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "confirm")[], "cancel" | "confirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
16
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "confirm" | "update:activeTab")[], "cancel" | "confirm" | "update:activeTab", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
17
  tabs: {
14
18
  type: import("vue").PropType<string[]>;
15
19
  default: () => never[];
16
20
  };
21
+ activeTab: {
22
+ type: (NumberConstructor | StringConstructor)[];
23
+ default: number;
24
+ };
17
25
  nextStepText: StringConstructor;
18
26
  } & {
19
27
  title: StringConstructor;
@@ -22,8 +30,10 @@ export declare const PickerGroup: import("../utils").WithInstall<import("vue").D
22
30
  }>> & {
23
31
  onCancel?: ((...args: any[]) => any) | undefined;
24
32
  onConfirm?: ((...args: any[]) => any) | undefined;
33
+ "onUpdate:activeTab"?: ((...args: any[]) => any) | undefined;
25
34
  }, {
26
35
  tabs: string[];
36
+ activeTab: string | number;
27
37
  }>>;
28
38
  export default PickerGroup;
29
39
  export { pickerGroupProps } from './PickerGroup';
@@ -14,6 +14,10 @@ export declare const signatureProps: {
14
14
  default: number;
15
15
  };
16
16
  clearButtonText: StringConstructor;
17
+ backgroundColor: {
18
+ type: import("vue").PropType<string>;
19
+ default: string;
20
+ };
17
21
  confirmButtonText: StringConstructor;
18
22
  };
19
23
  export type SignatureProps = ExtractPropTypes<typeof signatureProps>;
@@ -32,6 +36,10 @@ declare const _default: import("vue").DefineComponent<{
32
36
  default: number;
33
37
  };
34
38
  clearButtonText: StringConstructor;
39
+ backgroundColor: {
40
+ type: import("vue").PropType<string>;
41
+ default: string;
42
+ };
35
43
  confirmButtonText: StringConstructor;
36
44
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("submit" | "start" | "clear" | "end" | "signing")[], "submit" | "start" | "clear" | "end" | "signing", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
37
45
  tips: StringConstructor;
@@ -48,6 +56,10 @@ declare const _default: import("vue").DefineComponent<{
48
56
  default: number;
49
57
  };
50
58
  clearButtonText: StringConstructor;
59
+ backgroundColor: {
60
+ type: import("vue").PropType<string>;
61
+ default: string;
62
+ };
51
63
  confirmButtonText: StringConstructor;
52
64
  }>> & {
53
65
  onSubmit?: ((...args: any[]) => any) | undefined;
@@ -57,6 +69,7 @@ declare const _default: import("vue").DefineComponent<{
57
69
  onSigning?: ((...args: any[]) => any) | undefined;
58
70
  }, {
59
71
  type: string;
72
+ backgroundColor: string;
60
73
  lineWidth: number;
61
74
  penColor: string;
62
75
  }>;
@@ -1,5 +1,5 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
- import { ref, reactive, onMounted, defineComponent } from "vue";
2
+ import { ref, reactive, onMounted, nextTick, defineComponent } from "vue";
3
3
  import { inBrowser, makeNumberProp, makeStringProp, createNamespace, preventDefault } from "../utils/index.mjs";
4
4
  import { useRect } from "@vant/use";
5
5
  import { Button } from "../button/index.mjs";
@@ -10,6 +10,7 @@ const signatureProps = {
10
10
  penColor: makeStringProp("#000"),
11
11
  lineWidth: makeNumberProp(3),
12
12
  clearButtonText: String,
13
+ backgroundColor: makeStringProp(""),
13
14
  confirmButtonText: String
14
15
  };
15
16
  const hasCanvasSupport = () => {
@@ -29,7 +30,8 @@ var stdin_default = defineComponent({
29
30
  const state = reactive({
30
31
  width: 0,
31
32
  height: 0,
32
- ctx: null
33
+ ctx: null,
34
+ ratio: inBrowser ? window.devicePixelRatio : 1
33
35
  });
34
36
  let canvasRect;
35
37
  const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
@@ -38,7 +40,7 @@ var stdin_default = defineComponent({
38
40
  return false;
39
41
  }
40
42
  state.ctx.beginPath();
41
- state.ctx.lineWidth = props.lineWidth;
43
+ state.ctx.lineWidth = props.lineWidth * state.ratio;
42
44
  state.ctx.strokeStyle = props.penColor;
43
45
  canvasRect = useRect(canvasRef);
44
46
  emit("start");
@@ -50,8 +52,8 @@ var stdin_default = defineComponent({
50
52
  }
51
53
  preventDefault(event);
52
54
  const touch = event.touches[0];
53
- const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
54
- const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
55
+ const mouseX = (touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0)) * state.ratio;
56
+ const mouseY = (touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0)) * state.ratio;
55
57
  state.ctx.lineCap = "round";
56
58
  state.ctx.lineJoin = "round";
57
59
  (_a = state.ctx) == null ? void 0 : _a.lineTo(mouseX, mouseY);
@@ -68,13 +70,23 @@ var stdin_default = defineComponent({
68
70
  empty.height = canvas.height;
69
71
  return canvas.toDataURL() === empty.toDataURL();
70
72
  };
73
+ const setCanvasBgColor = () => {
74
+ if (state.ctx && props.backgroundColor) {
75
+ state.ctx.fillStyle = props.backgroundColor;
76
+ state.ctx.fillRect(0, 0, state.width, state.height);
77
+ }
78
+ };
71
79
  const submit = () => {
80
+ var _a, _b;
72
81
  const canvas = canvasRef.value;
73
82
  if (!canvas) {
74
83
  return;
75
84
  }
76
85
  const isEmpty = isCanvasEmpty(canvas);
77
- const image = isEmpty ? "" : canvas.toDataURL(`image/${props.type}`, props.type === "jpg" ? 0.9 : null);
86
+ const image = isEmpty ? "" : ((_b = (_a = {
87
+ jpg: () => canvas.toDataURL("image/jpeg", 0.8),
88
+ jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
89
+ })[props.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props.type}`);
78
90
  emit("submit", {
79
91
  image,
80
92
  canvas
@@ -84,6 +96,7 @@ var stdin_default = defineComponent({
84
96
  if (state.ctx) {
85
97
  state.ctx.clearRect(0, 0, state.width, state.height);
86
98
  state.ctx.closePath();
99
+ setCanvasBgColor();
87
100
  }
88
101
  emit("clear");
89
102
  };
@@ -91,8 +104,11 @@ var stdin_default = defineComponent({
91
104
  var _a, _b, _c;
92
105
  if (isRenderCanvas) {
93
106
  state.ctx = (_a = canvasRef.value) == null ? void 0 : _a.getContext("2d");
94
- state.width = ((_b = wrapRef.value) == null ? void 0 : _b.offsetWidth) || 0;
95
- state.height = ((_c = wrapRef.value) == null ? void 0 : _c.offsetHeight) || 0;
107
+ state.width = (((_b = wrapRef.value) == null ? void 0 : _b.offsetWidth) || 0) * state.ratio;
108
+ state.height = (((_c = wrapRef.value) == null ? void 0 : _c.offsetHeight) || 0) * state.ratio;
109
+ nextTick(() => {
110
+ setCanvasBgColor();
111
+ });
96
112
  }
97
113
  });
98
114
  return () => _createVNode("div", {
@@ -1 +1 @@
1
- :root{--van-signature-padding: var(--van-padding-xs);--van-signature-content-height: 200px;--van-signature-content-background: var(--van-background-2);--van-signature-content-border: 1px dotted #dadada}.van-signature{padding:var(--van-signature-padding)}.van-signature__content{display:flex;justify-content:center;align-items:center;height:var(--van-signature-content-height);background-color:var(--van-signature-content-background);border:var(--van-signature-content-border);border-radius:var(--van-radius-lg);overflow:hidden}.van-signature__footer{display:flex;justify-content:flex-end}.van-signature__footer .van-button{padding:0 var(--van-padding-md);margin-top:var(--van-padding-xs);margin-left:var(--van-padding-xs)}
1
+ :root{--van-signature-padding: var(--van-padding-xs);--van-signature-content-height: 200px;--van-signature-content-background: var(--van-background-2);--van-signature-content-border: 1px dotted #dadada}.van-signature{padding:var(--van-signature-padding)}.van-signature__content{display:flex;justify-content:center;align-items:center;height:var(--van-signature-content-height);background-color:var(--van-signature-content-background);border:var(--van-signature-content-border);border-radius:var(--van-radius-lg);overflow:hidden}.van-signature__content canvas{width:100%;height:100%}.van-signature__footer{display:flex;justify-content:flex-end}.van-signature__footer .van-button{padding:0 var(--van-padding-md);margin-top:var(--van-padding-xs);margin-left:var(--van-padding-xs)}