vant 4.4.1 → 4.6.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 (161) hide show
  1. package/es/address-list/AddressList.d.ts +13 -0
  2. package/es/address-list/AddressList.mjs +4 -2
  3. package/es/address-list/AddressListItem.d.ts +9 -0
  4. package/es/address-list/AddressListItem.mjs +4 -3
  5. package/es/address-list/index.d.ts +9 -0
  6. package/es/back-top/BackTop.mjs +14 -1
  7. package/es/barrage/index.d.ts +1 -1
  8. package/es/barrage/types.d.ts +6 -0
  9. package/es/composables/use-touch.d.ts +1 -0
  10. package/es/composables/use-touch.mjs +8 -1
  11. package/es/config-provider/types.d.ts +1 -1
  12. package/es/date-picker/DatePicker.d.ts +3 -3
  13. package/es/date-picker/index.d.ts +2 -2
  14. package/es/date-picker/utils.d.ts +4 -2
  15. package/es/date-picker/utils.mjs +8 -3
  16. package/es/dropdown-menu/DropdownMenu.mjs +10 -3
  17. package/es/dropdown-menu/index.d.ts +1 -1
  18. package/es/dropdown-menu/types.d.ts +5 -1
  19. package/es/field/Field.mjs +1 -1
  20. package/es/floating-bubble/FloatingBubble.d.ts +86 -0
  21. package/es/floating-bubble/FloatingBubble.mjs +177 -0
  22. package/es/floating-bubble/index.css +1 -0
  23. package/es/floating-bubble/index.d.ts +63 -0
  24. package/es/floating-bubble/index.mjs +10 -0
  25. package/es/floating-bubble/style/index.d.ts +1 -0
  26. package/es/floating-bubble/style/index.mjs +4 -0
  27. package/es/floating-bubble/types.d.ts +8 -0
  28. package/es/floating-bubble/types.mjs +0 -0
  29. package/es/floating-panel/FloatingPanel.d.ts +77 -0
  30. package/es/floating-panel/FloatingPanel.mjs +127 -0
  31. package/es/floating-panel/index.css +1 -0
  32. package/es/floating-panel/index.d.ts +61 -0
  33. package/es/floating-panel/index.mjs +10 -0
  34. package/es/floating-panel/style/index.d.ts +1 -0
  35. package/es/floating-panel/style/index.mjs +2 -0
  36. package/es/floating-panel/types.d.ts +9 -0
  37. package/es/floating-panel/types.mjs +0 -0
  38. package/es/image-preview/ImagePreviewItem.mjs +1 -2
  39. package/es/index.d.ts +4 -1
  40. package/es/index.mjs +10 -1
  41. package/es/picker/PickerColumn.mjs +7 -2
  42. package/es/rate/Rate.d.ts +4 -0
  43. package/es/rate/Rate.mjs +16 -10
  44. package/es/rate/index.css +1 -1
  45. package/es/rate/index.d.ts +3 -0
  46. package/es/rolling-text/RollingText.d.ts +104 -0
  47. package/es/rolling-text/RollingText.mjs +98 -0
  48. package/es/rolling-text/RollingTextItem.d.ts +67 -0
  49. package/es/rolling-text/RollingTextItem.mjs +47 -0
  50. package/es/rolling-text/index.css +1 -0
  51. package/es/rolling-text/index.d.ts +79 -0
  52. package/es/rolling-text/index.mjs +10 -0
  53. package/es/rolling-text/style/index.d.ts +1 -0
  54. package/es/rolling-text/style/index.mjs +2 -0
  55. package/es/rolling-text/types.d.ts +17 -0
  56. package/es/rolling-text/types.mjs +0 -0
  57. package/es/signature/index.d.ts +1 -0
  58. package/es/signature/types.d.ts +6 -0
  59. package/es/signature/types.mjs +0 -0
  60. package/es/slider/Slider.d.ts +1 -1
  61. package/es/slider/Slider.mjs +10 -2
  62. package/es/slider/index.d.ts +1 -1
  63. package/es/stepper/Stepper.d.ts +1 -1
  64. package/es/stepper/index.d.ts +1 -1
  65. package/es/time-picker/TimePicker.d.ts +31 -4
  66. package/es/time-picker/TimePicker.mjs +73 -21
  67. package/es/time-picker/index.d.ts +20 -2
  68. package/es/utils/basic.d.ts +3 -0
  69. package/es/utils/closest.d.ts +1 -0
  70. package/es/utils/closest.mjs +8 -0
  71. package/es/utils/constant.d.ts +1 -0
  72. package/es/utils/constant.mjs +3 -1
  73. package/es/utils/index.d.ts +1 -0
  74. package/es/utils/index.mjs +1 -0
  75. package/es/watermark/index.d.ts +1 -0
  76. package/es/watermark/types.d.ts +3 -0
  77. package/es/watermark/types.mjs +0 -0
  78. package/lib/address-list/AddressList.d.ts +13 -0
  79. package/lib/address-list/AddressList.js +3 -1
  80. package/lib/address-list/AddressListItem.d.ts +9 -0
  81. package/lib/address-list/AddressListItem.js +3 -2
  82. package/lib/address-list/index.d.ts +9 -0
  83. package/lib/back-top/BackTop.js +13 -0
  84. package/lib/barrage/index.d.ts +1 -1
  85. package/lib/barrage/types.d.ts +6 -0
  86. package/lib/composables/use-touch.d.ts +1 -0
  87. package/lib/composables/use-touch.js +8 -1
  88. package/lib/config-provider/types.d.ts +1 -1
  89. package/lib/date-picker/DatePicker.d.ts +3 -3
  90. package/lib/date-picker/index.d.ts +2 -2
  91. package/lib/date-picker/utils.d.ts +4 -2
  92. package/lib/date-picker/utils.js +2 -2
  93. package/lib/dropdown-menu/DropdownMenu.js +10 -3
  94. package/lib/dropdown-menu/index.d.ts +1 -1
  95. package/lib/dropdown-menu/types.d.ts +5 -1
  96. package/lib/field/Field.js +1 -1
  97. package/lib/floating-bubble/FloatingBubble.d.ts +86 -0
  98. package/lib/floating-bubble/FloatingBubble.js +206 -0
  99. package/lib/floating-bubble/index.css +1 -0
  100. package/lib/floating-bubble/index.d.ts +63 -0
  101. package/lib/floating-bubble/index.js +39 -0
  102. package/lib/floating-bubble/style/index.d.ts +1 -0
  103. package/lib/floating-bubble/style/index.js +4 -0
  104. package/lib/floating-bubble/types.d.ts +8 -0
  105. package/lib/floating-bubble/types.js +15 -0
  106. package/lib/floating-panel/FloatingPanel.d.ts +77 -0
  107. package/lib/floating-panel/FloatingPanel.js +146 -0
  108. package/lib/floating-panel/index.css +1 -0
  109. package/lib/floating-panel/index.d.ts +61 -0
  110. package/lib/floating-panel/index.js +39 -0
  111. package/lib/floating-panel/style/index.d.ts +1 -0
  112. package/lib/floating-panel/style/index.js +2 -0
  113. package/lib/floating-panel/types.d.ts +9 -0
  114. package/lib/floating-panel/types.js +15 -0
  115. package/lib/image-preview/ImagePreviewItem.js +1 -2
  116. package/lib/index.css +1 -1
  117. package/lib/index.d.ts +4 -1
  118. package/lib/index.js +10 -1
  119. package/lib/picker/PickerColumn.js +7 -2
  120. package/lib/rate/Rate.d.ts +4 -0
  121. package/lib/rate/Rate.js +16 -10
  122. package/lib/rate/index.css +1 -1
  123. package/lib/rate/index.d.ts +3 -0
  124. package/lib/rolling-text/RollingText.d.ts +104 -0
  125. package/lib/rolling-text/RollingText.js +127 -0
  126. package/lib/rolling-text/RollingTextItem.d.ts +67 -0
  127. package/lib/rolling-text/RollingTextItem.js +66 -0
  128. package/lib/rolling-text/index.css +1 -0
  129. package/lib/rolling-text/index.d.ts +79 -0
  130. package/lib/rolling-text/index.js +39 -0
  131. package/lib/rolling-text/style/index.d.ts +1 -0
  132. package/lib/rolling-text/style/index.js +2 -0
  133. package/lib/rolling-text/types.d.ts +17 -0
  134. package/lib/rolling-text/types.js +15 -0
  135. package/lib/signature/index.d.ts +1 -0
  136. package/lib/signature/types.d.ts +6 -0
  137. package/lib/signature/types.js +15 -0
  138. package/lib/slider/Slider.d.ts +1 -1
  139. package/lib/slider/Slider.js +10 -2
  140. package/lib/slider/index.d.ts +1 -1
  141. package/lib/stepper/Stepper.d.ts +1 -1
  142. package/lib/stepper/index.d.ts +1 -1
  143. package/lib/time-picker/TimePicker.d.ts +31 -4
  144. package/lib/time-picker/TimePicker.js +84 -32
  145. package/lib/time-picker/index.d.ts +20 -2
  146. package/lib/utils/basic.d.ts +3 -0
  147. package/lib/utils/closest.d.ts +1 -0
  148. package/lib/utils/closest.js +27 -0
  149. package/lib/utils/constant.d.ts +1 -0
  150. package/lib/utils/constant.js +3 -1
  151. package/lib/utils/index.d.ts +1 -0
  152. package/lib/utils/index.js +1 -0
  153. package/lib/vant.cjs.js +2547 -2019
  154. package/lib/vant.es.js +2547 -2019
  155. package/lib/vant.js +2544 -2016
  156. package/lib/vant.min.js +1 -1
  157. package/lib/watermark/index.d.ts +1 -0
  158. package/lib/watermark/types.d.ts +3 -0
  159. package/lib/watermark/types.js +15 -0
  160. package/lib/web-types.json +1 -1
  161. package/package.json +1 -1
