vant 4.0.0-beta.0 → 4.0.0-beta.1

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 (131) hide show
  1. package/README.md +13 -9
  2. package/changelog.generated.md +191 -150
  3. package/es/badge/Badge.mjs +1 -1
  4. package/es/calendar/Calendar.mjs +3 -4
  5. package/es/collapse/Collapse.d.ts +8 -1
  6. package/es/collapse/Collapse.mjs +28 -1
  7. package/es/collapse/index.d.ts +1 -1
  8. package/es/collapse-item/CollapseItem.mjs +3 -1
  9. package/es/composables/use-global-z-index.d.ts +4 -0
  10. package/es/composables/use-global-z-index.mjs +9 -0
  11. package/es/composables/use-height.d.ts +1 -1
  12. package/es/composables/use-height.mjs +8 -2
  13. package/es/composables/use-lock-scroll.mjs +3 -1
  14. package/es/composables/use-placeholder.mjs +1 -1
  15. package/es/config-provider/ConfigProvider.d.ts +13 -3
  16. package/es/config-provider/ConfigProvider.mjs +25 -9
  17. package/es/config-provider/index.d.ts +8 -2
  18. package/es/dialog/index.css +1 -1
  19. package/es/dropdown-menu/DropdownMenu.mjs +2 -1
  20. package/es/empty/Empty.d.ts +1 -1
  21. package/es/empty/Empty.mjs +281 -16
  22. package/es/field/Field.mjs +4 -1
  23. package/es/field/types.d.ts +1 -0
  24. package/es/field/utils.d.ts +1 -0
  25. package/es/field/utils.mjs +8 -2
  26. package/es/image-preview/ImagePreviewItem.mjs +1 -1
  27. package/es/image-preview/index.css +1 -1
  28. package/es/index-bar/IndexBar.mjs +3 -2
  29. package/es/index.d.ts +2 -1
  30. package/es/index.mjs +4 -1
  31. package/es/list/List.mjs +2 -1
  32. package/es/number-keyboard/NumberKeyboard.mjs +1 -2
  33. package/es/number-keyboard/NumberKeyboardKey.mjs +2 -2
  34. package/es/password-input/PasswordInput.mjs +1 -1
  35. package/es/picker/Picker.d.ts +2 -1
  36. package/es/picker/Picker.mjs +9 -2
  37. package/es/picker/PickerColumn.d.ts +2 -1
  38. package/es/picker/PickerColumn.mjs +5 -4
  39. package/es/picker/index.d.ts +2 -1
  40. package/es/popover/Popover.mjs +28 -27
  41. package/es/popup/Popup.mjs +6 -5
  42. package/es/popup/index.css +1 -1
  43. package/es/pull-refresh/PullRefresh.mjs +7 -3
  44. package/es/rate/Rate.mjs +1 -1
  45. package/es/search/index.css +1 -1
  46. package/es/slider/Slider.mjs +1 -1
  47. package/es/space/Space.d.ts +48 -0
  48. package/es/space/Space.mjs +87 -0
  49. package/es/space/index.css +1 -0
  50. package/es/space/index.d.ts +37 -0
  51. package/es/space/index.mjs +8 -0
  52. package/es/space/style/index.d.ts +1 -0
  53. package/es/space/style/index.mjs +2 -0
  54. package/es/stepper/Stepper.mjs +1 -1
  55. package/es/sticky/Sticky.mjs +2 -1
  56. package/es/swipe/Swipe.mjs +1 -1
  57. package/es/swipe-cell/SwipeCell.mjs +1 -1
  58. package/es/tabs/Tabs.mjs +12 -2
  59. package/es/tabs/TabsContent.mjs +4 -0
  60. package/es/vue-tsx-shim.d.ts +7 -0
  61. package/lib/badge/Badge.js +1 -1
  62. package/lib/calendar/Calendar.js +3 -4
  63. package/lib/collapse/Collapse.d.ts +8 -1
  64. package/lib/collapse/Collapse.js +28 -1
  65. package/lib/collapse/index.d.ts +1 -1
  66. package/lib/collapse-item/CollapseItem.js +3 -1
  67. package/lib/composables/use-global-z-index.d.ts +4 -0
  68. package/lib/composables/use-global-z-index.js +28 -0
  69. package/lib/composables/use-height.d.ts +1 -1
  70. package/lib/composables/use-height.js +8 -2
  71. package/lib/composables/use-lock-scroll.js +3 -1
  72. package/lib/composables/use-placeholder.js +1 -1
  73. package/lib/config-provider/ConfigProvider.d.ts +13 -3
  74. package/lib/config-provider/ConfigProvider.js +23 -7
  75. package/lib/config-provider/index.d.ts +8 -2
  76. package/lib/dialog/index.css +1 -1
  77. package/lib/dropdown-menu/DropdownMenu.js +2 -1
  78. package/lib/empty/Empty.d.ts +1 -1
  79. package/lib/empty/Empty.js +281 -16
  80. package/lib/field/Field.js +3 -0
  81. package/lib/field/types.d.ts +1 -0
  82. package/lib/field/utils.d.ts +1 -0
  83. package/lib/field/utils.js +8 -2
  84. package/lib/image-preview/ImagePreviewItem.js +1 -1
  85. package/lib/image-preview/index.css +1 -1
  86. package/lib/index-bar/IndexBar.js +3 -2
  87. package/lib/index.css +1 -1
  88. package/lib/index.d.ts +2 -1
  89. package/lib/index.js +4 -1
  90. package/lib/list/List.js +2 -1
  91. package/lib/number-keyboard/NumberKeyboard.js +1 -2
  92. package/lib/number-keyboard/NumberKeyboardKey.js +2 -2
  93. package/lib/password-input/PasswordInput.js +1 -1
  94. package/lib/picker/Picker.d.ts +2 -1
  95. package/lib/picker/Picker.js +9 -2
  96. package/lib/picker/PickerColumn.d.ts +2 -1
  97. package/lib/picker/PickerColumn.js +5 -4
  98. package/lib/picker/index.d.ts +2 -1
  99. package/lib/popover/Popover.js +27 -26
  100. package/lib/popup/Popup.js +6 -5
  101. package/lib/popup/index.css +1 -1
  102. package/lib/pull-refresh/PullRefresh.js +6 -2
  103. package/lib/rate/Rate.js +1 -1
  104. package/lib/search/index.css +1 -1
  105. package/lib/slider/Slider.js +1 -1
  106. package/lib/space/Space.d.ts +48 -0
  107. package/lib/space/Space.js +106 -0
  108. package/lib/space/index.css +1 -0
  109. package/lib/space/index.d.ts +37 -0
  110. package/lib/space/index.js +30 -0
  111. package/lib/space/style/index.d.ts +1 -0
  112. package/lib/space/style/index.js +2 -0
  113. package/lib/stepper/Stepper.js +1 -1
  114. package/lib/sticky/Sticky.js +2 -1
  115. package/lib/swipe/Swipe.js +1 -1
  116. package/lib/swipe-cell/SwipeCell.js +1 -1
  117. package/lib/tabs/Tabs.js +12 -2
  118. package/lib/tabs/TabsContent.js +4 -0
  119. package/lib/vant.cjs.js +1332 -1101
  120. package/lib/vant.es.js +1440 -1100
  121. package/lib/vant.js +1285 -1102
  122. package/lib/vant.min.js +1 -1
  123. package/lib/vue-tsx-shim.d.ts +7 -0
  124. package/{vetur → lib}/web-types.json +2304 -2203
  125. package/package.json +6 -11
  126. package/es/empty/Images.d.ts +0 -4
  127. package/es/empty/Images.mjs +0 -271
  128. package/lib/empty/Images.d.ts +0 -4
  129. package/lib/empty/Images.js +0 -290
  130. package/vetur/attributes.json +0 -3530
  131. package/vetur/tags.json +0 -1212
