vant 4.4.1 → 4.5.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 (59) 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/date-picker/DatePicker.d.ts +3 -3
  8. package/es/date-picker/index.d.ts +2 -2
  9. package/es/date-picker/utils.d.ts +4 -2
  10. package/es/date-picker/utils.mjs +8 -3
  11. package/es/dropdown-menu/DropdownMenu.mjs +10 -3
  12. package/es/dropdown-menu/types.d.ts +5 -1
  13. package/es/floating-panel/FloatingPanel.d.ts +77 -0
  14. package/es/floating-panel/FloatingPanel.mjs +126 -0
  15. package/es/floating-panel/index.css +1 -0
  16. package/es/floating-panel/index.d.ts +60 -0
  17. package/es/floating-panel/index.mjs +8 -0
  18. package/es/floating-panel/style/index.d.ts +1 -0
  19. package/es/floating-panel/style/index.mjs +2 -0
  20. package/es/index.d.ts +2 -1
  21. package/es/index.mjs +4 -1
  22. package/es/slider/Slider.mjs +10 -2
  23. package/es/time-picker/TimePicker.d.ts +31 -4
  24. package/es/time-picker/TimePicker.mjs +73 -21
  25. package/es/time-picker/index.d.ts +20 -2
  26. package/es/utils/basic.d.ts +3 -0
  27. package/lib/address-list/AddressList.d.ts +13 -0
  28. package/lib/address-list/AddressList.js +3 -1
  29. package/lib/address-list/AddressListItem.d.ts +9 -0
  30. package/lib/address-list/AddressListItem.js +3 -2
  31. package/lib/address-list/index.d.ts +9 -0
  32. package/lib/back-top/BackTop.js +13 -0
  33. package/lib/date-picker/DatePicker.d.ts +3 -3
  34. package/lib/date-picker/index.d.ts +2 -2
  35. package/lib/date-picker/utils.d.ts +4 -2
  36. package/lib/date-picker/utils.js +2 -2
  37. package/lib/dropdown-menu/DropdownMenu.js +10 -3
  38. package/lib/dropdown-menu/types.d.ts +5 -1
  39. package/lib/floating-panel/FloatingPanel.d.ts +77 -0
  40. package/lib/floating-panel/FloatingPanel.js +145 -0
  41. package/lib/floating-panel/index.css +1 -0
  42. package/lib/floating-panel/index.d.ts +60 -0
  43. package/lib/floating-panel/index.js +37 -0
  44. package/lib/floating-panel/style/index.d.ts +1 -0
  45. package/lib/floating-panel/style/index.js +2 -0
  46. package/lib/index.css +1 -1
  47. package/lib/index.d.ts +2 -1
  48. package/lib/index.js +4 -1
  49. package/lib/slider/Slider.js +10 -2
  50. package/lib/time-picker/TimePicker.d.ts +31 -4
  51. package/lib/time-picker/TimePicker.js +84 -32
  52. package/lib/time-picker/index.d.ts +20 -2
  53. package/lib/utils/basic.d.ts +3 -0
  54. package/lib/vant.cjs.js +770 -570
  55. package/lib/vant.es.js +770 -570
  56. package/lib/vant.js +766 -566
  57. package/lib/vant.min.js +1 -1
  58. package/lib/web-types.json +1 -1
  59. package/package.json +1 -1
@@ -17,6 +17,10 @@ export declare const addressListProps: {
17
17
  };
18
18
  addButtonText: StringConstructor;
19
19
  defaultTagText: StringConstructor;
20
+ rightIcon: {
21
+ type: import("vue").PropType<string>;
22
+ default: string;
23
+ };
20
24
  };
21
25
  export type AddressListProps = ExtractPropTypes<typeof addressListProps>;