@@ -0,0 +1,177 @@
1
+ import { withDirectives as _withDirectives, vShow as _vShow, createVNode as _createVNode } from "vue";
2
+ import { Teleport, computed, defineComponent, nextTick, onMounted, ref, watch, onActivated, onDeactivated } from "vue";
3
+ import { useRect, useEventListener } from "@vant/use";
4
+ import { useTouch } from "../composables/use-touch.mjs";
5
+ import { addUnit, closest, createNamespace, makeNumberProp, makeStringProp, pick, windowWidth, windowHeight } from "../utils/index.mjs";
6
+ import Icon from "../icon/index.mjs";
7
+ const floatingBubbleProps = {
8
+ axis: makeStringProp("y"),
9
+ magnetic: String,
10
+ icon: String,
11
+ gap: makeNumberProp(24),
12
+ offset: {
13
+ type: Object,
14
+ default: () => ({
15
+ x: -1,
16
+ y: -1
17
+ })
18
+ },
19
+ teleport: {
20
+ type: [String, Object],
21
+ default: "body"
22
+ }
23
+ };
24
+ const [name, bem] = createNamespace("floating-bubble");
25
+ var stdin_default = defineComponent({
26
+ name,
27
+ props: floatingBubbleProps,
28
+ emits: ["click", "update:offset", "offsetChange"],
29
+ setup(props, {
30
+ slots,
31
+ emit
32
+ }) {
33
+ const rootRef = ref();
34
+ const state = ref({
35
+ x: 0,
36
+ y: 0,
37
+ width: 0,
38
+ height: 0
39
+ });
40
+ const boundary = computed(() => ({
41
+ top: props.gap,
42
+ right: windowWidth.value - state.value.height - props.gap,
43
+ bottom: windowHeight.value - state.value.width - props.gap,
44
+ left: props.gap
45
+ }));
46
+ const dragging = ref(false);
47
+ let initialized = false;
48
+ const rootStyle = computed(() => {
49
+ const style = {};
50
+ const x = addUnit(state.value.x);
51
+ const y = addUnit(state.value.y);
52
+ style.transform = `translate3d(${x}, ${y}, 0)`;
53
+ if (dragging.value || !initialized) {
54
+ style.transition = "none";
55
+ }
56
+ return style;
57
+ });
58
+ const updateState = () => {
59
+ const {
60
+ width,
61
+ height
62
+ } = useRect(rootRef.value);
63
+ const {
64
+ offset
65
+ } = props;
66
+ state.value = {
67
+ x: offset.x > -1 ? offset.x : windowWidth.value - width - props.gap,
68
+ y: offset.y > -1 ? offset.y : windowHeight.value - height - props.gap,
69
+ width,
70
+ height
71
+ };
72
+ };
73
+ const touch = useTouch();
74
+ let prevX = 0;
75
+ let prevY = 0;
76
+ const onTouchStart = (e) => {
77
+ touch.start(e);
78
+ dragging.value = true;
79
+ prevX = state.value.x;
80
+ prevY = state.value.y;
81
+ };
82
+ const onTouchMove = (e) => {
83
+ e.preventDefault();
84
+ touch.move(e);
85
+ if (props.axis === "lock")
86
+ return;
87
+ if (!touch.isTap.value) {
88
+ if (props.axis === "x" || props.axis === "xy") {
89
+ let nextX = prevX + touch.deltaX.value;
90
+ if (nextX < boundary.value.left)
91
+ nextX = boundary.value.left;
92
+ if (nextX > boundary.value.right)
93
+ nextX = boundary.value.right;
94
+ state.value.x = nextX;
95
+ }
96
+ if (props.axis === "y" || props.axis === "xy") {
97
+ let nextY = prevY + touch.deltaY.value;
98
+ if (nextY < boundary.value.top)
99
+ nextY = boundary.value.top;
100
+ if (nextY > boundary.value.bottom)
101
+ nextY = boundary.value.bottom;
102
+ state.value.y = nextY;
103
+ }
104
+ const offset = pick(state.value, ["x", "y"]);
105
+ emit("update:offset", offset);
106
+ }
107
+ };
108
+ useEventListener("touchmove", onTouchMove, {
109
+ target: rootRef
110
+ });
111
+ const onTouchEnd = () => {
112
+ dragging.value = false;
113
+ nextTick(() => {
114
+ if (props.magnetic === "x") {
115
+ const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
116
+ state.value.x = nextX;
117
+ }
118
+ if (props.magnetic === "y") {
119
+ const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
120
+ state.value.y = nextY;
121
+ }
122
+ if (!touch.isTap.value) {
123
+ const offset = pick(state.value, ["x", "y"]);
124
+ emit("update:offset", offset);
125
+ if (prevX !== offset.x || prevY !== offset.y) {
126
+ emit("offsetChange", offset);
127
+ }
128
+ }
129
+ });
130
+ };
131
+ const onClick = (e) => {
132
+ if (touch.isTap.value)
133
+ emit("click", e);
134
+ };
135
+ onMounted(() => {
136
+ updateState();
137
+ nextTick(() => {
138
+ initialized = true;
139
+ });
140
+ });
141
+ watch([windowWidth, windowHeight, () => props.gap, () => props.offset], () => updateState(), {
142
+ deep: true
143
+ });
144
+ const show = ref(true);
145
+ onActivated(() => {
146
+ show.value = true;
147
+ });
148
+ onDeactivated(() => {
149
+ if (props.teleport) {
150
+ show.value = false;
151
+ }
152
+ });
153
+ return () => {
154
+ const Content = _withDirectives(_createVNode("div", {
155
+ "class": bem(),
156
+ "ref": rootRef,
157
+ "onTouchstartPassive": onTouchStart,
158
+ "onTouchend": onTouchEnd,
159
+ "onTouchcancel": onTouchEnd,
160
+ "onClick": onClick,
161
+ "style": rootStyle.value
162
+ }, [slots.default ? slots.default() : _createVNode(Icon, {
163
+ "name": props.icon,
164
+ "class": bem("icon")
165
+ }, null)]), [[_vShow, show.value]]);
166
+ return props.teleport ? _createVNode(Teleport, {
167
+ "to": props.teleport
168
+ }, {
169
+ default: () => [Content]
170
+ }) : Content;
171
+ };
172
+ }
173
+ });
174
+ export {
175
+ stdin_default as default,
176
+ floatingBubbleProps
177
+ };
@@ -0,0 +1 @@
1
+ :root{--van-floating-bubble-size: 48px;--van-floating-bubble-initial-gap: 24px;--van-floating-bubble-icon-size: 28px;--van-floating-bubble-background: var(--van-primary-color);--van-floating-bubble-color: var(--van-background-2);--van-floating-bubble-z-index: 999}.van-floating-bubble{position:fixed;left:0;top:0;right:var(--van-floating-bubble-initial-gap);bottom:var(--van-floating-bubble-initial-gap);width:var(--van-floating-bubble-size);height:var(--van-floating-bubble-size);box-sizing:border-box;display:flex;justify-content:center;align-items:center;overflow:hidden;cursor:pointer;-webkit-user-select:none;user-select:none;touch-action:none;background:var(--van-floating-bubble-background);color:var(--van-floating-bubble-color);border-radius:var(--van-radius-max);z-index:var(--van-floating-bubble-z-index);transition:transform .3s}.van-floating-bubble:active{opacity:.9}.van-floating-bubble__icon{font-size:var(--van-floating-bubble-icon-size)}
@@ -0,0 +1,63 @@
1
+ export declare const FloatingBubble: import("../utils").WithInstall<import("vue").DefineComponent<{
2
+ axis: {
3
+ type: import("vue").PropType<import("./FloatingBubble").FloatingBubbleAxis>;
4
+ default: import("./FloatingBubble").FloatingBubbleAxis;
5
+ };
6
+ magnetic: import("vue").PropType<import("./FloatingBubble").FloatingBubbleMagnetic>;
7
+ icon: StringConstructor;
8
+ gap: {
9
+ type: NumberConstructor;
10
+ default: number;
11
+ };
12
+ offset: {
13
+ type: import("vue").PropType<import("./FloatingBubble").FloatingBubbleOffset>;
14
+ default: () => {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ };
19
+ teleport: {
20
+ type: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
21
+ default: string;
22
+ };
23
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "update:offset" | "offsetChange")[], "click" | "update:offset" | "offsetChange", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
24
+ axis: {
25
+ type: import("vue").PropType<import("./FloatingBubble").FloatingBubbleAxis>;
26
+ default: import("./FloatingBubble").FloatingBubbleAxis;
27
+ };
28
+ magnetic: import("vue").PropType<import("./FloatingBubble").FloatingBubbleMagnetic>;
29
+ icon: StringConstructor;
30
+ gap: {
31
+ type: NumberConstructor;
32
+ default: number;
33
+ };
34
+ offset: {
35
+ type: import("vue").PropType<import("./FloatingBubble").FloatingBubbleOffset>;
36
+ default: () => {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ };
41
+ teleport: {
42
+ type: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
43
+ default: string;
44
+ };
45
+ }>> & {
46
+ onClick?: ((...args: any[]) => any) | undefined;
47
+ "onUpdate:offset"?: ((...args: any[]) => any) | undefined;
48
+ onOffsetChange?: ((...args: any[]) => any) | undefined;
49
+ }, {
50
+ offset: import("./FloatingBubble").FloatingBubbleOffset;
51
+ teleport: string | import("vue").RendererElement | null | undefined;
52
+ gap: number;
53
+ axis: import("./FloatingBubble").FloatingBubbleAxis;
54
+ }, {}>>;
55
+ export default FloatingBubble;
56
+ export { floatingBubbleProps } from './FloatingBubble';
57
+ export type { FloatingBubbleProps, FloatingBubbleAxis, FloatingBubbleMagnetic, FloatingBubbleOffset, } from './FloatingBubble';
58
+ export type { FloatingBubbleThemeVars } from './types';
59
+ declare module 'vue' {
60
+ interface GlobalComponents {
61
+ FloatingBubble: typeof FloatingBubble;
62
+ }
63
+ }
@@ -0,0 +1,10 @@
1
+ import { withInstall } from "../utils/index.mjs";
2
+ import _FloatingBubble from "./FloatingBubble.mjs";
3
+ const FloatingBubble = withInstall(_FloatingBubble);
4
+ var stdin_default = FloatingBubble;
5
+ import { floatingBubbleProps } from "./FloatingBubble.mjs";
6
+ export {
7
+ FloatingBubble,
8
+ stdin_default as default,
9
+ floatingBubbleProps
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import "../../style/base.css";
2
+ import "../../badge/index.css";
3
+ import "../../icon/index.css";
4
+ import "../index.css";
@@ -0,0 +1,8 @@
1
+ export type FloatingBubbleThemeVars = {
2
+ floatingBubbleSize?: string;
3
+ floatingBubbleInitialGap?: string;
4
+ floatingBubbleIconSize?: string;
5
+ floatingBubbleBackground: string;
6
+ floatingBubbleColor?: string;
7
+ floatingBubbleZIndex?: number | string;
8
+ };
File without changes
@@ -0,0 +1,77 @@
1
+ import { type ExtractPropTypes } from 'vue';
2
+ export declare const floatingPanelProps: {
3
+ height: {
4
+ type: (NumberConstructor | StringConstructor)[];
5
+ default: number;
6
+ };
7
+ anchors: {
8
+ type: import("vue").PropType<number[]>;
9
+ default: () => never[];
10
+ };
11
+ duration: {
12
+ type: (NumberConstructor | StringConstructor)[];
13
+ default: number;
14
+ };
15
+ contentDraggable: {
16
+ type: BooleanConstructor;
17
+ default: true;
18
+ };
19
+ safeAreaInsetBottom: {
20
+ type: BooleanConstructor;
21
+ default: true;
22
+ };
23
+ };
24
+ export type FloatingPanelProps = ExtractPropTypes<typeof floatingPanelProps>;
25
+ declare const _default: import("vue").DefineComponent<{
26
+ height: {
27
+ type: (NumberConstructor | StringConstructor)[];
28
+ default: number;
29
+ };
30
+ anchors: {
31
+ type: import("vue").PropType<number[]>;
32
+ default: () => never[];
33
+ };
34
+ duration: {
35
+ type: (NumberConstructor | StringConstructor)[];
36
+ default: number;
37
+ };
38
+ contentDraggable: {
39
+ type: BooleanConstructor;
40
+ default: true;
41
+ };
42
+ safeAreaInsetBottom: {
43
+ type: BooleanConstructor;
44
+ default: true;
45
+ };
46
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("heightChange" | "update:height")[], "heightChange" | "update:height", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
47
+ height: {
48
+ type: (NumberConstructor | StringConstructor)[];
49
+ default: number;
50
+ };
51
+ anchors: {
52
+ type: import("vue").PropType<number[]>;
53
+ default: () => never[];
54
+ };
55
+ duration: {
56
+ type: (NumberConstructor | StringConstructor)[];
57
+ default: number;
58
+ };
59
+ contentDraggable: {
60
+ type: BooleanConstructor;
61
+ default: true;
62
+ };
63
+ safeAreaInsetBottom: {
64
+ type: BooleanConstructor;
65
+ default: true;
66
+ };
67
+ }>> & {
68
+ onHeightChange?: ((...args: any[]) => any) | undefined;
69
+ "onUpdate:height"?: ((...args: any[]) => any) | undefined;
70
+ }, {
71
+ height: string | number;
72
+ safeAreaInsetBottom: boolean;
73
+ duration: string | number;
74
+ anchors: number[];
75
+ contentDraggable: boolean;
76
+ }, {}>;
77
+ export default _default;
@@ -0,0 +1,127 @@
1
+ import { createVNode as _createVNode } from "vue";
2
+ import { computed, defineComponent, ref, watch } from "vue";
3
+ import { addUnit, closest, createNamespace, makeArrayProp, makeNumericProp, truthProp } from "../utils/index.mjs";
4
+ import { useWindowSize, useEventListener } from "@vant/use";
5
+ import { useLockScroll } from "../composables/use-lock-scroll.mjs";
6
+ import { useTouch } from "../composables/use-touch.mjs";
7
+ import { useSyncPropRef } from "../composables/use-sync-prop-ref.mjs";
8
+ const {
9
+ height: windowHeight
10
+ } = useWindowSize();
11
+ const floatingPanelProps = {
12
+ height: makeNumericProp(0),
13
+ anchors: makeArrayProp(),
14
+ duration: makeNumericProp(0.2),
15
+ contentDraggable: truthProp,
16
+ safeAreaInsetBottom: truthProp
17
+ };
18
+ const [name, bem] = createNamespace("floating-panel");
19
+ const DAMP = 0.2;
20
+ var stdin_default = defineComponent({
21
+ name,
22
+ props: floatingPanelProps,
23
+ emits: ["heightChange", "update:height"],
24
+ setup(props, {
25
+ emit,
26
+ slots
27
+ }) {
28
+ const rootRef = ref();
29
+ const contentRef = ref();
30
+ const height = useSyncPropRef(() => +props.height, (value) => emit("update:height", value));
31
+ const boundary = computed(() => {
32
+ var _a, _b;
33
+ return {
34
+ min: (_a = props.anchors[0]) != null ? _a : 100,
35
+ max: (_b = props.anchors[props.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
36
+ };
37
+ });
38
+ const anchors = computed(() => props.anchors.length >= 2 ? props.anchors : [boundary.value.min, boundary.value.max]);
39
+ const dragging = ref(false);
40
+ const rootStyle = computed(() => ({
41
+ height: addUnit(boundary.value.max),
42
+ transform: `translateY(calc(100% + ${addUnit(-height.value)}))`,
43
+ transition: !dragging.value ? `transform ${props.duration}s` : "none"
44
+ }));
45
+ const ease = (moveY) => {
46
+ const absDistance = Math.abs(moveY);
47
+ const {
48
+ min,
49
+ max
50
+ } = boundary.value;
51
+ if (absDistance > max) {
52
+ return -(max + (absDistance - max) * DAMP);
53
+ }
54
+ if (absDistance < min) {
55
+ return -(min - (min - absDistance) * DAMP);
56
+ }
57
+ return moveY;
58
+ };
59
+ let startY;
60
+ const touch = useTouch();
61
+ const onTouchstart = (e) => {
62
+ touch.start(e);
63
+ dragging.value = true;
64
+ startY = -height.value;
65
+ };
66
+ const onTouchmove = (e) => {
67
+ var _a;
68
+ touch.move(e);
69
+ const target = e.target;
70
+ if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
71
+ if (!props.contentDraggable)
72
+ return;
73
+ if (-startY < boundary.value.max) {
74
+ if (e.cancelable)
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ } else if (!(contentRef.value.scrollTop <= 0 && touch.deltaY.value > 0)) {
78
+ return;
79
+ }
80
+ }
81
+ const moveY = touch.deltaY.value + startY;
82
+ height.value = -ease(moveY);
83
+ };
84
+ const onTouchend = () => {
85
+ dragging.value = false;
86
+ height.value = closest(anchors.value, height.value);
87
+ if (height.value !== -startY) {
88
+ emit("heightChange", {
89
+ height: height.value
90
+ });
91
+ }
92
+ };
93
+ watch(boundary, () => {
94
+ height.value = closest(anchors.value, height.value);
95
+ }, {
96
+ immediate: true
97
+ });
98
+ useLockScroll(rootRef, () => true);
99
+ useEventListener("touchmove", onTouchmove, {
100
+ target: rootRef
101
+ });
102
+ return () => {
103
+ var _a;
104
+ return _createVNode("div", {
105
+ "class": [bem(), {
106
+ "van-safe-area-bottom": props.safeAreaInsetBottom
107
+ }],
108
+ "ref": rootRef,
109
+ "style": rootStyle.value,
110
+ "onTouchstartPassive": onTouchstart,
111
+ "onTouchend": onTouchend,
112
+ "onTouchcancel": onTouchend
113
+ }, [_createVNode("div", {
114
+ "class": bem("header")
115
+ }, [_createVNode("div", {
116
+ "class": bem("header-bar")
117
+ }, null)]), _createVNode("div", {
118
+ "class": bem("content"),
119
+ "ref": contentRef
120
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
121
+ };
122
+ }
123
+ });
124
+ export {
125
+ stdin_default as default,
126
+ floatingPanelProps
127
+ };
@@ -0,0 +1 @@
1
+ :root{--van-floating-panel-border-radius: 16px;--van-floating-panel-header-height: 30px;--van-floating-panel-z-index: 999;--van-floating-panel-background: var(--van-background-2);--van-floating-panel-bar-width: 20px;--van-floating-panel-bar-height: 3px;--van-floating-panel-bar-color: var(--van-gray-5)}.van-floating-panel{position:fixed;left:0;bottom:0;width:100vw;z-index:var(--van-floating-panel-z-index);display:flex;flex-direction:column;touch-action:none;border-top-left-radius:var(--van-floating-panel-border-radius);border-top-right-radius:var(--van-floating-panel-border-radius);background:var(--van-floating-panel-background)}.van-floating-panel:after{content:"";display:block;position:absolute;bottom:-100vh;height:100vh;width:100vw;background-color:inherit}.van-floating-panel__header{height:var(--van-floating-panel-header-height);display:flex;justify-content:center;align-items:center;cursor:-webkit-grab;cursor:grab;-webkit-user-select:none;user-select:none}.van-floating-panel__header-bar{height:var(--van-floating-panel-bar-height);width:var(--van-floating-panel-bar-width);border-radius:var(--van-radius-md);background:var(--van-floating-panel-bar-color)}.van-floating-panel__content{flex:1;overflow-y:auto;background-color:var(--van-floating-panel-background)}
@@ -0,0 +1,61 @@
1
+ export declare const FloatingPanel: import("../utils").WithInstall<import("vue").DefineComponent<{
2
+ height: {
3
+ type: (NumberConstructor | StringConstructor)[];
4
+ default: number;
5
+ };
6
+ anchors: {
7
+ type: import("vue").PropType<number[]>;
8
+ default: () => never[];
9
+ };
10
+ duration: {
11
+ type: (NumberConstructor | StringConstructor)[];
12
+ default: number;
13
+ };
14
+ contentDraggable: {
15
+ type: BooleanConstructor;
16
+ default: true;
17
+ };
18
+ safeAreaInsetBottom: {
19
+ type: BooleanConstructor;
20
+ default: true;
21
+ };
22
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("heightChange" | "update:height")[], "heightChange" | "update:height", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
23
+ height: {
24
+ type: (NumberConstructor | StringConstructor)[];
25
+ default: number;
26
+ };
27
+ anchors: {
28
+ type: import("vue").PropType<number[]>;
29
+ default: () => never[];
30
+ };
31
+ duration: {
32
+ type: (NumberConstructor | StringConstructor)[];
33
+ default: number;
34
+ };
35
+ contentDraggable: {
36
+ type: BooleanConstructor;
37
+ default: true;
38
+ };
39
+ safeAreaInsetBottom: {
40
+ type: BooleanConstructor;
41
+ default: true;
42
+ };
43
+ }>> & {
44
+ onHeightChange?: ((...args: any[]) => any) | undefined;
45
+ "onUpdate:height"?: ((...args: any[]) => any) | undefined;
46
+ }, {
47
+ height: string | number;
48
+ safeAreaInsetBottom: boolean;
49
+ duration: string | number;
50
+ anchors: number[];
51
+ contentDraggable: boolean;
52
+ }, {}>>;
53
+ export default FloatingPanel;
54
+ export { floatingPanelProps } from './FloatingPanel';
55
+ export type { FloatingPanelProps } from './FloatingPanel';
56
+ export type { FloatingPanelThemeVars } from './types';
57
+ declare module 'vue' {
58
+ interface GlobalComponents {
59
+ VanFloatingPanel: typeof FloatingPanel;
60
+ }
61
+ }
@@ -0,0 +1,10 @@
1
+ import { withInstall } from "../utils/index.mjs";
2
+ import _FloatingPanel from "./FloatingPanel.mjs";
3
+ const FloatingPanel = withInstall(_FloatingPanel);
4
+ var stdin_default = FloatingPanel;
5
+ import { floatingPanelProps } from "./FloatingPanel.mjs";
6
+ export {
7
+ FloatingPanel,
8
+ stdin_default as default,
9
+ floatingPanelProps
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import "../../style/base.css";
2
+ import "../index.css";
@@ -0,0 +1,9 @@
1
+ export type FloatingPanelThemeVars = {
2
+ floatingPanelBorderRadius?: string;
3
+ floatingPanelHeaderHeight?: string;
4
+ floatingPanelZIndex?: number | string;
5
+ floatingPanelBackground?: string;
6
+ floatingPanelBarWidth?: string;
7
+ floatingPanelBarHeight?: string;
8
+ floatingPanelBarColor?: string;
9
+ };
File without changes
@@ -1,6 +1,6 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { ref, watch, computed, reactive, defineComponent } from "vue";
3
- import { clamp, numericProp, preventDefault, createNamespace, makeRequiredProp, LONG_PRESS_START_TIME } from "../utils/index.mjs";
3
+ import { clamp, numericProp, preventDefault, createNamespace, makeRequiredProp, LONG_PRESS_START_TIME, TAP_OFFSET } from "../utils/index.mjs";
4
4
  import { useTouch } from "../composables/use-touch.mjs";
5
5
  import { raf, useEventListener, useRect } from "@vant/use";
6
6
  import { Image } from "../image/index.mjs";
@@ -192,7 +192,6 @@ var stdin_default = defineComponent({
192
192
  } = touch;
193
193
  const deltaTime = Date.now() - touchStartTime;
194
194
  const TAP_TIME = 250;
195
- const TAP_OFFSET = 5;
196
195
  if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET) {
197
196
  if (deltaTime < TAP_TIME) {
198
197
  if (doubleTapTimer) {
package/es/index.d.ts CHANGED
@@ -35,6 +35,8 @@ export * from "./dropdown-item";
35
35
  export * from "./dropdown-menu";
36
36
  export * from "./empty";
37
37
  export * from "./field";
38
+ export * from "./floating-bubble";
39
+ export * from "./floating-panel";
38
40
  export * from "./form";
39
41
  export * from "./grid";
40
42
  export * from "./grid-item";
@@ -63,6 +65,7 @@ export * from "./pull-refresh";
63
65
  export * from "./radio";
64
66
  export * from "./radio-group";
65
67
  export * from "./rate";
68
+ export * from "./rolling-text";
66
69
  export * from "./row";
67
70
  export * from "./search";
68
71
  export * from "./share-sheet";
@@ -102,4 +105,4 @@ declare namespace _default {
102
105
  }
103
106
  export default _default;
104
107
  export function install(app: any): void;
105
- export const version: "4.4.1";
108
+ export const version: "4.6.0";
package/es/index.mjs CHANGED
@@ -35,6 +35,8 @@ import { DropdownItem } from "./dropdown-item/index.mjs";
35
35
  import { DropdownMenu } from "./dropdown-menu/index.mjs";
36
36
  import { Empty } from "./empty/index.mjs";
37
37
  import { Field } from "./field/index.mjs";
38
+ import { FloatingBubble } from "./floating-bubble/index.mjs";
39
+ import { FloatingPanel } from "./floating-panel/index.mjs";
38
40
  import { Form } from "./form/index.mjs";
39
41
  import { Grid } from "./grid/index.mjs";
40
42
  import { GridItem } from "./grid-item/index.mjs";
@@ -62,6 +64,7 @@ import { PullRefresh } from "./pull-refresh/index.mjs";
62
64
  import { Radio } from "./radio/index.mjs";
63
65
  import { RadioGroup } from "./radio-group/index.mjs";
64
66
  import { Rate } from "./rate/index.mjs";
67
+ import { RollingText } from "./rolling-text/index.mjs";
65
68
  import { Row } from "./row/index.mjs";
66
69
  import { Search } from "./search/index.mjs";
67
70
  import { ShareSheet } from "./share-sheet/index.mjs";
@@ -95,7 +98,7 @@ import { Toast } from "./toast/index.mjs";
95
98
  import { TreeSelect } from "./tree-select/index.mjs";
96
99
  import { Uploader } from "./uploader/index.mjs";
97
100
  import { Watermark } from "./watermark/index.mjs";
98
- const version = "4.4.1";
101
+ const version = "4.6.0";
99
102
  function install(app) {
100
103
  const components = [
101
104
  ActionBar,
@@ -135,6 +138,8 @@ function install(app) {
135
138
  DropdownMenu,
136
139
  Empty,
137
140
  Field,
141
+ FloatingBubble,
142
+ FloatingPanel,
138
143
  Form,
139
144
  Grid,
140
145
  GridItem,
@@ -162,6 +167,7 @@ function install(app) {
162
167
  Radio,
163
168
  RadioGroup,
164
169
  Rate,
170
+ RollingText,
165
171
  Row,
166
172
  Search,
167
173
  ShareSheet,
@@ -241,6 +247,8 @@ export * from "./dropdown-item/index.mjs";
241
247
  export * from "./dropdown-menu/index.mjs";
242
248
  export * from "./empty/index.mjs";
243
249
  export * from "./field/index.mjs";
250
+ export * from "./floating-bubble/index.mjs";
251
+ export * from "./floating-panel/index.mjs";
244
252
  export * from "./form/index.mjs";
245
253
  export * from "./grid/index.mjs";
246
254
  export * from "./grid-item/index.mjs";
@@ -269,6 +277,7 @@ export * from "./pull-refresh/index.mjs";
269
277
  export * from "./radio/index.mjs";
270
278
  export * from "./radio-group/index.mjs";
271
279
  export * from "./rate/index.mjs";
280
+ export * from "./rolling-text/index.mjs";
272
281
  export * from "./row/index.mjs";
273
282
  export * from "./search/index.mjs";
274
283
  export * from "./share-sheet/index.mjs";