vant 3.2.7 → 3.3.2

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 (191) hide show
  1. package/es/address-edit/AddressEdit.js +154 -180
  2. package/es/address-edit/AddressEditDetail.d.ts +10 -9
  3. package/es/address-edit/AddressEditDetail.js +6 -6
  4. package/es/button/Button.js +2 -2
  5. package/es/calendar/Calendar.js +8 -14
  6. package/es/calendar/CalendarHeader.js +1 -3
  7. package/es/calendar/CalendarMonth.js +11 -10
  8. package/es/calendar/types.d.ts +1 -1
  9. package/es/cascader/Cascader.js +17 -5
  10. package/es/checkbox/Checker.js +1 -1
  11. package/es/checkbox/types.d.ts +2 -6
  12. package/es/composables/use-id.d.ts +1 -0
  13. package/es/composables/use-id.js +14 -0
  14. package/es/composables/use-route.d.ts +1 -1
  15. package/es/composables/use-route.js +4 -4
  16. package/es/count-down/CountDown.js +1 -0
  17. package/es/coupon-list/CouponList.js +40 -24
  18. package/es/coupon-list/index.css +1 -1
  19. package/es/coupon-list/index.less +0 -5
  20. package/es/dropdown-item/DropdownItem.js +7 -2
  21. package/es/dropdown-item/types.d.ts +2 -6
  22. package/es/dropdown-menu/DropdownMenu.js +7 -3
  23. package/es/dropdown-menu/types.d.ts +1 -0
  24. package/es/empty/Network.js +22 -34
  25. package/es/field/Field.d.ts +1 -1
  26. package/es/field/Field.js +13 -5
  27. package/es/field/index.d.ts +2 -2
  28. package/es/field/types.d.ts +7 -6
  29. package/es/form/Form.js +2 -2
  30. package/es/image/Image.js +4 -9
  31. package/es/image-preview/ImagePreview.js +3 -4
  32. package/es/index.d.ts +1 -1
  33. package/es/index.js +1 -1
  34. package/es/lazyload/index.d.ts +1 -1
  35. package/es/lazyload/index.js +1 -1
  36. package/es/lazyload/vue-lazyload/index.d.ts +55 -0
  37. package/es/lazyload/vue-lazyload/index.js +46 -0
  38. package/es/lazyload/vue-lazyload/lazy-component.js +53 -0
  39. package/es/lazyload/vue-lazyload/lazy-container.js +98 -0
  40. package/es/lazyload/vue-lazyload/lazy-image.js +115 -0
  41. package/es/lazyload/vue-lazyload/lazy.js +507 -0
  42. package/es/lazyload/vue-lazyload/listener.js +241 -0
  43. package/es/lazyload/vue-lazyload/util.js +183 -0
  44. package/es/list/List.js +3 -1
  45. package/es/nav-bar/NavBar.d.ts +1 -1
  46. package/es/nav-bar/index.d.ts +1 -1
  47. package/es/number-keyboard/NumberKeyboardKey.js +4 -4
  48. package/es/pagination/Pagination.js +67 -49
  49. package/es/pagination/index.css +1 -1
  50. package/es/pagination/index.less +32 -31
  51. package/es/password-input/PasswordInput.d.ts +21 -1
  52. package/es/password-input/PasswordInput.js +10 -9
  53. package/es/password-input/index.d.ts +2 -1
  54. package/es/popover/Popover.js +2 -0
  55. package/es/popup/Popup.d.ts +1 -2
  56. package/es/popup/Popup.js +2 -5
  57. package/es/popup/index.d.ts +1 -2
  58. package/es/progress/Progress.js +2 -2
  59. package/es/rate/Rate.js +5 -3
  60. package/es/search/Search.js +8 -2
  61. package/es/sidebar/Sidebar.js +1 -0
  62. package/es/sidebar-item/SidebarItem.js +4 -1
  63. package/es/slider/Slider.js +5 -3
  64. package/es/stepper/Stepper.js +11 -8
  65. package/es/submit-bar/SubmitBar.d.ts +4 -3
  66. package/es/submit-bar/index.d.ts +3 -2
  67. package/es/swipe/Swipe.js +11 -6
  68. package/es/swipe/types.d.ts +1 -3
  69. package/es/switch/Switch.js +1 -0
  70. package/es/switch/index.css +1 -1
  71. package/es/switch/index.less +2 -0
  72. package/es/tab/Tab.js +18 -5
  73. package/es/tab/index.css +1 -1
  74. package/es/tab/index.less +1 -1
  75. package/es/tabbar/Tabbar.d.ts +1 -1
  76. package/es/tabbar/Tabbar.js +10 -10
  77. package/es/tabbar-item/TabbarItem.js +16 -7
  78. package/es/tabs/Tabs.js +17 -11
  79. package/es/tabs/TabsTitle.d.ts +6 -0
  80. package/es/tabs/TabsTitle.js +7 -1
  81. package/es/tabs/types.d.ts +1 -0
  82. package/es/uploader/UploaderPreviewItem.js +4 -1
  83. package/es/uploader/utils.d.ts +2 -2
  84. package/es/uploader/utils.js +2 -2
  85. package/es/utils/dom.d.ts +1 -0
  86. package/es/utils/dom.js +6 -2
  87. package/es/utils/format.js +6 -5
  88. package/es/vue-tsx-shim.d.ts +1 -0
  89. package/lib/address-edit/AddressEdit.js +155 -180
  90. package/lib/address-edit/AddressEditDetail.d.ts +10 -9
  91. package/lib/address-edit/AddressEditDetail.js +6 -6
  92. package/lib/button/Button.js +1 -1
  93. package/lib/calendar/Calendar.js +8 -14
  94. package/lib/calendar/CalendarHeader.js +1 -3
  95. package/lib/calendar/CalendarMonth.js +11 -10
  96. package/lib/calendar/types.d.ts +1 -1
  97. package/lib/cascader/Cascader.js +17 -5
  98. package/lib/checkbox/Checker.js +1 -1
  99. package/lib/checkbox/types.d.ts +2 -6
  100. package/lib/composables/use-id.d.ts +1 -0
  101. package/lib/composables/use-id.js +21 -0
  102. package/lib/composables/use-route.d.ts +1 -1
  103. package/lib/composables/use-route.js +4 -4
  104. package/lib/count-down/CountDown.js +1 -0
  105. package/lib/coupon-list/CouponList.js +39 -22
  106. package/lib/coupon-list/index.css +1 -1
  107. package/lib/coupon-list/index.less +0 -5
  108. package/lib/dropdown-item/DropdownItem.js +7 -2
  109. package/lib/dropdown-item/types.d.ts +2 -6
  110. package/lib/dropdown-menu/DropdownMenu.js +7 -2
  111. package/lib/dropdown-menu/types.d.ts +1 -0
  112. package/lib/empty/Network.js +22 -34
  113. package/lib/field/Field.d.ts +1 -1
  114. package/lib/field/Field.js +14 -5
  115. package/lib/field/index.d.ts +2 -2
  116. package/lib/field/types.d.ts +7 -6
  117. package/lib/form/Form.js +1 -1
  118. package/lib/image/Image.js +4 -9
  119. package/lib/image-preview/ImagePreview.js +1 -2
  120. package/lib/index.css +1 -1
  121. package/lib/index.d.ts +1 -1
  122. package/lib/index.js +1 -1
  123. package/lib/lazyload/index.d.ts +1 -1
  124. package/lib/lazyload/index.js +3 -3
  125. package/lib/lazyload/vue-lazyload/index.d.ts +55 -0
  126. package/lib/lazyload/vue-lazyload/index.js +58 -0
  127. package/lib/lazyload/vue-lazyload/lazy-component.js +62 -0
  128. package/lib/lazyload/vue-lazyload/lazy-container.js +106 -0
  129. package/lib/lazyload/vue-lazyload/lazy-image.js +125 -0
  130. package/lib/lazyload/vue-lazyload/lazy.js +520 -0
  131. package/lib/lazyload/vue-lazyload/listener.js +251 -0
  132. package/lib/lazyload/vue-lazyload/util.js +213 -0
  133. package/lib/list/List.js +3 -1
  134. package/lib/nav-bar/NavBar.d.ts +1 -1
  135. package/lib/nav-bar/index.d.ts +1 -1
  136. package/lib/number-keyboard/NumberKeyboardKey.js +3 -3
  137. package/lib/pagination/Pagination.js +65 -47
  138. package/lib/pagination/index.css +1 -1
  139. package/lib/pagination/index.less +32 -31
  140. package/lib/password-input/PasswordInput.d.ts +21 -1
  141. package/lib/password-input/PasswordInput.js +10 -9
  142. package/lib/password-input/index.d.ts +2 -1
  143. package/lib/popover/Popover.js +2 -0
  144. package/lib/popup/Popup.d.ts +1 -2
  145. package/lib/popup/Popup.js +2 -5
  146. package/lib/popup/index.d.ts +1 -2
  147. package/lib/progress/Progress.js +2 -2
  148. package/lib/rate/Rate.js +5 -3
  149. package/lib/search/Search.js +9 -2
  150. package/lib/sidebar/Sidebar.js +1 -0
  151. package/lib/sidebar-item/SidebarItem.js +4 -1
  152. package/lib/slider/Slider.js +5 -3
  153. package/lib/stepper/Stepper.js +11 -8
  154. package/lib/submit-bar/SubmitBar.d.ts +4 -3
  155. package/lib/submit-bar/index.d.ts +3 -2
  156. package/lib/swipe/Swipe.js +9 -4
  157. package/lib/swipe/types.d.ts +1 -3
  158. package/lib/switch/Switch.js +1 -0
  159. package/lib/switch/index.css +1 -1
  160. package/lib/switch/index.less +2 -0
  161. package/lib/tab/Tab.js +20 -5
  162. package/lib/tab/index.css +1 -1
  163. package/lib/tab/index.less +1 -1
  164. package/lib/tabbar/Tabbar.d.ts +1 -1
  165. package/lib/tabbar/Tabbar.js +10 -10
  166. package/lib/tabbar-item/TabbarItem.js +16 -7
  167. package/lib/tabs/Tabs.js +16 -9
  168. package/lib/tabs/TabsTitle.d.ts +6 -0
  169. package/lib/tabs/TabsTitle.js +7 -1
  170. package/lib/tabs/types.d.ts +1 -0
  171. package/lib/uploader/UploaderPreviewItem.js +3 -0
  172. package/lib/uploader/utils.d.ts +2 -2
  173. package/lib/uploader/utils.js +3 -2
  174. package/lib/utils/dom.d.ts +1 -0
  175. package/lib/utils/dom.js +9 -2
  176. package/lib/utils/format.js +7 -5
  177. package/lib/vant.cjs.js +14407 -0
  178. package/lib/vant.cjs.min.js +1 -0
  179. package/lib/vant.es.js +1217 -2203
  180. package/lib/vant.es.min.js +1217 -2203
  181. package/lib/vant.js +1349 -1254
  182. package/lib/vant.min.js +1 -1
  183. package/lib/vue-tsx-shim.d.ts +1 -0
  184. package/package.json +27 -13
  185. package/vetur/attributes.json +115 -115
  186. package/vetur/tags.json +35 -35
  187. package/vetur/web-types.json +370 -366
  188. package/es/composables/use-link-field.d.ts +0 -0
  189. package/es/composables/use-link-field.js +0 -0
  190. package/lib/composables/use-link-field.d.ts +0 -0
  191. package/lib/composables/use-link-field.js +0 -1
