vant 4.5.0 → 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 (119) hide show
  1. package/es/barrage/index.d.ts +1 -1
  2. package/es/barrage/types.d.ts +6 -0
  3. package/es/composables/use-touch.d.ts +1 -0
  4. package/es/composables/use-touch.mjs +8 -1
  5. package/es/config-provider/types.d.ts +1 -1
  6. package/es/dropdown-menu/index.d.ts +1 -1
  7. package/es/field/Field.mjs +1 -1
  8. package/es/floating-bubble/FloatingBubble.d.ts +86 -0
  9. package/es/floating-bubble/FloatingBubble.mjs +177 -0
  10. package/es/floating-bubble/index.css +1 -0
  11. package/es/floating-bubble/index.d.ts +63 -0
  12. package/es/floating-bubble/index.mjs +10 -0
  13. package/es/floating-bubble/style/index.d.ts +1 -0
  14. package/es/floating-bubble/style/index.mjs +4 -0
  15. package/es/floating-bubble/types.d.ts +8 -0
  16. package/es/floating-bubble/types.mjs +0 -0
  17. package/es/floating-panel/FloatingPanel.mjs +5 -4
  18. package/es/floating-panel/index.d.ts +3 -2
  19. package/es/floating-panel/index.mjs +3 -1
  20. package/es/floating-panel/types.d.ts +9 -0
  21. package/es/floating-panel/types.mjs +0 -0
  22. package/es/image-preview/ImagePreviewItem.mjs +1 -2
  23. package/es/index.d.ts +3 -1
  24. package/es/index.mjs +7 -1
  25. package/es/picker/PickerColumn.mjs +7 -2
  26. package/es/rate/Rate.d.ts +4 -0
  27. package/es/rate/Rate.mjs +16 -10
  28. package/es/rate/index.css +1 -1
  29. package/es/rate/index.d.ts +3 -0
  30. package/es/rolling-text/RollingText.d.ts +104 -0
  31. package/es/rolling-text/RollingText.mjs +98 -0
  32. package/es/rolling-text/RollingTextItem.d.ts +67 -0
  33. package/es/rolling-text/RollingTextItem.mjs +47 -0
  34. package/es/rolling-text/index.css +1 -0
  35. package/es/rolling-text/index.d.ts +79 -0
  36. package/es/rolling-text/index.mjs +10 -0
  37. package/es/rolling-text/style/index.d.ts +1 -0
  38. package/es/rolling-text/style/index.mjs +2 -0
  39. package/es/rolling-text/types.d.ts +17 -0
  40. package/es/rolling-text/types.mjs +0 -0
  41. package/es/signature/index.d.ts +1 -0
  42. package/es/signature/types.d.ts +6 -0
  43. package/es/signature/types.mjs +0 -0
  44. package/es/slider/Slider.d.ts +1 -1
  45. package/es/slider/index.d.ts +1 -1
  46. package/es/stepper/Stepper.d.ts +1 -1
  47. package/es/stepper/index.d.ts +1 -1
  48. package/es/utils/closest.d.ts +1 -0
  49. package/es/utils/closest.mjs +8 -0
  50. package/es/utils/constant.d.ts +1 -0
  51. package/es/utils/constant.mjs +3 -1
  52. package/es/utils/index.d.ts +1 -0
  53. package/es/utils/index.mjs +1 -0
  54. package/es/watermark/index.d.ts +1 -0
  55. package/es/watermark/types.d.ts +3 -0
  56. package/es/watermark/types.mjs +0 -0
  57. package/lib/barrage/index.d.ts +1 -1
  58. package/lib/barrage/types.d.ts +6 -0
  59. package/lib/composables/use-touch.d.ts +1 -0
  60. package/lib/composables/use-touch.js +8 -1
  61. package/lib/config-provider/types.d.ts +1 -1
  62. package/lib/dropdown-menu/index.d.ts +1 -1
  63. package/lib/field/Field.js +1 -1
  64. package/lib/floating-bubble/FloatingBubble.d.ts +86 -0
  65. package/lib/floating-bubble/FloatingBubble.js +206 -0
  66. package/lib/floating-bubble/index.css +1 -0
  67. package/lib/floating-bubble/index.d.ts +63 -0
  68. package/lib/floating-bubble/index.js +39 -0
  69. package/lib/floating-bubble/style/index.d.ts +1 -0
  70. package/lib/floating-bubble/style/index.js +4 -0
  71. package/lib/floating-bubble/types.d.ts +8 -0
  72. package/lib/floating-bubble/types.js +15 -0
  73. package/lib/floating-panel/FloatingPanel.js +5 -4
  74. package/lib/floating-panel/index.d.ts +3 -2
  75. package/lib/floating-panel/index.js +3 -1
  76. package/lib/floating-panel/types.d.ts +9 -0
  77. package/lib/floating-panel/types.js +15 -0
  78. package/lib/image-preview/ImagePreviewItem.js +1 -2
  79. package/lib/index.css +1 -1
  80. package/lib/index.d.ts +3 -1
  81. package/lib/index.js +7 -1
  82. package/lib/picker/PickerColumn.js +7 -2
  83. package/lib/rate/Rate.d.ts +4 -0
  84. package/lib/rate/Rate.js +16 -10
  85. package/lib/rate/index.css +1 -1
  86. package/lib/rate/index.d.ts +3 -0
  87. package/lib/rolling-text/RollingText.d.ts +104 -0
  88. package/lib/rolling-text/RollingText.js +127 -0
  89. package/lib/rolling-text/RollingTextItem.d.ts +67 -0
  90. package/lib/rolling-text/RollingTextItem.js +66 -0
  91. package/lib/rolling-text/index.css +1 -0
  92. package/lib/rolling-text/index.d.ts +79 -0
  93. package/lib/rolling-text/index.js +39 -0
  94. package/lib/rolling-text/style/index.d.ts +1 -0
  95. package/lib/rolling-text/style/index.js +2 -0
  96. package/lib/rolling-text/types.d.ts +17 -0
  97. package/lib/rolling-text/types.js +15 -0
  98. package/lib/signature/index.d.ts +1 -0
  99. package/lib/signature/types.d.ts +6 -0
  100. package/lib/signature/types.js +15 -0
  101. package/lib/slider/Slider.d.ts +1 -1
  102. package/lib/slider/index.d.ts +1 -1
  103. package/lib/stepper/Stepper.d.ts +1 -1
  104. package/lib/stepper/index.d.ts +1 -1
  105. package/lib/utils/closest.d.ts +1 -0
  106. package/lib/utils/closest.js +27 -0
  107. package/lib/utils/constant.d.ts +1 -0
  108. package/lib/utils/constant.js +3 -1
  109. package/lib/utils/index.d.ts +1 -0
  110. package/lib/utils/index.js +1 -0
  111. package/lib/vant.cjs.js +2340 -2012
  112. package/lib/vant.es.js +2340 -2012
  113. package/lib/vant.js +2340 -2012
  114. package/lib/vant.min.js +1 -1
  115. package/lib/watermark/index.d.ts +1 -0
  116. package/lib/watermark/types.d.ts +3 -0
  117. package/lib/watermark/types.js +15 -0
  118. package/lib/web-types.json +1 -1
  119. package/package.json +1 -1