@@ -0,0 +1,87 @@
1
+ import { createVNode as _createVNode } from "vue";
2
+ import { computed, defineComponent, Fragment } from "vue";
3
+ import { createNamespace } from "../utils/index.mjs";
4
+ const [name, bem] = createNamespace("space");
5
+ const spaceProps = {
6
+ align: String,
7
+ direction: {
8
+ type: String,
9
+ default: "horizontal"
10
+ },
11
+ size: {
12
+ type: [Number, String, Array],
13
+ default: 8
14
+ },
15
+ wrap: Boolean,
16
+ fill: Boolean
17
+ };
18
+ function filterEmpty(children = []) {
19
+ const nodes = [];
20
+ children.forEach((child) => {
21
+ if (Array.isArray(child)) {
22
+ nodes.push(...child);
23
+ } else if (child.type === Fragment) {
24
+ nodes.push(...filterEmpty(child.children));
25
+ } else {
26
+ nodes.push(child);
27
+ }
28
+ });
29
+ return nodes.filter((c) => {
30
+ var _a;
31
+ return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
32
+ });
33
+ }
34
+ var stdin_default = defineComponent({
35
+ name,
36
+ props: spaceProps,
37
+ setup(props, {
38
+ slots
39
+ }) {
40
+ const mergedAlign = computed(() => {
41
+ var _a;
42
+ return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
43
+ });
44
+ const getMargin = (size) => {
45
+ if (typeof size === "number") {
46
+ return size + "px";
47
+ }
48
+ return size;
49
+ };
50
+ const getMarginStyle = (isLast) => {
51
+ const style = {};
52
+ const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
53
+ const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
54
+ if (isLast) {
55
+ return props.wrap ? {
56
+ marginBottom
57
+ } : {};
58
+ }
59
+ if (props.direction === "horizontal") {
60
+ style.marginRight = marginRight;
61
+ }
62
+ if (props.direction === "vertical" || props.wrap) {
63
+ style.marginBottom = marginBottom;
64
+ }
65
+ return style;
66
+ };
67
+ return () => {
68
+ var _a;
69
+ const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
70
+ return _createVNode("div", {
71
+ "class": [bem({
72
+ [props.direction]: props.direction,
73
+ [`align-${mergedAlign.value}`]: mergedAlign.value,
74
+ wrap: props.wrap,
75
+ fill: props.fill
76
+ })]
77
+ }, [children.map((c, i) => _createVNode("div", {
78
+ "key": `item-${i}`,
79
+ "class": `${name}-item`,
80
+ "style": getMarginStyle(i === children.length - 1)
81
+ }, [c]))]);
82
+ };
83
+ }
84
+ });
85
+ export {
86
+ stdin_default as default
87
+ };
@@ -0,0 +1 @@
1
+ .van-space{display:inline-flex}.van-space--horizontal .van-space-item{display:flex;align-items:center}.van-space--vertical{flex-direction:column}.van-space--align-baseline{align-items:baseline}.van-space--align-start{align-items:flex-start}.van-space--align-end{align-items:flex-end}.van-space--align-center{align-items:center}.van-space--wrap{flex-wrap:wrap}.van-space--fill{display:flex}
@@ -0,0 +1,37 @@
1
+ export declare const Space: import("../utils").WithInstall<import("vue").DefineComponent<{
2
+ align: import("vue").PropType<import("./Space").SpaceAlign>;
3
+ direction: {
4
+ type: import("vue").PropType<"vertical" | "horizontal">;
5
+ default: string;
6
+ };
7
+ size: {
8
+ type: import("vue").PropType<string | number | [import("./Space").SpaceSize, import("./Space").SpaceSize]>;
9
+ default: number;
10
+ };
11
+ wrap: BooleanConstructor;
12
+ fill: BooleanConstructor;
13
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
14
+ align: import("vue").PropType<import("./Space").SpaceAlign>;
15
+ direction: {
16
+ type: import("vue").PropType<"vertical" | "horizontal">;
17
+ default: string;
18
+ };
19
+ size: {
20
+ type: import("vue").PropType<string | number | [import("./Space").SpaceSize, import("./Space").SpaceSize]>;
21
+ default: number;
22
+ };
23
+ wrap: BooleanConstructor;
24
+ fill: BooleanConstructor;
25
+ }>>, {
26
+ fill: boolean;
27
+ size: string | number | [import("./Space").SpaceSize, import("./Space").SpaceSize];
28
+ wrap: boolean;
29
+ direction: "vertical" | "horizontal";
30
+ }>>;
31
+ export default Space;
32
+ export type { SpaceProps, SpaceSize, SpaceAlign } from './Space';
33
+ declare module 'vue' {
34
+ interface GlobalComponents {
35
+ VanSpace: typeof Space;
36
+ }
37
+ }
@@ -0,0 +1,8 @@
1
+ import { withInstall } from "../utils/index.mjs";
2
+ import _Space from "./Space.mjs";
3
+ const Space = withInstall(_Space);
4
+ var stdin_default = Space;
5
+ export {
6
+ Space,
7
+ stdin_default as default
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import "../../style/base.css";
2
+ import "../index.css";
@@ -180,7 +180,7 @@ var stdin_default = defineComponent({
180
180
  actionType = type;
181
181
  onChange();
182
182
  },
183
- onTouchstart: () => {
183
+ onTouchstartPassive: () => {
184
184
  actionType = type;
185
185
  onTouchStart();
186
186
  },
@@ -97,7 +97,8 @@ var stdin_default = defineComponent({
97
97
  };
98
98
  watch(() => state.fixed, (value) => emit("change", value));
99
99
  useEventListener("scroll", onScroll, {
100
- target: scrollParent
100
+ target: scrollParent,
101
+ passive: true
101
102
  });
102
103
  useVisibilityChange(root, onScroll);
103
104
  return () => {
@@ -339,7 +339,7 @@ var stdin_default = defineComponent({
339
339
  "class": bem("track", {
340
340
  vertical: props.vertical
341
341
  }),
342
- "onTouchstart": onTouchStart,
342
+ "onTouchstartPassive": onTouchStart,
343
343
  "onTouchmove": onTouchMove,
344
344
  "onTouchend": onTouchEnd,
345
345
  "onTouchcancel": onTouchEnd
@@ -144,7 +144,7 @@ var stdin_default = defineComponent({
144
144
  "ref": root,
145
145
  "class": bem(),
146
146
  "onClick": getClickHandler("cell", lockClick),
147
- "onTouchstart": onTouchStart,
147
+ "onTouchstartPassive": onTouchStart,
148
148
  "onTouchmove": onTouchMove,
149
149
  "onTouchend": onTouchEnd,
150
150
  "onTouchcancel": onTouchEnd
package/es/tabs/Tabs.mjs CHANGED
@@ -49,6 +49,7 @@ var stdin_default = defineComponent({
49
49
  const root = ref();
50
50
  const navRef = ref();
51
51
  const wrapRef = ref();
52
+ const contentRef = ref();
52
53
  const id = useId();
53
54
  const scroller = useScrollParent(root);
54
55
  const [titleRefs, setTitleRefs] = useRefs();
@@ -296,15 +297,23 @@ var stdin_default = defineComponent({
296
297
  });
297
298
  };
298
299
  const onRendered = (name2, title) => emit("rendered", name2, title);
300
+ const resize = () => {
301
+ setLine();
302
+ nextTick(() => {
303
+ var _a, _b;
304
+ return (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
305
+ });
306
+ };
299
307
  useExpose({
300
- resize: setLine,
308
+ resize,
301
309
  scrollTo
302
310
  });
303
311
  onActivated(setLine);
304
312
  onPopupReopen(setLine);
305
313
  onMountedOrActivated(init);
306
314
  useEventListener("scroll", onScroll, {
307
- target: scroller
315
+ target: scroller,
316
+ passive: true
308
317
  });
309
318
  linkChildren({
310
319
  id,
@@ -329,6 +338,7 @@ var stdin_default = defineComponent({
329
338
  return [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)];
330
339
  }
331
340
  }) : [renderHeader(), (_a = slots["nav-bottom"]) == null ? void 0 : _a.call(slots)], _createVNode(TabsContent, {
341
+ "ref": contentRef,
332
342
  "count": children.length,
333
343
  "inited": state.inited,
334
344
  "animated": props.animated,
@@ -2,6 +2,7 @@ import { createVNode as _createVNode } from "vue";
2
2
  import { ref, watch, onMounted, defineComponent } from "vue";
3
3
  import { numericProp, makeRequiredProp, createNamespace } from "../utils/index.mjs";
4
4
  import { Swipe } from "../swipe/index.mjs";
5
+ import { useExpose } from "../composables/use-expose.mjs";
5
6
  const [name, bem] = createNamespace("tabs");
6
7
  var stdin_default = defineComponent({
7
8
  name,
@@ -52,6 +53,9 @@ var stdin_default = defineComponent({
52
53
  onMounted(() => {
53
54
  swipeToCurrentTab(props.currentIndex);
54
55
  });
56
+ useExpose({
57
+ swipeRef
58
+ });
55
59
  return () => _createVNode("div", {
56
60
  "class": bem("content", {
57
61
  animated: props.animated || props.swipeable
@@ -12,5 +12,12 @@ declare module 'vue' {
12
12
  onTouchmove?: EventHandler;
13
13
  onTouchstart?: EventHandler;
14
14
  onTouchcancel?: EventHandler;
15
+ onTouchmovePassive?: EventHandler;
16
+ onTouchstartPassive?: EventHandler;
17
+ }
18
+
19
+ interface HTMLAttributes {
20
+ onTouchmovePassive?: EventHandler;
21
+ onTouchstartPassive?: EventHandler;
15
22
  }
16
23
  }
@@ -48,7 +48,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
48
48
  content,
49
49
  showZero
50
50
  } = props;
51
- return (0, import_utils.isDef)(content) && content !== "" && (showZero || content !== 0);
51
+ return (0, import_utils.isDef)(content) && content !== "" && (showZero || content !== 0 && content !== "0");
52
52
  };
53
53
  const renderContent = () => {
54
54
  const {
@@ -137,9 +137,6 @@ var stdin_default = (0, import_vue2.defineComponent)({
137
137
  const months = (0, import_vue2.computed)(() => {
138
138
  const months2 = [];
139
139
  const cursor = new Date(props.minDate);
140
- if (props.lazyRender && !props.show && props.poppable) {
141
- return months2;
142
- }
143
140
  cursor.setDate(1);
144
141
  do {
145
142
  months2.push(new Date(cursor));
@@ -217,7 +214,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
217
214
  }
218
215
  if (currentDate.value) {
219
216
  const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
220
- scrollToDate(targetDate);
217
+ if ((0, import_utils.isDate)(targetDate)) {
218
+ scrollToDate(targetDate);
219
+ }
221
220
  } else {
222
221
  (0, import_use.raf)(onScroll);
223
222
  }
@@ -1,9 +1,13 @@
1
- import { type PropType, type InjectionKey, type ExtractPropTypes } from 'vue';
1
+ import { type PropType, type InjectionKey, type ExtractPropTypes, type ComponentPublicInstance } from 'vue';
2
2
  import { type Numeric } from '../utils';
3
3
  export declare type CollapseProvide = {
4
4
  toggle: (name: Numeric, expanded: boolean) => void;
5
5
  isExpanded: (name: Numeric) => boolean;
6
6
  };
7
+ export declare type CollapseToggleAllOptions = boolean | {
8
+ expanded?: boolean;
9
+ skipDisabled?: boolean;
10
+ };
7
11
  export declare const COLLAPSE_KEY: InjectionKey<CollapseProvide>;
8
12
  declare const collapseProps: {
9
13
  border: {
@@ -17,6 +21,9 @@ declare const collapseProps: {
17
21
  };
18
22
  };
19
23
  export declare type CollapseProps = ExtractPropTypes<typeof collapseProps>;
24
+ export declare type CollapseInstance = ComponentPublicInstance<{
25
+ toggleAll: (options?: boolean | CollapseToggleAllOptions) => void;
26
+ }>;
20
27
  declare const _default: import("vue").DefineComponent<{
21
28
  border: {
22
29
  type: BooleanConstructor;
@@ -25,6 +25,7 @@ var import_vue = require("vue");
25
25
  var import_vue2 = require("vue");
26
26
  var import_utils = require("../utils");
27
27
  var import_use = require("@vant/use");
28
+ var import_use_expose = require("../composables/use-expose");
28
29
  const [name, bem] = (0, import_utils.createNamespace)("collapse");
29
30
  const COLLAPSE_KEY = Symbol(name);
30
31
  const collapseProps = {
@@ -55,7 +56,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
55
56
  slots
56
57
  }) {
57
58
  const {
58
- linkChildren
59
+ linkChildren,
60
+ children
59
61
  } = (0, import_use.useChildren)(COLLAPSE_KEY);
60
62
  const updateName = (name2) => {
61
63
  emit("change", name2);
@@ -74,6 +76,28 @@ var stdin_default = (0, import_vue2.defineComponent)({
74
76
  updateName(modelValue.filter((activeName) => activeName !== name2));
75
77
  }
76
78
  };
79
+ const toggleAll = (options = {}) => {
80
+ if (props.accordion) {
81
+ return;
82
+ }
83
+ if (typeof options === "boolean") {
84
+ options = {
85
+ expanded: options
86
+ };
87
+ }
88
+ const {
89
+ expanded,
90
+ skipDisabled
91
+ } = options;
92
+ const expandedChildren = children.filter((item) => {
93
+ if (item.disabled && skipDisabled) {
94
+ return item.expanded.value;
95
+ }
96
+ return expanded != null ? expanded : !item.expanded.value;
97
+ });
98
+ const names = expandedChildren.map((item) => item.itemName.value);
99
+ updateName(names);
100
+ };
77
101
  const isExpanded = (name2) => {
78
102
  const {
79
103
  accordion,
@@ -84,6 +108,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
84
108
  }
85
109
  return accordion ? modelValue === name2 : modelValue.includes(name2);
86
110
  };
111
+ (0, import_use_expose.useExpose)({
112
+ toggleAll
113
+ });
87
114
  linkChildren({
88
115
  toggle,
89
116
  isExpanded
@@ -27,7 +27,7 @@ export declare const Collapse: import("../utils").WithInstall<import("vue").Defi
27
27
  accordion: boolean;
28
28
  }>>;
29
29
  export default Collapse;
30
- export type { CollapseProps } from './Collapse';
30
+ export type { CollapseProps, CollapseInstance, CollapseToggleAllOptions, } from './Collapse';
31
31
  declare module 'vue' {
32
32
  interface GlobalComponents {
33
33
  VanCollapse: typeof Collapse;
@@ -142,7 +142,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
142
142
  }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[import_vue.vShow, show.value]]);
143
143
  });
144
144
  (0, import_use_expose.useExpose)({
145
- toggle
145
+ toggle,
146
+ expanded,
147
+ itemName: name2
146
148
  });
147
149
  return () => (0, import_vue.createVNode)("div", {
148
150
  "class": [bem({
@@ -0,0 +1,4 @@
1
+ /** the global z-index is automatically incremented after reading */
2
+ export declare const useGlobalZIndex: () => number;
3
+ /** reset the global z-index */
4
+ export declare const setGlobalZIndex: (val: number) => void;
@@ -0,0 +1,28 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ setGlobalZIndex: () => setGlobalZIndex,
21
+ useGlobalZIndex: () => useGlobalZIndex
22
+ });
23
+ module.exports = __toCommonJS(stdin_exports);
24
+ let globalZIndex = 2e3;
25
+ const useGlobalZIndex = () => ++globalZIndex;
26
+ const setGlobalZIndex = (val) => {
27
+ globalZIndex = val;
28
+ };
@@ -1,2 +1,2 @@
1
1
  import { Ref } from 'vue';
2
- export declare const useHeight: (element: Element | Ref<Element | undefined>) => Ref<number | undefined>;
2
+ export declare const useHeight: (element: Element | Ref<Element | undefined>, withSafeArea?: boolean) => Ref<number | undefined>;
@@ -22,14 +22,20 @@ __export(stdin_exports, {
22
22
  module.exports = __toCommonJS(stdin_exports);
23
23
  var import_use = require("@vant/use");
24
24
  var import_vue = require("vue");
25
- const useHeight = (element) => {
25
+ var import_on_popup_reopen = require("./on-popup-reopen");
26
+ const useHeight = (element, withSafeArea) => {
26
27
  const height = (0, import_vue.ref)();
27
28
  const setHeight = () => {
28
29
  height.value = (0, import_use.useRect)(element).height;
29
30
  };
30
31
  (0, import_vue.onMounted)(() => {
31
32
  (0, import_vue.nextTick)(setHeight);
32
- setTimeout(setHeight, 100);
33
+ if (withSafeArea) {
34
+ for (let i = 1; i <= 3; i++) {
35
+ setTimeout(setHeight, 100 * i);
36
+ }
37
+ }
33
38
  });
39
+ (0, import_on_popup_reopen.onPopupReopen)(() => (0, import_vue.nextTick)(setHeight));
34
40
  return height;
35
41
  };
@@ -28,9 +28,11 @@ let totalLockCount = 0;
28
28
  const BODY_LOCK_CLASS = "van-overflow-hidden";
29
29
  function useLockScroll(rootRef, shouldLock) {
30
30
  const touch = (0, import_use_touch.useTouch)();
31
+ const DIRECTION_UP = "01";
32
+ const DIRECTION_DOWN = "10";
31
33
  const onTouchMove = (event) => {
32
34
  touch.move(event);
33
- const direction = touch.deltaY.value > 0 ? "10" : "01";
35
+ const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
34
36
  const el = (0, import_use.getScrollParent)(event.target, rootRef.value);
35
37
  const { scrollHeight, offsetHeight, scrollTop } = el;
36
38
  let status = "11";
@@ -23,7 +23,7 @@ module.exports = __toCommonJS(stdin_exports);
23
23
  var import_vue = require("vue");
24
24
  var import_use_height = require("./use-height");
25
25
  function usePlaceholder(contentRef, bem) {
26
- const height = (0, import_use_height.useHeight)(contentRef);
26
+ const height = (0, import_use_height.useHeight)(contentRef, true);
27
27
  return (renderContent) => (0, import_vue.createVNode)("div", {
28
28
  "class": bem("placeholder"),
29
29
  "style": {
@@ -5,6 +5,7 @@ export declare type ConfigProviderProvide = {
5
5
  iconPrefix?: string;
6
6
  };
7
7
  export declare const CONFIG_PROVIDER_KEY: InjectionKey<ConfigProviderProvide>;
8
+ export declare type ThemeVars = PropType<Record<string, Numeric>>;
8
9
  declare const configProviderProps: {
9
10
  tag: {
10
11
  type: PropType<keyof HTMLElementTagNameMap>;
@@ -14,7 +15,10 @@ declare const configProviderProps: {
14
15
  type: PropType<ConfigProviderTheme>;
15
16
  default: ConfigProviderTheme;
16
17
  };
17
- themeVars: PropType<Record<string, Numeric>>;
18
+ zIndex: NumberConstructor;
19
+ themeVars: ThemeVars;
20
+ themeVarsDark: ThemeVars;
21
+ themeVarsLight: ThemeVars;
18
22
  iconPrefix: StringConstructor;
19
23
  };
20
24
  export declare type ConfigProviderProps = ExtractPropTypes<typeof configProviderProps>;
@@ -27,7 +31,10 @@ declare const _default: import("vue").DefineComponent<{
27
31
  type: PropType<ConfigProviderTheme>;
28
32
  default: ConfigProviderTheme;
29
33
  };
30
- themeVars: PropType<Record<string, Numeric>>;
34
+ zIndex: NumberConstructor;
35
+ themeVars: ThemeVars;
36
+ themeVarsDark: ThemeVars;
37
+ themeVarsLight: ThemeVars;
31
38
  iconPrefix: StringConstructor;
32
39
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
33
40
  tag: {
@@ -38,7 +45,10 @@ declare const _default: import("vue").DefineComponent<{
38
45
  type: PropType<ConfigProviderTheme>;
39
46
  default: ConfigProviderTheme;
40
47
  };
41
- themeVars: PropType<Record<string, Numeric>>;
48
+ zIndex: NumberConstructor;
49
+ themeVars: ThemeVars;
50
+ themeVarsDark: ThemeVars;
51
+ themeVarsLight: ThemeVars;
42
52
  iconPrefix: StringConstructor;
43
53
  }>>, {
44
54
  tag: keyof HTMLElementTagNameMap;
@@ -24,12 +24,16 @@ module.exports = __toCommonJS(stdin_exports);
24
24
  var import_vue = require("vue");
25
25
  var import_vue2 = require("vue");
26
26
  var import_utils = require("../utils");
27
+ var import_use_global_z_index = require("../composables/use-global-z-index");
27
28
  const [name, bem] = (0, import_utils.createNamespace)("config-provider");
28
29
  const CONFIG_PROVIDER_KEY = Symbol(name);
29
30
  const configProviderProps = {
30
31
  tag: (0, import_utils.makeStringProp)("div"),
31
32
  theme: (0, import_utils.makeStringProp)("light"),
33
+ zIndex: Number,
32
34
  themeVars: Object,
35
+ themeVarsDark: Object,
36
+ themeVarsLight: Object,
33
37
  iconPrefix: String
34
38
  };
35
39
  function mapThemeVarsToCSSVars(themeVars) {
@@ -45,20 +49,32 @@ var stdin_default = (0, import_vue2.defineComponent)({
45
49
  setup(props, {
46
50
  slots
47
51
  }) {
48
- const style = (0, import_vue2.computed)(() => {
49
- if (props.themeVars) {
50
- return mapThemeVarsToCSSVars(props.themeVars);
51
- }
52
- });
52
+ const style = (0, import_vue2.computed)(() => mapThemeVarsToCSSVars((0, import_utils.extend)({}, props.themeVars, props.theme === "dark" ? props.themeVarsDark : props.themeVarsLight)));
53
53
  if (import_utils.inBrowser) {
54
+ const addTheme = () => {
55
+ document.body.classList.add(`van-theme-${props.theme}`);
56
+ };
57
+ const removeTheme = (theme = props.theme) => {
58
+ document.body.classList.remove(`van-theme-${theme}`);
59
+ };
54
60
  (0, import_vue2.watch)(() => props.theme, (newVal, oldVal) => {
55
- document.body.classList.remove(`van-theme-${oldVal}`);
56
- document.body.classList.add(`van-theme-${newVal}`);
61
+ if (oldVal) {
62
+ removeTheme(oldVal);
63
+ }
64
+ addTheme();
57
65
  }, {
58
66
  immediate: true
59
67
  });
68
+ (0, import_vue2.onActivated)(addTheme);
69
+ (0, import_vue2.onDeactivated)(removeTheme);
70
+ (0, import_vue2.onBeforeUnmount)(removeTheme);
60
71
  }
61
72
  (0, import_vue2.provide)(CONFIG_PROVIDER_KEY, props);
73
+ (0, import_vue2.watchEffect)(() => {
74
+ if (props.zIndex !== void 0) {
75
+ (0, import_use_global_z_index.setGlobalZIndex)(props.zIndex);
76
+ }
77
+ });
62
78
  return () => (0, import_vue.createVNode)(props.tag, {
63
79
  "class": bem(),
64
80
  "style": style.value
@@ -7,7 +7,10 @@ export declare const ConfigProvider: import("../utils").WithInstall<import("vue"
7
7
  type: import("vue").PropType<import("./ConfigProvider").ConfigProviderTheme>;
8
8
  default: import("./ConfigProvider").ConfigProviderTheme;
9
9
  };
10
- themeVars: import("vue").PropType<Record<string, import("../utils").Numeric>>;
10
+ zIndex: NumberConstructor;
11
+ themeVars: import("./ConfigProvider").ThemeVars;
12
+ themeVarsDark: import("./ConfigProvider").ThemeVars;
13
+ themeVarsLight: import("./ConfigProvider").ThemeVars;
11
14
  iconPrefix: StringConstructor;
12
15
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
16
  tag: {
@@ -18,7 +21,10 @@ export declare const ConfigProvider: import("../utils").WithInstall<import("vue"
18
21
  type: import("vue").PropType<import("./ConfigProvider").ConfigProviderTheme>;
19
22
  default: import("./ConfigProvider").ConfigProviderTheme;
20
23
  };
21
- themeVars: import("vue").PropType<Record<string, import("../utils").Numeric>>;
24
+ zIndex: NumberConstructor;
25
+ themeVars: import("./ConfigProvider").ThemeVars;
26
+ themeVarsDark: import("./ConfigProvider").ThemeVars;
27
+ themeVarsLight: import("./ConfigProvider").ThemeVars;
22
28
  iconPrefix: StringConstructor;
23
29
  }>>, {
24
30
  tag: keyof HTMLElementTagNameMap;
@@ -1 +1 @@
1
- body{--van-dialog-width: 320px;--van-dialog-small-screen-width: 90%;--van-dialog-font-size: var(--van-font-size-lg);--van-dialog-transition: var(--van-duration-base);--van-dialog-radius: 16px;--van-dialog-background: var(--van-background-2);--van-dialog-header-font-weight: var(--van-font-bold);--van-dialog-header-line-height: 24px;--van-dialog-header-padding-top: 26px;--van-dialog-header-isolated-padding: var(--van-padding-lg) 0;--van-dialog-message-padding: var(--van-padding-lg);--van-dialog-message-font-size: var(--van-font-size-md);--van-dialog-message-line-height: var(--van-line-height-md);--van-dialog-message-max-height: 60vh;--van-dialog-has-title-message-text-color: var(--van-gray-7);--van-dialog-has-title-message-padding-top: var(--van-padding-xs);--van-dialog-button-height: 48px;--van-dialog-round-button-height: 36px;--van-dialog-confirm-button-text-color: var(--van-primary-color)}.van-dialog{top:45%;left:50%;width:var(--van-dialog-width);overflow:hidden;font-size:var(--van-dialog-font-size);background:var(--van-dialog-background);border-radius:var(--van-dialog-radius);-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:var(--van-dialog-transition);transition-property:transform,opacity}@media (max-width: 321px){.van-dialog{width:var(--van-dialog-small-screen-width)}}.van-dialog__header{color:var(--van-text-color);padding-top:var(--van-dialog-header-padding-top);font-weight:var(--van-dialog-header-font-weight);line-height:var(--van-dialog-header-line-height);text-align:center}.van-dialog__header--isolated{padding:var(--van-dialog-header-isolated-padding)}.van-dialog__content--isolated{display:flex;align-items:center;min-height:104px}.van-dialog__message{color:var(--van-text-color);flex:1;max-height:var(--van-dialog-message-max-height);padding:26px var(--van-dialog-message-padding);overflow-y:auto;font-size:var(--van-dialog-message-font-size);line-height:var(--van-dialog-message-line-height);white-space:pre-wrap;text-align:center;word-wrap:break-word;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:var(--van-dialog-has-title-message-padding-top);color:var(--van-dialog-has-title-message-text-color)}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-dialog__confirm,.van-dialog__cancel{flex:1;height:var(--van-dialog-button-height);margin:0;border:0}.van-dialog__confirm,.van-dialog__confirm:active{color:var(--van-dialog-confirm-button-text-color)}.van-dialog--round-button .van-dialog__footer{position:relative;height:auto;padding:var(--van-padding-xs) var(--van-padding-lg) var(--van-padding-md)}.van-dialog--round-button .van-dialog__message{padding-bottom:var(--van-padding-md);color:var(--van-text-color)}.van-dialog--round-button .van-dialog__confirm,.van-dialog--round-button .van-dialog__cancel{height:var(--van-dialog-round-button-height)}.van-dialog--round-button .van-dialog__confirm{color:var(--van-white)}.van-dialog-bounce-enter-from{transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{transform:translate3d(-50%,-50%,0) scale(.9);opacity:0}
1
+ body{--van-dialog-width: 320px;--van-dialog-small-screen-width: 90%;--van-dialog-font-size: var(--van-font-size-lg);--van-dialog-transition: var(--van-duration-base);--van-dialog-radius: 16px;--van-dialog-background: var(--van-background-2);--van-dialog-header-font-weight: var(--van-font-bold);--van-dialog-header-line-height: 24px;--van-dialog-header-padding-top: 26px;--van-dialog-header-isolated-padding: var(--van-padding-lg) 0;--van-dialog-message-padding: var(--van-padding-lg);--van-dialog-message-font-size: var(--van-font-size-md);--van-dialog-message-line-height: var(--van-line-height-md);--van-dialog-message-max-height: 60vh;--van-dialog-has-title-message-text-color: var(--van-gray-7);--van-dialog-has-title-message-padding-top: var(--van-padding-xs);--van-dialog-button-height: 48px;--van-dialog-round-button-height: 36px;--van-dialog-confirm-button-text-color: var(--van-primary-color)}.van-dialog{top:45%;width:var(--van-dialog-width);overflow:hidden;font-size:var(--van-dialog-font-size);background:var(--van-dialog-background);border-radius:var(--van-dialog-radius);-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:var(--van-dialog-transition);transition-property:transform,opacity}@media (max-width: 321px){.van-dialog{width:var(--van-dialog-small-screen-width)}}.van-dialog__header{color:var(--van-text-color);padding-top:var(--van-dialog-header-padding-top);font-weight:var(--van-dialog-header-font-weight);line-height:var(--van-dialog-header-line-height);text-align:center}.van-dialog__header--isolated{padding:var(--van-dialog-header-isolated-padding)}.van-dialog__content--isolated{display:flex;align-items:center;min-height:104px}.van-dialog__message{color:var(--van-text-color);flex:1;max-height:var(--van-dialog-message-max-height);padding:26px var(--van-dialog-message-padding);overflow-y:auto;font-size:var(--van-dialog-message-font-size);line-height:var(--van-dialog-message-line-height);white-space:pre-wrap;text-align:center;word-wrap:break-word;-webkit-overflow-scrolling:touch}.van-dialog__message--has-title{padding-top:var(--van-dialog-has-title-message-padding-top);color:var(--van-dialog-has-title-message-text-color)}.van-dialog__message--left{text-align:left}.van-dialog__message--right{text-align:right}.van-dialog__footer{display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.van-dialog__confirm,.van-dialog__cancel{flex:1;height:var(--van-dialog-button-height);margin:0;border:0}.van-dialog__confirm,.van-dialog__confirm:active{color:var(--van-dialog-confirm-button-text-color)}.van-dialog--round-button .van-dialog__footer{position:relative;height:auto;padding:var(--van-padding-xs) var(--van-padding-lg) var(--van-padding-md)}.van-dialog--round-button .van-dialog__message{padding-bottom:var(--van-padding-md);color:var(--van-text-color)}.van-dialog--round-button .van-dialog__confirm,.van-dialog--round-button .van-dialog__cancel{height:var(--van-dialog-round-button-height)}.van-dialog--round-button .van-dialog__confirm{color:var(--van-white)}.van-dialog-bounce-enter-from{transform:translate3d(-50%,-50%,0) scale(.7);opacity:0}.van-dialog-bounce-leave-active{transform:translate3d(-50%,-50%,0) scale(.9);opacity:0}
@@ -135,7 +135,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
135
135
  });
136
136
  (0, import_use.useClickAway)(root, onClickAway);
137
137
  (0, import_use.useEventListener)("scroll", onScroll, {
138
- target: scrollParent
138
+ target: scrollParent,
139
+ passive: true
139
140
  });
140
141
  return () => {
141
142
  var _a;
@@ -1,4 +1,4 @@
1
- import { PropType, type ExtractPropTypes } from 'vue';
1
+ import { type PropType, type ExtractPropTypes } from 'vue';
2
2
  import { Numeric } from '../utils';
3
3
  declare const emptyProps: {
4
4
  image: {