@@ -27,7 +27,7 @@ declare const tabbarProps: {
27
27
  export declare type TabbarProps = ExtractPropTypes<typeof tabbarProps>;
28
28
  export declare type TabbarProvide = {
29
29
  props: TabbarProps;
30
- setActive: (active: number | string) => void;
30
+ setActive: (active: number | string, afterChange: () => void) => void;
31
31
  };
32
32
  export declare const TABBAR_KEY: InjectionKey<TabbarProvide>;
33
33
  declare const _default: import("vue").DefineComponent<{
@@ -62,6 +62,7 @@ var _default = (0, _vue.defineComponent)({
62
62
  } = props;
63
63
  return (0, _vue.createVNode)("div", {
64
64
  "ref": root,
65
+ "role": "tablist",
65
66
  "style": (0, _utils.getZIndexStyle)(zIndex),
66
67
  "class": [bem({
67
68
  fixed
@@ -72,18 +73,17 @@ var _default = (0, _vue.defineComponent)({
72
73
  }, [slots.default == null ? void 0 : slots.default()]);
73
74
  };
74
75
 
75
- var setActive = active => {
76
- if (active !== props.modelValue) {
77
- (0, _utils.callInterceptor)(props.beforeChange, {
78
- args: [active],
76
+ var setActive = (active, afterChange) => {
77
+ (0, _utils.callInterceptor)(props.beforeChange, {
78
+ args: [active],
79
79
 
80
- done() {
81
- emit('update:modelValue', active);
82
- emit('change', active);
83
- }
80
+ done() {
81
+ emit('update:modelValue', active);
82
+ emit('change', active);
83
+ afterChange();
84
+ }
84
85
 
85
- });
86
- }
86
+ });
87
87
  };
88
88
 
89
89
  linkChildren({
@@ -55,6 +55,8 @@ var _default = (0, _vue.defineComponent)({
55
55
  }
56
56
 
57
57
  var active = (0, _vue.computed)(() => {
58
+ var _props$name;
59
+
58
60
  var {
59
61
  route,
60
62
  modelValue
@@ -70,20 +72,24 @@ var _default = (0, _vue.defineComponent)({
70
72
  var config = (0, _utils.isObject)(to) ? to : {
71
73
  path: to
72
74
  };
73
- var pathMatched = 'path' in config && config.path === $route.path;
74
- var nameMatched = 'name' in config && config.name === $route.name;
75
- return pathMatched || nameMatched;
75
+ return !!$route.matched.find(val => {
76
+ var pathMatched = 'path' in config && config.path === val.path;
77
+ var nameMatched = 'name' in config && config.name === val.name;
78
+ return pathMatched || nameMatched;
79
+ });
76
80
  }
77
81
 
78
- return (props.name || index.value) === modelValue;
82
+ return ((_props$name = props.name) != null ? _props$name : index.value) === modelValue;
79
83
  });
80
84
 
81
85
  var onClick = event => {
82
- var _props$name;
86
+ if (!active.value) {
87
+ var _props$name2;
88
+
89
+ parent.setActive((_props$name2 = props.name) != null ? _props$name2 : index.value, route);
90
+ }
83
91
 
84
- parent.setActive((_props$name = props.name) != null ? _props$name : index.value);
85
92
  emit('click', event);
86
- route();
87
93
  };
88
94
 
89
95
  var renderIcon = () => {
@@ -112,12 +118,15 @@ var _default = (0, _vue.defineComponent)({
112
118
  } = parent.props;
113
119
  var color = active.value ? activeColor : inactiveColor;
114
120
  return (0, _vue.createVNode)("div", {
121
+ "role": "tab",
115
122
  "class": bem({
116
123
  active: active.value
117
124
  }),
118
125
  "style": {
119
126
  color
120
127
  },
128
+ "tabindex": 0,
129
+ "aria-selected": active.value,
121
130
  "onClick": onClick
122
131
  }, [(0, _vue.createVNode)(_badge.Badge, {
123
132
  "dot": dot,
package/lib/tabs/Tabs.js CHANGED
@@ -11,6 +11,8 @@ var _utils2 = require("./utils");
11
11
 
12
12
  var _use = require("@vant/use");
13
13
 
14
+ var _useId = require("../composables/use-id");
15
+
14
16
  var _useRoute = require("../composables/use-route");
15
17
 
16
18
  var _useRefs = require("../composables/use-refs");
@@ -86,7 +88,7 @@ var _default = (0, _vue.defineComponent)({
86
88
  var root = (0, _vue.ref)();
87
89
  var navRef = (0, _vue.ref)();
88
90
  var wrapRef = (0, _vue.ref)();
89
- var windowSize = (0, _use.useWindowSize)();
91
+ var id = (0, _useId.useId)();
90
92
  var scroller = (0, _use.useScrollParent)(root);
91
93
  var [titleRefs, setTitleRefs] = (0, _useRefs.useRefs)();
92
94
  var {
@@ -242,12 +244,6 @@ var _default = (0, _vue.defineComponent)({
242
244
  disabled
243
245
  } = children[index];
244
246
  var name = getTabName(children[index], index);
245
- emit('click-tab', {
246
- name,
247
- title,
248
- event,
249
- disabled
250
- });
251
247
 
252
248
  if (disabled) {
253
249
  // @deprecated
@@ -266,6 +262,13 @@ var _default = (0, _vue.defineComponent)({
266
262
  emit('click', name, title);
267
263
  (0, _useRoute.route)(item);
268
264
  }
265
+
266
+ emit('click-tab', {
267
+ name,
268
+ title,
269
+ event,
270
+ disabled
271
+ });
269
272
  };
270
273
 
271
274
  var onStickyScroll = params => {
@@ -302,12 +305,14 @@ var _default = (0, _vue.defineComponent)({
302
305
  };
303
306
 
304
307
  var renderNav = () => children.map((item, index) => (0, _vue.createVNode)(_TabsTitle.default, (0, _vue.mergeProps)({
308
+ "id": id + "-" + index,
305
309
  "ref": setTitleRefs(index),
306
310
  "type": props.type,
307
311
  "color": props.color,
308
312
  "style": item.titleStyle,
309
313
  "class": item.titleClass,
310
314
  "isActive": index === state.currentIndex,
315
+ "controls": item.id,
311
316
  "scrollable": scrollable.value,
312
317
  "renderTitle": item.$slots.title,
313
318
  "activeColor": props.titleActiveColor,
@@ -335,14 +340,15 @@ var _default = (0, _vue.defineComponent)({
335
340
  "class": bem('nav', [type, {
336
341
  complete: scrollable.value
337
342
  }]),
338
- "style": navStyle.value
343
+ "style": navStyle.value,
344
+ "aria-orientation": "horizontal"
339
345
  }, [(_slots$navLeft = slots['nav-left']) == null ? void 0 : _slots$navLeft.call(slots), renderNav(), type === 'line' && (0, _vue.createVNode)("div", {
340
346
  "class": bem('line'),
341
347
  "style": state.lineStyle
342
348
  }, null), (_slots$navRight = slots['nav-right']) == null ? void 0 : _slots$navRight.call(slots)])]);
343
349
  };
344
350
 
345
- (0, _vue.watch)([() => props.color, windowSize.width], setLine);
351
+ (0, _vue.watch)([() => props.color, _utils.windowWidth], setLine);
346
352
  (0, _vue.watch)(() => props.active, value => {
347
353
  if (value !== currentName.value) {
348
354
  setCurrentIndexByName(value);
@@ -392,6 +398,7 @@ var _default = (0, _vue.defineComponent)({
392
398
  target: scroller
393
399
  });
394
400
  linkChildren({
401
+ id,
395
402
  props,
396
403
  setLine,
397
404
  onRendered,
@@ -1,4 +1,5 @@
1
1
  declare const _default: import("vue").DefineComponent<{
2
+ id: StringConstructor;
2
3
  dot: BooleanConstructor;
3
4
  type: StringConstructor;
4
5
  color: StringConstructor;
@@ -6,6 +7,7 @@ declare const _default: import("vue").DefineComponent<{
6
7
  badge: (NumberConstructor | StringConstructor)[];
7
8
  isActive: BooleanConstructor;
8
9
  disabled: BooleanConstructor;
10
+ controls: StringConstructor;
9
11
  scrollable: BooleanConstructor;
10
12
  activeColor: StringConstructor;
11
13
  renderTitle: FunctionConstructor;
@@ -15,6 +17,7 @@ declare const _default: import("vue").DefineComponent<{
15
17
  default: true;
16
18
  };
17
19
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
20
+ id?: unknown;
18
21
  dot?: unknown;
19
22
  type?: unknown;
20
23
  color?: unknown;
@@ -22,6 +25,7 @@ declare const _default: import("vue").DefineComponent<{
22
25
  badge?: unknown;
23
26
  isActive?: unknown;
24
27
  disabled?: unknown;
28
+ controls?: unknown;
25
29
  scrollable?: unknown;
26
30
  activeColor?: unknown;
27
31
  renderTitle?: unknown;
@@ -38,6 +42,8 @@ declare const _default: import("vue").DefineComponent<{
38
42
  badge?: string | number | undefined;
39
43
  title?: string | undefined;
40
44
  color?: string | undefined;
45
+ controls?: string | undefined;
46
+ id?: string | undefined;
41
47
  activeColor?: string | undefined;
42
48
  inactiveColor?: string | undefined;
43
49
  renderTitle?: Function | undefined;
@@ -14,6 +14,7 @@ var [name, bem] = (0, _utils.createNamespace)('tab');
14
14
  var _default = (0, _vue.defineComponent)({
15
15
  name,
16
16
  props: {
17
+ id: String,
17
18
  dot: Boolean,
18
19
  type: String,
19
20
  color: String,
@@ -21,6 +22,7 @@ var _default = (0, _vue.defineComponent)({
21
22
  badge: _utils.numericProp,
22
23
  isActive: Boolean,
23
24
  disabled: Boolean,
25
+ controls: String,
24
26
  scrollable: Boolean,
25
27
  activeColor: String,
26
28
  renderTitle: Function,
@@ -83,13 +85,17 @@ var _default = (0, _vue.defineComponent)({
83
85
  };
84
86
 
85
87
  return () => (0, _vue.createVNode)("div", {
88
+ "id": props.id,
86
89
  "role": "tab",
87
90
  "class": [bem({
88
91
  active: props.isActive,
89
92
  disabled: props.disabled
90
93
  })],
91
94
  "style": style.value,
92
- "aria-selected": props.isActive
95
+ "tabindex": props.disabled ? undefined : props.isActive ? 0 : -1,
96
+ "aria-selected": props.isActive,
97
+ "aria-disabled": props.disabled || undefined,
98
+ "aria-controls": props.controls
93
99
  }, [renderText()]);
94
100
  }
95
101
 
@@ -8,6 +8,7 @@ export declare type TabsClickTabEventParams = {
8
8
  disabled: boolean;
9
9
  };
10
10
  export declare type TabsProvide = {
11
+ id: string;
11
12
  props: TabsProps;
12
13
  setLine: () => void;
13
14
  onRendered: (name: string | number, title?: string) => void;
@@ -80,7 +80,10 @@ var _default = (0, _vue.defineComponent)({
80
80
  var renderDeleteIcon = () => {
81
81
  if (props.deletable && props.item.status !== 'uploading') {
82
82
  return (0, _vue.createVNode)("div", {
83
+ "role": "button",
83
84
  "class": (0, _utils.bem)('preview-delete'),
85
+ "tabindex": 0,
86
+ "aria-label": (0, _utils.t)('delete'),
84
87
  "onClick": onDelete
85
88
  }, [(0, _vue.createVNode)(_icon.Icon, {
86
89
  "name": "cross",
@@ -1,6 +1,6 @@
1
1
  import type { UploaderMaxSize, UploaderResultType, UploaderFileListItem } from './types';
2
- declare const name: string, bem: (el?: import("../utils").Mods | undefined, mods?: import("../utils").Mods | undefined) => import("../utils").Mods;
3
- export { name, bem };
2
+ declare const name: string, bem: (el?: import("../utils").Mods | undefined, mods?: import("../utils").Mods | undefined) => import("../utils").Mods, t: (path: string, ...args: unknown[]) => any;
3
+ export { name, bem, t };
4
4
  export declare const toArray: <T>(item: T | T[]) => T[];
5
5
  export declare function readFileContent(file: File, resultType: UploaderResultType): Promise<string | void>;
6
6
  export declare function isOversize(items: UploaderFileListItem | UploaderFileListItem[], maxSize: UploaderMaxSize): boolean;
@@ -8,11 +8,12 @@ exports.isImageUrl = void 0;
8
8
  exports.isOversize = isOversize;
9
9
  exports.name = void 0;
10
10
  exports.readFileContent = readFileContent;
11
- exports.toArray = void 0;
11
+ exports.toArray = exports.t = void 0;
12
12
 
13
13
  var _utils = require("../utils");
14
14
 
15
- var [name, bem] = (0, _utils.createNamespace)('uploader');
15
+ var [name, bem, t] = (0, _utils.createNamespace)('uploader');
16
+ exports.t = t;
16
17
  exports.bem = bem;
17
18
  exports.name = name;
18
19
 
@@ -9,3 +9,4 @@ export declare function resetScroll(): void;
9
9
  export declare const stopPropagation: (event: Event) => void;
10
10
  export declare function preventDefault(event: Event, isStopPropagation?: boolean): void;
11
11
  export declare function isHidden(elementRef: HTMLElement | Ref<HTMLElement | undefined>): boolean;
12
+ export declare const windowWidth: Ref<number>, windowHeight: Ref<number>;
package/lib/utils/dom.js CHANGED
@@ -9,7 +9,7 @@ exports.preventDefault = preventDefault;
9
9
  exports.resetScroll = resetScroll;
10
10
  exports.setRootScrollTop = setRootScrollTop;
11
11
  exports.setScrollTop = setScrollTop;
12
- exports.stopPropagation = void 0;
12
+ exports.windowWidth = exports.windowHeight = exports.stopPropagation = void 0;
13
13
 
14
14
  var _use = require("@vant/use");
15
15
 
@@ -88,4 +88,11 @@ function isHidden(elementRef) {
88
88
 
89
89
  var parentHidden = el.offsetParent === null && style.position !== 'fixed';
90
90
  return hidden || parentHidden;
91
- }
91
+ }
92
+
93
+ var {
94
+ width: windowWidth,
95
+ height: windowHeight
96
+ } = (0, _use.useWindowSize)();
97
+ exports.windowHeight = windowHeight;
98
+ exports.windowWidth = windowWidth;
@@ -13,14 +13,16 @@ exports.unitToPx = unitToPx;
13
13
 
14
14
  var _basic = require("./basic");
15
15
 
16
+ var _dom = require("./dom");
17
+
16
18
  var _validate = require("./validate");
17
19
 
18
20
  function addUnit(value) {
19
- if (!(0, _validate.isDef)(value)) {
20
- return undefined;
21
+ if ((0, _validate.isDef)(value)) {
22
+ return (0, _validate.isNumeric)(value) ? value + "px" : String(value);
21
23
  }
22
24
 
23
- return (0, _validate.isNumeric)(value) ? value + "px" : String(value);
25
+ return undefined;
24
26
  }
25
27
 
26
28
  function getSizeStyle(originSize) {
@@ -63,12 +65,12 @@ function convertRem(value) {
63
65
 
64
66
  function convertVw(value) {
65
67
  value = value.replace(/vw/g, '');
66
- return +value * window.innerWidth / 100;
68
+ return +value * _dom.windowWidth.value / 100;
67
69
  }
68
70
 
69
71
  function convertVh(value) {
70
72
  value = value.replace(/vh/g, '');
71
- return +value * window.innerHeight / 100;
73
+ return +value * _dom.windowHeight.value / 100;
72
74
  }
73
75
 
74
76
  function unitToPx(value) {