@@ -11,3 +11,4 @@ export declare const BORDER_UNSET_TOP_BOTTOM: string;
11
11
  export declare const HAPTICS_FEEDBACK = "van-haptics-feedback";
12
12
  export declare const FORM_KEY: InjectionKey<FormProvide>;
13
13
  export declare const LONG_PRESS_START_TIME = 500;
14
+ export declare const TAP_OFFSET = 5;
@@ -9,6 +9,7 @@ const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
9
9
  const HAPTICS_FEEDBACK = "van-haptics-feedback";
10
10
  const FORM_KEY = Symbol("van-form");
11
11
  const LONG_PRESS_START_TIME = 500;
12
+ const TAP_OFFSET = 5;
12
13
  export {
13
14
  BORDER,
14
15
  BORDER_BOTTOM,
@@ -20,5 +21,6 @@ export {
20
21
  BORDER_UNSET_TOP_BOTTOM,
21
22
  FORM_KEY,
22
23
  HAPTICS_FEEDBACK,
23
- LONG_PRESS_START_TIME
24
+ LONG_PRESS_START_TIME,
25
+ TAP_OFFSET
24
26
  };
@@ -7,3 +7,4 @@ export * from './constant';
7
7
  export * from './validate';
8
8
  export * from './interceptor';
9
9
  export * from './with-install';
10
+ export * from './closest';
@@ -7,3 +7,4 @@ export * from "./constant.mjs";
7
7
  export * from "./validate.mjs";
8
8
  export * from "./interceptor.mjs";
9
9
  export * from "./with-install.mjs";
10
+ export * from "./closest.mjs";
@@ -76,6 +76,7 @@ export declare const Watermark: import("../utils").WithInstall<import("vue").Def
76
76
  export default Watermark;
77
77
  export { watermarkProps } from './Watermark';
78
78
  export type { WatermarkProps } from './Watermark';
79
+ export type { WatermarkThemeVars } from './types';
79
80
  declare module 'vue' {
80
81
  interface GlobalComponents {
81
82
  VanWatermark: typeof Watermark;
@@ -0,0 +1,3 @@
1
+ export type WatermarkThemeVars = {
2
+ watermarkZIndex?: number | string;
3
+ };
File without changes
@@ -61,7 +61,7 @@ export declare const Barrage: import("../utils").WithInstall<import("vue").Defin
61
61
  export default Barrage;
62
62
  export { barrageProps } from './Barrage';
63
63
  export type { BarrageProps, BarrageItem } from './Barrage';
64
- export type { BarrageInstance } from './types';
64
+ export type { BarrageInstance, BarrageThemeVars } from './types';
65
65
  declare module 'vue' {
66
66
  interface GlobalComponents {
67
67
  VanBarrage: typeof Barrage;
@@ -5,3 +5,9 @@ export type BarrageExpose = {
5
5
  pause(): void;
6
6
  };
7
7
  export type BarrageInstance = ComponentPublicInstance<BarrageProps, BarrageExpose>;
8
+ export type BarrageThemeVars = {
9
+ barrageFontSize?: string;
10
+ barrageSpace?: string;
11
+ barrageFont?: string;
12
+ barrageColor?: string;
13
+ };
@@ -12,5 +12,6 @@ export declare function useTouch(): {
12
12
  direction: import("vue").Ref<Direction>;
13
13
  isVertical: () => boolean;
14
14
  isHorizontal: () => boolean;
15
+ isTap: import("vue").Ref<boolean>;
15
16
  };
16
17
  export {};
@@ -21,6 +21,7 @@ __export(stdin_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(stdin_exports);
23
23
  var import_vue = require("vue");
24
+ var import_utils = require("../utils");
24
25
  function getDirection(x, y) {
25
26
  if (x > y) {
26
27
  return "horizontal";
@@ -38,6 +39,7 @@ function useTouch() {
38
39
  const offsetX = (0, import_vue.ref)(0);
39
40
  const offsetY = (0, import_vue.ref)(0);
40
41
  const direction = (0, import_vue.ref)("");
42
+ const isTap = (0, import_vue.ref)(true);
41
43
  const isVertical = () => direction.value === "vertical";
42
44
  const isHorizontal = () => direction.value === "horizontal";
43
45
  const reset = () => {
@@ -46,6 +48,7 @@ function useTouch() {
46
48
  offsetX.value = 0;
47
49
  offsetY.value = 0;
48
50
  direction.value = "";
51
+ isTap.value = true;
49
52
  };
50
53
  const start = (event) => {
51
54
  reset();
@@ -62,6 +65,9 @@ function useTouch() {
62
65
  if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
63
66
  direction.value = getDirection(offsetX.value, offsetY.value);
64
67
  }
68
+ if (isTap.value && (offsetX.value > import_utils.TAP_OFFSET || offsetY.value > import_utils.TAP_OFFSET)) {
69
+ isTap.value = false;
70
+ }
65
71
  };
66
72
  return {
67
73
  move,
@@ -75,6 +81,7 @@ function useTouch() {
75
81
  offsetY,
76
82
  direction,
77
83
  isVertical,
78
- isHorizontal
84
+ isHorizontal,
85
+ isTap
79
86
  };
80
87
  }
@@ -1 +1 @@
1
- export type ConfigProviderThemeVars = import('../action-bar').ActionBarThemeVars & import('../action-bar-button').ActionBarButtonThemeVars & import('../action-bar-icon').ActionBarIconThemeVars & import('../action-sheet').ActionSheetThemeVars & import('../address-edit').AddressEditThemeVars & import('../address-list').AddressListThemeVars & import('../badge').BadgeThemeVars & import('../button').ButtonThemeVars & import('../calendar').CalendarThemeVars & import('../card').CardThemeVars & import('../cascader').CascaderThemeVars & import('../cell').CellThemeVars & import('../cell-group').CellGroupThemeVars & import('../checkbox').CheckboxThemeVars & import('../circle').CircleThemeVars & import('../collapse-item').CollapseItemThemeVars & import('../contact-card').ContactCardThemeVars & import('../contact-edit').ContactEditThemeVars & import('../contact-list').ContactListThemeVars & import('../count-down').CountDownThemeVars & import('../coupon').CouponThemeVars & import('../coupon-cell').CouponCellThemeVars & import('../coupon-list').CouponListThemeVars & import('../dialog').DialogThemeVars & import('../divider').DividerThemeVars & import('../dropdown-item').DropdownItemThemeVars & import('../dropdown-menu').DropdownMenuThemeVars & import('../empty').EmptyThemeVars & import('../field').FieldThemeVars & import('../grid-item').GridItemThemeVars & import('../image').ImageThemeVars & import('../image-preview').ImagePreviewThemeVars & import('../index-anchor').IndexAnchorThemeVars & import('../index-bar').IndexBarThemeVars & import('../list').ListThemeVars & import('../loading').LoadingThemeVars & import('../nav-bar').NavBarThemeVars & import('../notice-bar').NoticeBarThemeVars & import('../notify').NotifyThemeVars & import('../number-keyboard').NumberKeyboardThemeVars & import('../overlay').OverlayThemeVars & import('../pagination').PaginationThemeVars & import('../password-input').PasswordInputThemeVars & import('../picker').PickerThemeVars & import('../picker-group').PickerGroupThemeVars & import('../popover').PopoverThemeVars & import('../popup').PopupThemeVars & import('../progress').ProgressThemeVars & import('../pull-refresh').PullRefreshThemeVars & import('../radio').RadioThemeVars & import('../rate').RateThemeVars & import('../search').SearchThemeVars & import('../share-sheet').ShareSheetThemeVars & import('../sidebar').SidebarThemeVars & import('../sidebar-item').SidebarItemThemeVars & import('../skeleton').SkeletonThemeVars & import('../slider').SliderThemeVars & import('../step').StepThemeVars & import('../stepper').StepperThemeVars & import('../steps').StepsThemeVars & import('../sticky').StickyThemeVars & import('../submit-bar').SubmitBarThemeVars & import('../swipe').SwipeThemeVars & import('../switch').SwitchThemeVars & import('../tabbar').TabbarThemeVars & import('../tabbar-item').TabbarItemThemeVars & import('../tabs').TabsThemeVars & import('../tag').TagThemeVars & import('../toast').ToastThemeVars & import('../tree-select').TreeSelectThemeVars & import('../uploader').UploaderThemeVars;
1
+ export type ConfigProviderThemeVars = import('../action-bar').ActionBarThemeVars & import('../action-bar-button').ActionBarButtonThemeVars & import('../action-bar-icon').ActionBarIconThemeVars & import('../action-sheet').ActionSheetThemeVars & import('../address-edit').AddressEditThemeVars & import('../address-list').AddressListThemeVars & import('../badge').BadgeThemeVars & import('../barrage').BarrageThemeVars & import('../button').ButtonThemeVars & import('../calendar').CalendarThemeVars & import('../card').CardThemeVars & import('../cascader').CascaderThemeVars & import('../cell').CellThemeVars & import('../cell-group').CellGroupThemeVars & import('../checkbox').CheckboxThemeVars & import('../circle').CircleThemeVars & import('../collapse-item').CollapseItemThemeVars & import('../contact-card').ContactCardThemeVars & import('../contact-edit').ContactEditThemeVars & import('../contact-list').ContactListThemeVars & import('../count-down').CountDownThemeVars & import('../coupon').CouponThemeVars & import('../coupon-cell').CouponCellThemeVars & import('../coupon-list').CouponListThemeVars & import('../dialog').DialogThemeVars & import('../divider').DividerThemeVars & import('../dropdown-item').DropdownItemThemeVars & import('../dropdown-menu').DropdownMenuThemeVars & import('../empty').EmptyThemeVars & import('../field').FieldThemeVars & import('../floating-bubble').FloatingBubbleThemeVars & import('../floating-panel').FloatingPanelThemeVars & import('../grid-item').GridItemThemeVars & import('../image').ImageThemeVars & import('../image-preview').ImagePreviewThemeVars & import('../index-anchor').IndexAnchorThemeVars & import('../index-bar').IndexBarThemeVars & import('../list').ListThemeVars & import('../loading').LoadingThemeVars & import('../nav-bar').NavBarThemeVars & import('../notice-bar').NoticeBarThemeVars & import('../notify').NotifyThemeVars & import('../number-keyboard').NumberKeyboardThemeVars & import('../overlay').OverlayThemeVars & import('../pagination').PaginationThemeVars & import('../password-input').PasswordInputThemeVars & import('../picker').PickerThemeVars & import('../picker-group').PickerGroupThemeVars & import('../popover').PopoverThemeVars & import('../popup').PopupThemeVars & import('../progress').ProgressThemeVars & import('../pull-refresh').PullRefreshThemeVars & import('../radio').RadioThemeVars & import('../rate').RateThemeVars & import('../rolling-text').RollingTextThemeVars & import('../search').SearchThemeVars & import('../share-sheet').ShareSheetThemeVars & import('../sidebar').SidebarThemeVars & import('../sidebar-item').SidebarItemThemeVars & import('../signature').SignatureThemeVars & import('../skeleton').SkeletonThemeVars & import('../slider').SliderThemeVars & import('../step').StepThemeVars & import('../stepper').StepperThemeVars & import('../steps').StepsThemeVars & import('../sticky').StickyThemeVars & import('../submit-bar').SubmitBarThemeVars & import('../swipe').SwipeThemeVars & import('../switch').SwitchThemeVars & import('../tabbar').TabbarThemeVars & import('../tabbar-item').TabbarItemThemeVars & import('../tabs').TabsThemeVars & import('../tag').TagThemeVars & import('../toast').ToastThemeVars & import('../tree-select').TreeSelectThemeVars & import('../uploader').UploaderThemeVars & import('../watermark').WatermarkThemeVars;
@@ -55,7 +55,7 @@ export declare const DropdownMenu: import("../utils").WithInstall<import("vue").
55
55
  export default DropdownMenu;
56
56
  export { dropdownMenuProps } from './DropdownMenu';
57
57
  export type { DropdownMenuProps };
58
- export type { DropdownMenuDirection, DropdownMenuThemeVars } from './types';
58
+ export type { DropdownMenuInstance, DropdownMenuDirection, DropdownMenuThemeVars, } from './types';
59
59
  declare module 'vue' {
60
60
  interface GlobalComponents {
61
61
  VanDropdownMenu: typeof DropdownMenu;
@@ -451,7 +451,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
451
451
  if (props.label) {
452
452
  return (0, import_vue.createVNode)("label", {
453
453
  "id": `${id}-label`,
454
- "for": getInputId(),
454
+ "for": slots.input ? void 0 : getInputId(),
455
455
  "onClick": (event) => {
456
456
  (0, import_utils.preventDefault)(event);
457
457
  focus();
@@ -0,0 +1,86 @@
1
+ import { PropType, type ExtractPropTypes } from 'vue';
2
+ export type FloatingBubbleAxis = 'x' | 'y' | 'xy' | 'lock';
3
+ export type FloatingBubbleMagnetic = 'x' | 'y';
4
+ export type FloatingBubbleOffset = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ export declare const floatingBubbleProps: {
9
+ axis: {
10
+ type: PropType<FloatingBubbleAxis>;
11
+ default: FloatingBubbleAxis;
12
+ };
13
+ magnetic: PropType<FloatingBubbleMagnetic>;
14
+ icon: StringConstructor;
15
+ gap: {
16
+ type: NumberConstructor;
17
+ default: number;
18
+ };
19
+ offset: {
20
+ type: PropType<FloatingBubbleOffset>;
21
+ default: () => {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ };
26
+ teleport: {
27
+ type: PropType<string | import("vue").RendererElement | null | undefined>;
28
+ default: string;
29
+ };
30
+ };
31
+ export type FloatingBubbleProps = ExtractPropTypes<typeof floatingBubbleProps>;
32
+ declare const _default: import("vue").DefineComponent<{
33
+ axis: {
34
+ type: PropType<FloatingBubbleAxis>;
35
+ default: FloatingBubbleAxis;
36
+ };
37
+ magnetic: PropType<FloatingBubbleMagnetic>;
38
+ icon: StringConstructor;
39
+ gap: {
40
+ type: NumberConstructor;
41
+ default: number;
42
+ };
43
+ offset: {
44
+ type: PropType<FloatingBubbleOffset>;
45
+ default: () => {
46
+ x: number;
47
+ y: number;
48
+ };
49
+ };
50
+ teleport: {
51
+ type: PropType<string | import("vue").RendererElement | null | undefined>;
52
+ default: string;
53
+ };
54
+ }, () => 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<ExtractPropTypes<{
55
+ axis: {
56
+ type: PropType<FloatingBubbleAxis>;
57
+ default: FloatingBubbleAxis;
58
+ };
59
+ magnetic: PropType<FloatingBubbleMagnetic>;
60
+ icon: StringConstructor;
61
+ gap: {
62
+ type: NumberConstructor;
63
+ default: number;
64
+ };
65
+ offset: {
66
+ type: PropType<FloatingBubbleOffset>;
67
+ default: () => {
68
+ x: number;
69
+ y: number;
70
+ };
71
+ };
72
+ teleport: {
73
+ type: PropType<string | import("vue").RendererElement | null | undefined>;
74
+ default: string;
75
+ };
76
+ }>> & {
77
+ onClick?: ((...args: any[]) => any) | undefined;
78
+ "onUpdate:offset"?: ((...args: any[]) => any) | undefined;
79
+ onOffsetChange?: ((...args: any[]) => any) | undefined;
80
+ }, {
81
+ offset: FloatingBubbleOffset;
82
+ teleport: string | import("vue").RendererElement | null | undefined;
83
+ gap: number;
84
+ axis: FloatingBubbleAxis;
85
+ }, {}>;
86
+ export default _default;
@@ -0,0 +1,206 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var stdin_exports = {};
29
+ __export(stdin_exports, {
30
+ default: () => stdin_default,
31
+ floatingBubbleProps: () => floatingBubbleProps
32
+ });
33
+ module.exports = __toCommonJS(stdin_exports);
34
+ var import_vue = require("vue");
35
+ var import_vue2 = require("vue");
36
+ var import_use = require("@vant/use");
37
+ var import_use_touch = require("../composables/use-touch");
38
+ var import_utils = require("../utils");
39
+ var import_icon = __toESM(require("../icon"));
40
+ const floatingBubbleProps = {
41
+ axis: (0, import_utils.makeStringProp)("y"),
42
+ magnetic: String,
43
+ icon: String,
44
+ gap: (0, import_utils.makeNumberProp)(24),
45
+ offset: {
46
+ type: Object,
47
+ default: () => ({
48
+ x: -1,
49
+ y: -1
50
+ })
51
+ },
52
+ teleport: {
53
+ type: [String, Object],
54
+ default: "body"
55
+ }
56
+ };
57
+ const [name, bem] = (0, import_utils.createNamespace)("floating-bubble");
58
+ var stdin_default = (0, import_vue2.defineComponent)({
59
+ name,
60
+ props: floatingBubbleProps,
61
+ emits: ["click", "update:offset", "offsetChange"],
62
+ setup(props, {
63
+ slots,
64
+ emit
65
+ }) {
66
+ const rootRef = (0, import_vue2.ref)();
67
+ const state = (0, import_vue2.ref)({
68
+ x: 0,
69
+ y: 0,
70
+ width: 0,
71
+ height: 0
72
+ });
73
+ const boundary = (0, import_vue2.computed)(() => ({
74
+ top: props.gap,
75
+ right: import_utils.windowWidth.value - state.value.height - props.gap,
76
+ bottom: import_utils.windowHeight.value - state.value.width - props.gap,
77
+ left: props.gap
78
+ }));
79
+ const dragging = (0, import_vue2.ref)(false);
80
+ let initialized = false;
81
+ const rootStyle = (0, import_vue2.computed)(() => {
82
+ const style = {};
83
+ const x = (0, import_utils.addUnit)(state.value.x);
84
+ const y = (0, import_utils.addUnit)(state.value.y);
85
+ style.transform = `translate3d(${x}, ${y}, 0)`;
86
+ if (dragging.value || !initialized) {
87
+ style.transition = "none";
88
+ }
89
+ return style;
90
+ });
91
+ const updateState = () => {
92
+ const {
93
+ width,
94
+ height
95
+ } = (0, import_use.useRect)(rootRef.value);
96
+ const {
97
+ offset
98
+ } = props;
99
+ state.value = {
100
+ x: offset.x > -1 ? offset.x : import_utils.windowWidth.value - width - props.gap,
101
+ y: offset.y > -1 ? offset.y : import_utils.windowHeight.value - height - props.gap,
102
+ width,
103
+ height
104
+ };
105
+ };
106
+ const touch = (0, import_use_touch.useTouch)();
107
+ let prevX = 0;
108
+ let prevY = 0;
109
+ const onTouchStart = (e) => {
110
+ touch.start(e);
111
+ dragging.value = true;
112
+ prevX = state.value.x;
113
+ prevY = state.value.y;
114
+ };
115
+ const onTouchMove = (e) => {
116
+ e.preventDefault();
117
+ touch.move(e);
118
+ if (props.axis === "lock")
119
+ return;
120
+ if (!touch.isTap.value) {
121
+ if (props.axis === "x" || props.axis === "xy") {
122
+ let nextX = prevX + touch.deltaX.value;
123
+ if (nextX < boundary.value.left)
124
+ nextX = boundary.value.left;
125
+ if (nextX > boundary.value.right)
126
+ nextX = boundary.value.right;
127
+ state.value.x = nextX;
128
+ }
129
+ if (props.axis === "y" || props.axis === "xy") {
130
+ let nextY = prevY + touch.deltaY.value;
131
+ if (nextY < boundary.value.top)
132
+ nextY = boundary.value.top;
133
+ if (nextY > boundary.value.bottom)
134
+ nextY = boundary.value.bottom;
135
+ state.value.y = nextY;
136
+ }
137
+ const offset = (0, import_utils.pick)(state.value, ["x", "y"]);
138
+ emit("update:offset", offset);
139
+ }
140
+ };
141
+ (0, import_use.useEventListener)("touchmove", onTouchMove, {
142
+ target: rootRef
143
+ });
144
+ const onTouchEnd = () => {
145
+ dragging.value = false;
146
+ (0, import_vue2.nextTick)(() => {
147
+ if (props.magnetic === "x") {
148
+ const nextX = (0, import_utils.closest)([boundary.value.left, boundary.value.right], state.value.x);
149
+ state.value.x = nextX;
150
+ }
151
+ if (props.magnetic === "y") {
152
+ const nextY = (0, import_utils.closest)([boundary.value.top, boundary.value.bottom], state.value.y);
153
+ state.value.y = nextY;
154
+ }
155
+ if (!touch.isTap.value) {
156
+ const offset = (0, import_utils.pick)(state.value, ["x", "y"]);
157
+ emit("update:offset", offset);
158
+ if (prevX !== offset.x || prevY !== offset.y) {
159
+ emit("offsetChange", offset);
160
+ }
161
+ }
162
+ });
163
+ };
164
+ const onClick = (e) => {
165
+ if (touch.isTap.value)
166
+ emit("click", e);
167
+ };
168
+ (0, import_vue2.onMounted)(() => {
169
+ updateState();
170
+ (0, import_vue2.nextTick)(() => {
171
+ initialized = true;
172
+ });
173
+ });
174
+ (0, import_vue2.watch)([import_utils.windowWidth, import_utils.windowHeight, () => props.gap, () => props.offset], () => updateState(), {
175
+ deep: true
176
+ });
177
+ const show = (0, import_vue2.ref)(true);
178
+ (0, import_vue2.onActivated)(() => {
179
+ show.value = true;
180
+ });
181
+ (0, import_vue2.onDeactivated)(() => {
182
+ if (props.teleport) {
183
+ show.value = false;
184
+ }
185
+ });
186
+ return () => {
187
+ const Content = (0, import_vue.withDirectives)((0, import_vue.createVNode)("div", {
188
+ "class": bem(),
189
+ "ref": rootRef,
190
+ "onTouchstartPassive": onTouchStart,
191
+ "onTouchend": onTouchEnd,
192
+ "onTouchcancel": onTouchEnd,
193
+ "onClick": onClick,
194
+ "style": rootStyle.value
195
+ }, [slots.default ? slots.default() : (0, import_vue.createVNode)(import_icon.default, {
196
+ "name": props.icon,
197
+ "class": bem("icon")
198
+ }, null)]), [[import_vue.vShow, show.value]]);
199
+ return props.teleport ? (0, import_vue.createVNode)(import_vue2.Teleport, {
200
+ "to": props.teleport
201
+ }, {
202
+ default: () => [Content]
203
+ }) : Content;
204
+ };
205
+ }
206
+ });
@@ -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,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var stdin_exports = {};
29
+ __export(stdin_exports, {
30
+ FloatingBubble: () => FloatingBubble,
31
+ default: () => stdin_default,
32
+ floatingBubbleProps: () => import_FloatingBubble2.floatingBubbleProps
33
+ });
34
+ module.exports = __toCommonJS(stdin_exports);
35
+ var import_utils = require("../utils");
36
+ var import_FloatingBubble = __toESM(require("./FloatingBubble"));
37
+ var import_FloatingBubble2 = require("./FloatingBubble");
38
+ const FloatingBubble = (0, import_utils.withInstall)(import_FloatingBubble.default);
39
+ var stdin_default = FloatingBubble;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ require("../../style/base.css");
2
+ require("../../badge/index.css");
3
+ require("../../icon/index.css");
4
+ require("../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
+ };
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var stdin_exports = {};
15
+ module.exports = __toCommonJS(stdin_exports);
@@ -79,7 +79,6 @@ var stdin_default = (0, import_vue2.defineComponent)({
79
79
  }
80
80
  return moveY;
81
81
  };
82
- const closest = (arr, target) => arr.reduce((pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur);
83
82
  let startY;
84
83
  const touch = (0, import_use_touch.useTouch)();
85
84
  const onTouchstart = (e) => {
@@ -107,7 +106,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
107
106
  };
108
107
  const onTouchend = () => {
109
108
  dragging.value = false;
110
- height.value = closest(anchors.value, height.value);
109
+ height.value = (0, import_utils.closest)(anchors.value, height.value);
111
110
  if (height.value !== -startY) {
112
111
  emit("heightChange", {
113
112
  height: height.value
@@ -115,11 +114,14 @@ var stdin_default = (0, import_vue2.defineComponent)({
115
114
  }
116
115
  };
117
116
  (0, import_vue2.watch)(boundary, () => {
118
- height.value = closest(anchors.value, height.value);
117
+ height.value = (0, import_utils.closest)(anchors.value, height.value);
119
118
  }, {
120
119
  immediate: true
121
120
  });
122
121
  (0, import_use_lock_scroll.useLockScroll)(rootRef, () => true);
122
+ (0, import_use.useEventListener)("touchmove", onTouchmove, {
123
+ target: rootRef
124
+ });
123
125
  return () => {
124
126
  var _a;
125
127
  return (0, import_vue.createVNode)("div", {
@@ -129,7 +131,6 @@ var stdin_default = (0, import_vue2.defineComponent)({
129
131
  "ref": rootRef,
130
132
  "style": rootStyle.value,
131
133
  "onTouchstartPassive": onTouchstart,
132
- "onTouchmove": onTouchmove,
133
134
  "onTouchend": onTouchend,
134
135
  "onTouchcancel": onTouchend
135
136
  }, [(0, import_vue.createVNode)("div", {
@@ -1,4 +1,3 @@
1
- import { FloatingPanelProps } from './FloatingPanel';
2
1
  export declare const FloatingPanel: import("../utils").WithInstall<import("vue").DefineComponent<{
3
2
  height: {
4
3
  type: (NumberConstructor | StringConstructor)[];
@@ -52,7 +51,9 @@ export declare const FloatingPanel: import("../utils").WithInstall<import("vue")
52
51
  contentDraggable: boolean;
53
52
  }, {}>>;
54
53
  export default FloatingPanel;
55
- export type { FloatingPanelProps };
54
+ export { floatingPanelProps } from './FloatingPanel';
55
+ export type { FloatingPanelProps } from './FloatingPanel';
56
+ export type { FloatingPanelThemeVars } from './types';
56
57
  declare module 'vue' {
57
58
  interface GlobalComponents {
58
59
  VanFloatingPanel: typeof FloatingPanel;