22
26
  declare const _default: import("vue").DefineComponent<{
@@ -36,6 +40,10 @@ declare const _default: import("vue").DefineComponent<{
36
40
  };
37
41
  addButtonText: StringConstructor;
38
42
  defaultTagText: StringConstructor;
43
+ rightIcon: {
44
+ type: import("vue").PropType<string>;
45
+ default: string;
46
+ };
39
47
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:modelValue" | "add" | "edit" | "clickItem" | "editDisabled" | "selectDisabled")[], "select" | "update:modelValue" | "add" | "edit" | "clickItem" | "editDisabled" | "selectDisabled", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
40
48
  list: {
41
49
  type: import("vue").PropType<AddressListAddress[]>;
@@ -53,6 +61,10 @@ declare const _default: import("vue").DefineComponent<{
53
61
  };
54
62
  addButtonText: StringConstructor;
55
63
  defaultTagText: StringConstructor;
64
+ rightIcon: {
65
+ type: import("vue").PropType<string>;
66
+ default: string;
67
+ };
56
68
  }>> & {
57
69
  onSelect?: ((...args: any[]) => any) | undefined;
58
70
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -62,6 +74,7 @@ declare const _default: import("vue").DefineComponent<{
62
74
  onEditDisabled?: ((...args: any[]) => any) | undefined;
63
75
  onSelectDisabled?: ((...args: any[]) => any) | undefined;
64
76
  }, {
77
+ rightIcon: string;
65
78
  switchable: boolean;
66
79
  list: AddressListAddress[];
67
80
  disabledList: AddressListAddress[];
@@ -1,6 +1,6 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { defineComponent } from "vue";
3
- import { truthProp, numericProp, makeArrayProp, createNamespace } from "../utils/index.mjs";
3
+ import { truthProp, numericProp, makeArrayProp, createNamespace, makeStringProp } from "../utils/index.mjs";
4
4
  import { Button } from "../button/index.mjs";
5
5
  import { RadioGroup } from "../radio-group/index.mjs";
6
6
  import AddressListItem from "./AddressListItem.mjs";
@@ -12,7 +12,8 @@ const addressListProps = {
12
12
  disabledText: String,
13
13
  disabledList: makeArrayProp(),
14
14
  addButtonText: String,
15
- defaultTagText: String
15
+ defaultTagText: String,
16
+ rightIcon: makeStringProp("edit")
16
17
  };
17
18
  var stdin_default = defineComponent({
18
19
  name,
@@ -37,6 +38,7 @@ var stdin_default = defineComponent({
37
38
  "disabled": disabled,
38
39
  "switchable": props.switchable,
39
40
  "defaultTagText": props.defaultTagText,
41
+ "rightIcon": props.rightIcon,
40
42
  "onEdit": onEdit,
41
43
  "onClick": onClick,
42
44
  "onSelect": onSelect
@@ -15,6 +15,10 @@ declare const _default: import("vue").DefineComponent<{
15
15
  disabled: BooleanConstructor;
16
16
  switchable: BooleanConstructor;
17
17
  defaultTagText: StringConstructor;
18
+ rightIcon: {
19
+ type: PropType<string>;
20
+ default: string;
21
+ };
18
22
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "click" | "edit")[], "select" | "click" | "edit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
19
23
  address: {
20
24
  type: PropType<AddressListAddress>;
@@ -23,12 +27,17 @@ declare const _default: import("vue").DefineComponent<{
23
27
  disabled: BooleanConstructor;
24
28
  switchable: BooleanConstructor;
25
29
  defaultTagText: StringConstructor;
30
+ rightIcon: {
31
+ type: PropType<string>;
32
+ default: string;
33
+ };
26
34
  }>> & {
27
35
  onClick?: ((...args: any[]) => any) | undefined;
28
36
  onSelect?: ((...args: any[]) => any) | undefined;
29
37
  onEdit?: ((...args: any[]) => any) | undefined;
30
38
  }, {
31
39
  disabled: boolean;
40
+ rightIcon: string;
32
41
  switchable: boolean;
33
42
  }, {}>;
34
43
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { defineComponent } from "vue";
3
- import { extend, createNamespace, makeRequiredProp } from "../utils/index.mjs";
3
+ import { extend, createNamespace, makeRequiredProp, makeStringProp } from "../utils/index.mjs";
4
4
  import { Tag } from "../tag/index.mjs";
5
5
  import { Icon } from "../icon/index.mjs";
6
6
  import { Cell } from "../cell/index.mjs";
@@ -12,7 +12,8 @@ var stdin_default = defineComponent({
12
12
  address: makeRequiredProp(Object),
13
13
  disabled: Boolean,
14
14
  switchable: Boolean,
15
- defaultTagText: String
15
+ defaultTagText: String,
16
+ rightIcon: makeStringProp("edit")
16
17
  },
17
18
  emits: ["edit", "click", "select"],
18
19
  setup(props, {
@@ -26,7 +27,7 @@ var stdin_default = defineComponent({
26
27
  emit("click");
27
28
  };
28
29
  const renderRightIcon = () => _createVNode(Icon, {
29
- "name": "edit",
30
+ "name": props.rightIcon,
30
31
  "class": bem("edit"),
31
32
  "onClick": (event) => {
32
33
  event.stopPropagation();
@@ -15,6 +15,10 @@ export declare const AddressList: import("../utils").WithInstall<import("vue").D
15
15
  };
16
16
  addButtonText: StringConstructor;
17
17
  defaultTagText: StringConstructor;
18
+ rightIcon: {
19
+ type: import("vue").PropType<string>;
20
+ default: string;
21
+ };
18
22
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:modelValue" | "add" | "edit" | "clickItem" | "editDisabled" | "selectDisabled")[], "select" | "update:modelValue" | "add" | "edit" | "clickItem" | "editDisabled" | "selectDisabled", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
19
23
  list: {
20
24
  type: import("vue").PropType<import("./AddressListItem").AddressListAddress[]>;
@@ -32,6 +36,10 @@ export declare const AddressList: import("../utils").WithInstall<import("vue").D
32
36
  };
33
37
  addButtonText: StringConstructor;
34
38
  defaultTagText: StringConstructor;
39
+ rightIcon: {
40
+ type: import("vue").PropType<string>;
41
+ default: string;
42
+ };
35
43
  }>> & {
36
44
  onSelect?: ((...args: any[]) => any) | undefined;
37
45
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -41,6 +49,7 @@ export declare const AddressList: import("../utils").WithInstall<import("vue").D
41
49
  onEditDisabled?: ((...args: any[]) => any) | undefined;
42
50
  onSelectDisabled?: ((...args: any[]) => any) | undefined;
43
51
  }, {
52
+ rightIcon: string;
44
53
  switchable: boolean;
45
54
  list: import("./AddressListItem").AddressListAddress[];
46
55
  disabledList: import("./AddressListItem").AddressListAddress[];
@@ -1,5 +1,5 @@
1
1
  import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
2
- import { ref, watch, computed, Teleport, nextTick, onMounted, defineComponent } from "vue";
2
+ import { ref, watch, computed, Teleport, nextTick, onMounted, defineComponent, onDeactivated, onActivated } from "vue";
3
3
  import { extend, addUnit, inBrowser, numericProp, getScrollTop, getZIndexStyle, createNamespace, makeNumericProp } from "../utils/index.mjs";
4
4
  import { throttle } from "../lazyload/vue-lazyload/util.mjs";
5
5
  import { useEventListener, getScrollParent } from "@vant/use";
@@ -27,6 +27,7 @@ var stdin_default = defineComponent({
27
27
  slots,
28
28
  attrs
29
29
  }) {
30
+ let shouldReshow = false;
30
31
  const show = ref(false);
31
32
  const root = ref();
32
33
  const scrollParent = ref();
@@ -73,6 +74,18 @@ var stdin_default = defineComponent({
73
74
  target: scrollParent
74
75
  });
75
76
  onMounted(updateTarget);
77
+ onActivated(() => {
78
+ if (shouldReshow) {
79
+ show.value = true;
80
+ shouldReshow = false;
81
+ }
82
+ });
83
+ onDeactivated(() => {
84
+ if (show.value && props.teleport) {
85
+ show.value = false;
86
+ shouldReshow = true;
87
+ }
88
+ });
76
89
  watch(() => props.target, updateTarget);
77
90
  return () => {
78
91
  const Content = _createVNode("div", _mergeProps({
@@ -29,7 +29,7 @@ export declare const datePickerProps: {
29
29
  type: PropType<string[]>;
30
30
  default: () => never[];
31
31
  };
32
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
32
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
33
33
  formatter: {
34
34
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
35
35
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -80,7 +80,7 @@ declare const _default: import("vue").DefineComponent<{
80
80
  type: PropType<string[]>;
81
81
  default: () => never[];
82
82
  };
83
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
83
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
84
84
  formatter: {
85
85
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
86
86
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -129,7 +129,7 @@ declare const _default: import("vue").DefineComponent<{
129
129
  type: PropType<string[]>;
130
130
  default: () => never[];
131
131
  };
132
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
132
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
133
133
  formatter: {
134
134
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
135
135
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -28,7 +28,7 @@ export declare const DatePicker: import("../utils").WithInstall<import("vue").De
28
28
  type: import("vue").PropType<string[]>;
29
29
  default: () => never[];
30
30
  };
31
- filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[]) => import("..").PickerOption[]>;
31
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values?: string[] | undefined) => import("..").PickerOption[]>;
32
32
  formatter: {
33
33
  type: import("vue").PropType<(type: string, option: import("..").PickerOption) => import("..").PickerOption>;
34
34
  default: (type: string, option: import("..").PickerOption) => import("..").PickerOption;
@@ -77,7 +77,7 @@ export declare const DatePicker: import("../utils").WithInstall<import("vue").De
77
77
  type: import("vue").PropType<string[]>;
78
78
  default: () => never[];
79
79
  };
80
- filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[]) => import("..").PickerOption[]>;
80
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values?: string[] | undefined) => import("..").PickerOption[]>;
81
81
  formatter: {
82
82
  type: import("vue").PropType<(type: string, option: import("..").PickerOption) => import("..").PickerOption>;
83
83
  default: (type: string, option: import("..").PickerOption) => import("..").PickerOption;
@@ -1,6 +1,8 @@
1
+ import { type RequiredParams } from '../utils';
1
2
  import type { PropType } from 'vue';
2
3
  import type { PickerOption } from '../picker';
3
- type Filter = (columnType: string, options: PickerOption[]) => PickerOption[];
4
+ type Filter = (columnType: string, options: PickerOption[], values?: string[]) => PickerOption[];
5
+ export type TimeFilter = RequiredParams<Filter>;
4
6
  type Formatter = (type: string, option: PickerOption) => PickerOption;
5
7
  export declare const sharedProps: {
6
8
  loading: BooleanConstructor;
@@ -40,6 +42,6 @@ export declare const sharedProps: {
40
42
  export declare const pickerInheritKeys: ("title" | "readonly" | "loading" | "allowHtml" | "optionHeight" | "showToolbar" | "swipeDuration" | "visibleOptionNum" | "cancelButtonText" | "confirmButtonText")[];
41
43
  export declare function times<T>(n: number, iteratee: (index: number) => T): T[];
42
44
  export declare const getMonthEndDay: (year: number, month: number) => number;
43
- export declare const genOptions: <T extends string>(min: number, max: number, type: T, formatter: Formatter, filter?: Filter) => PickerOption[];
45
+ export declare const genOptions: <T extends string>(min: number, max: number, type: T, formatter: Formatter, filter?: Filter | TimeFilter, values?: string[]) => PickerOption[];
44
46
  export declare const formatValueRange: (values: string[], columns: PickerOption[][]) => string[];
45
47
  export {};
@@ -1,4 +1,9 @@
1
- import { extend, padZero, makeArrayProp, clamp } from "../utils/index.mjs";
1
+ import {
2
+ extend,
3
+ padZero,
4
+ makeArrayProp,
5
+ clamp
6
+ } from "../utils/index.mjs";
2
7
  import { pickerSharedProps } from "../picker/Picker.mjs";
3
8
  const sharedProps = extend({}, pickerSharedProps, {
4
9
  modelValue: makeArrayProp(),
@@ -21,7 +26,7 @@ function times(n, iteratee) {
21
26
  return result;
22
27
  }
23
28
  const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
24
- const genOptions = (min, max, type, formatter, filter) => {
29
+ const genOptions = (min, max, type, formatter, filter, values) => {
25
30
  const options = times(max - min + 1, (index) => {
26
31
  const value = padZero(min + index);
27
32
  return formatter(type, {
@@ -29,7 +34,7 @@ const genOptions = (min, max, type, formatter, filter) => {
29
34
  value
30
35
  });
31
36
  });
32
- return filter ? filter(type, options) : options;
37
+ return filter ? filter(type, options, values) : options;
33
38
  };
34
39
  const formatValueRange = (values, columns) => values.map((value, index) => {
35
40
  const column = columns[index];
@@ -2,6 +2,7 @@ import { createVNode as _createVNode } from "vue";
2
2
  import { ref, computed, defineComponent } from "vue";
3
3
  import { isDef, truthProp, numericProp, windowHeight, makeStringProp, makeNumericProp, createNamespace, HAPTICS_FEEDBACK } from "../utils/index.mjs";
4
4
  import { useId } from "../composables/use-id.mjs";
5
+ import { useExpose } from "../composables/use-expose.mjs";
5
6
  import { useRect, useChildren, useClickAway, useScrollParent, useEventListener } from "@vant/use";
6
7
  const [name, bem] = createNamespace("dropdown-menu");
7
8
  const dropdownMenuProps = {
@@ -37,11 +38,14 @@ var stdin_default = defineComponent({
37
38
  };
38
39
  }
39
40
  });
41
+ const close = () => {
42
+ children.forEach((item) => {
43
+ item.toggle(false);
44
+ });
45
+ };
40
46
  const onClickAway = () => {
41
47
  if (props.closeOnClickOutside) {
42
- children.forEach((item) => {
43
- item.toggle(false);
44
- });
48
+ close();
45
49
  }
46
50
  };
47
51
  const updateOffset = () => {
@@ -104,6 +108,9 @@ var stdin_default = defineComponent({
104
108
  "class": "van-ellipsis"
105
109
  }, [item.renderTitle()])])]);
106
110
  };
111
+ useExpose({
112
+ close
113
+ });
107
114
  linkChildren({
108
115
  id,
109
116
  props,
@@ -1,4 +1,4 @@
1
- import type { Ref } from 'vue';
1
+ import type { ComponentPublicInstance, Ref } from 'vue';
2
2
  import type { DropdownMenuProps } from './DropdownMenu';
3
3
  export type DropdownMenuDirection = 'up' | 'down';
4
4
  export type DropdownMenuProvide = {
@@ -7,6 +7,10 @@ export type DropdownMenuProvide = {
7
7
  offset: Ref<number>;
8
8
  updateOffset: () => void;
9
9
  };
10
+ export type DropdownMenuExpose = {
11
+ close: () => void;
12
+ };
13
+ export type DropdownMenuInstance = ComponentPublicInstance<DropdownMenuProps, DropdownMenuExpose>;
10
14
  export type DropdownMenuThemeVars = {
11
15
  dropdownMenuHeight?: string;
12
16
  dropdownMenuBackground?: string;
@@ -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,126 @@
1
+ import { createVNode as _createVNode } from "vue";
2
+ import { computed, defineComponent, ref, watch } from "vue";
3
+ import { addUnit, createNamespace, makeArrayProp, makeNumericProp, truthProp } from "../utils/index.mjs";
4
+ import { useWindowSize } 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
+ const closest = (arr, target) => arr.reduce((pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur);
60
+ let startY;
61
+ const touch = useTouch();
62
+ const onTouchstart = (e) => {
63
+ touch.start(e);
64
+ dragging.value = true;
65
+ startY = -height.value;
66
+ };
67
+ const onTouchmove = (e) => {
68
+ var _a;
69
+ touch.move(e);
70
+ const target = e.target;
71
+ if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
72
+ if (!props.contentDraggable)
73
+ return;
74
+ if (-startY < boundary.value.max) {
75
+ if (e.cancelable)
76
+ e.preventDefault();
77
+ e.stopPropagation();
78
+ } else if (!(contentRef.value.scrollTop <= 0 && touch.deltaY.value > 0)) {
79
+ return;
80
+ }
81
+ }
82
+ const moveY = touch.deltaY.value + startY;
83
+ height.value = -ease(moveY);
84
+ };
85
+ const onTouchend = () => {
86
+ dragging.value = false;
87
+ height.value = closest(anchors.value, height.value);
88
+ if (height.value !== -startY) {
89
+ emit("heightChange", {
90
+ height: height.value
91
+ });
92
+ }
93
+ };
94
+ watch(boundary, () => {
95
+ height.value = closest(anchors.value, height.value);
96
+ }, {
97
+ immediate: true
98
+ });
99
+ useLockScroll(rootRef, () => true);
100
+ return () => {
101
+ var _a;
102
+ return _createVNode("div", {
103
+ "class": [bem(), {
104
+ "van-safe-area-bottom": props.safeAreaInsetBottom
105
+ }],
106
+ "ref": rootRef,
107
+ "style": rootStyle.value,
108
+ "onTouchstartPassive": onTouchstart,
109
+ "onTouchmove": onTouchmove,
110
+ "onTouchend": onTouchend,
111
+ "onTouchcancel": onTouchend
112
+ }, [_createVNode("div", {
113
+ "class": bem("header")
114
+ }, [_createVNode("div", {
115
+ "class": bem("header-bar")
116
+ }, null)]), _createVNode("div", {
117
+ "class": bem("content"),
118
+ "ref": contentRef
119
+ }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
120
+ };
121
+ }
122
+ });
123
+ export {
124
+ stdin_default as default,
125
+ floatingPanelProps
126
+ };
@@ -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,60 @@
1
+ import { FloatingPanelProps } from './FloatingPanel';
2
+ export declare const FloatingPanel: import("../utils").WithInstall<import("vue").DefineComponent<{
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
+ }, () => 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<{
24
+ height: {
25
+ type: (NumberConstructor | StringConstructor)[];
26
+ default: number;
27
+ };
28
+ anchors: {
29
+ type: import("vue").PropType<number[]>;
30
+ default: () => never[];
31
+ };
32
+ duration: {
33
+ type: (NumberConstructor | StringConstructor)[];
34
+ default: number;
35
+ };
36
+ contentDraggable: {
37
+ type: BooleanConstructor;
38
+ default: true;
39
+ };
40
+ safeAreaInsetBottom: {
41
+ type: BooleanConstructor;
42
+ default: true;
43
+ };
44
+ }>> & {
45
+ onHeightChange?: ((...args: any[]) => any) | undefined;
46
+ "onUpdate:height"?: ((...args: any[]) => any) | undefined;
47
+ }, {
48
+ height: string | number;
49
+ safeAreaInsetBottom: boolean;
50
+ duration: string | number;
51
+ anchors: number[];
52
+ contentDraggable: boolean;
53
+ }, {}>>;
54
+ export default FloatingPanel;
55
+ export type { FloatingPanelProps };
56
+ declare module 'vue' {
57
+ interface GlobalComponents {
58
+ VanFloatingPanel: typeof FloatingPanel;
59
+ }
60
+ }
@@ -0,0 +1,8 @@
1
+ import { withInstall } from "../utils/index.mjs";
2
+ import _FloatingPanel from "./FloatingPanel.mjs";
3
+ const FloatingPanel = withInstall(_FloatingPanel);
4
+ var stdin_default = FloatingPanel;
5
+ export {
6
+ FloatingPanel,
7
+ stdin_default as default
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import "../../style/base.css";
2
+ import "../index.css";
package/es/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export * from "./dropdown-item";
35
35
  export * from "./dropdown-menu";
36
36
  export * from "./empty";
37
37
  export * from "./field";
38
+ export * from "./floating-panel";
38
39
  export * from "./form";
39
40
  export * from "./grid";
40
41
  export * from "./grid-item";
@@ -102,4 +103,4 @@ declare namespace _default {
102
103
  }
103
104
  export default _default;
104
105
  export function install(app: any): void;
105
- export const version: "4.4.1";
106
+ export const version: "4.5.0";