vant 3.2.8 → 3.3.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 (171) hide show
  1. package/es/address-edit/AddressEdit.js +155 -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/CalendarHeader.js +1 -3
  6. package/es/cascader/Cascader.js +10 -2
  7. package/es/checkbox/Checker.js +1 -1
  8. package/es/checkbox/types.d.ts +2 -6
  9. package/es/composables/use-id.d.ts +1 -0
  10. package/es/composables/use-id.js +14 -0
  11. package/es/composables/use-route.d.ts +1 -1
  12. package/es/composables/use-route.js +4 -4
  13. package/es/count-down/CountDown.js +1 -0
  14. package/es/coupon-list/CouponList.js +40 -24
  15. package/es/coupon-list/index.css +1 -1
  16. package/es/coupon-list/index.less +0 -5
  17. package/es/dropdown-item/DropdownItem.js +7 -2
  18. package/es/dropdown-item/types.d.ts +2 -6
  19. package/es/dropdown-menu/DropdownMenu.js +7 -3
  20. package/es/dropdown-menu/types.d.ts +1 -0
  21. package/es/empty/Network.js +22 -34
  22. package/es/field/Field.d.ts +1 -1
  23. package/es/field/Field.js +13 -5
  24. package/es/field/index.d.ts +2 -2
  25. package/es/field/types.d.ts +7 -6
  26. package/es/form/Form.js +2 -2
  27. package/es/image/Image.js +4 -9
  28. package/es/image-preview/ImagePreview.js +3 -4
  29. package/es/index.d.ts +1 -1
  30. package/es/index.js +1 -1
  31. package/es/lazyload/index.d.ts +1 -1
  32. package/es/lazyload/index.js +1 -1
  33. package/es/lazyload/vue-lazyload/index.d.ts +55 -0
  34. package/es/lazyload/vue-lazyload/index.js +46 -0
  35. package/es/lazyload/vue-lazyload/lazy-component.js +53 -0
  36. package/es/lazyload/vue-lazyload/lazy-container.js +98 -0
  37. package/es/lazyload/vue-lazyload/lazy-image.js +115 -0
  38. package/es/lazyload/vue-lazyload/lazy.js +507 -0
  39. package/es/lazyload/vue-lazyload/listener.js +241 -0
  40. package/es/lazyload/vue-lazyload/util.js +183 -0
  41. package/es/list/List.js +3 -1
  42. package/es/number-keyboard/NumberKeyboardKey.js +4 -4
  43. package/es/pagination/Pagination.js +67 -49
  44. package/es/pagination/index.css +1 -1
  45. package/es/pagination/index.less +32 -31
  46. package/es/password-input/PasswordInput.d.ts +1 -1
  47. package/es/password-input/index.d.ts +1 -1
  48. package/es/popover/Popover.js +2 -0
  49. package/es/popup/Popup.d.ts +1 -2
  50. package/es/popup/Popup.js +2 -5
  51. package/es/popup/index.d.ts +1 -2
  52. package/es/rate/Rate.js +5 -3
  53. package/es/search/Search.js +8 -2
  54. package/es/sidebar/Sidebar.js +1 -0
  55. package/es/sidebar-item/SidebarItem.js +4 -1
  56. package/es/slider/Slider.js +5 -3
  57. package/es/stepper/Stepper.js +11 -8
  58. package/es/swipe/Swipe.js +3 -4
  59. package/es/swipe/types.d.ts +1 -3
  60. package/es/switch/Switch.js +1 -0
  61. package/es/switch/index.css +1 -1
  62. package/es/switch/index.less +2 -0
  63. package/es/tab/Tab.js +17 -4
  64. package/es/tab/index.css +1 -1
  65. package/es/tab/index.less +1 -1
  66. package/es/tabbar/Tabbar.d.ts +1 -1
  67. package/es/tabbar/Tabbar.js +10 -10
  68. package/es/tabbar-item/TabbarItem.js +11 -4
  69. package/es/tabs/Tabs.js +10 -5
  70. package/es/tabs/TabsTitle.d.ts +6 -0
  71. package/es/tabs/TabsTitle.js +7 -1
  72. package/es/tabs/types.d.ts +1 -0
  73. package/es/uploader/UploaderPreviewItem.js +4 -1
  74. package/es/uploader/utils.d.ts +2 -2
  75. package/es/uploader/utils.js +2 -2
  76. package/es/utils/dom.d.ts +1 -0
  77. package/es/utils/dom.js +6 -2
  78. package/es/utils/format.js +6 -5
  79. package/es/vue-tsx-shim.d.ts +1 -0
  80. package/lib/address-edit/AddressEdit.js +156 -180
  81. package/lib/address-edit/AddressEditDetail.d.ts +10 -9
  82. package/lib/address-edit/AddressEditDetail.js +6 -6
  83. package/lib/button/Button.js +1 -1
  84. package/lib/calendar/CalendarHeader.js +1 -3
  85. package/lib/cascader/Cascader.js +10 -2
  86. package/lib/checkbox/Checker.js +1 -1
  87. package/lib/checkbox/types.d.ts +2 -6
  88. package/lib/composables/use-id.d.ts +1 -0
  89. package/lib/composables/use-id.js +21 -0
  90. package/lib/composables/use-route.d.ts +1 -1
  91. package/lib/composables/use-route.js +4 -4
  92. package/lib/count-down/CountDown.js +1 -0
  93. package/lib/coupon-list/CouponList.js +39 -22
  94. package/lib/coupon-list/index.css +1 -1
  95. package/lib/coupon-list/index.less +0 -5
  96. package/lib/dropdown-item/DropdownItem.js +7 -2
  97. package/lib/dropdown-item/types.d.ts +2 -6
  98. package/lib/dropdown-menu/DropdownMenu.js +7 -2
  99. package/lib/dropdown-menu/types.d.ts +1 -0
  100. package/lib/empty/Network.js +22 -34
  101. package/lib/field/Field.d.ts +1 -1
  102. package/lib/field/Field.js +14 -5
  103. package/lib/field/index.d.ts +2 -2
  104. package/lib/field/types.d.ts +7 -6
  105. package/lib/form/Form.js +1 -1
  106. package/lib/image/Image.js +4 -9
  107. package/lib/image-preview/ImagePreview.js +1 -2
  108. package/lib/index.css +1 -1
  109. package/lib/index.d.ts +1 -1
  110. package/lib/index.js +1 -1
  111. package/lib/lazyload/index.d.ts +1 -1
  112. package/lib/lazyload/index.js +3 -3
  113. package/lib/lazyload/vue-lazyload/index.d.ts +55 -0
  114. package/lib/lazyload/vue-lazyload/index.js +58 -0
  115. package/lib/lazyload/vue-lazyload/lazy-component.js +62 -0
  116. package/lib/lazyload/vue-lazyload/lazy-container.js +106 -0
  117. package/lib/lazyload/vue-lazyload/lazy-image.js +125 -0
  118. package/lib/lazyload/vue-lazyload/lazy.js +520 -0
  119. package/lib/lazyload/vue-lazyload/listener.js +251 -0
  120. package/lib/lazyload/vue-lazyload/util.js +213 -0
  121. package/lib/list/List.js +3 -1
  122. package/lib/number-keyboard/NumberKeyboardKey.js +3 -3
  123. package/lib/pagination/Pagination.js +65 -47
  124. package/lib/pagination/index.css +1 -1
  125. package/lib/pagination/index.less +32 -31
  126. package/lib/password-input/PasswordInput.d.ts +1 -1
  127. package/lib/password-input/index.d.ts +1 -1
  128. package/lib/popover/Popover.js +2 -0
  129. package/lib/popup/Popup.d.ts +1 -2
  130. package/lib/popup/Popup.js +2 -5
  131. package/lib/popup/index.d.ts +1 -2
  132. package/lib/rate/Rate.js +5 -3
  133. package/lib/search/Search.js +9 -2
  134. package/lib/sidebar/Sidebar.js +1 -0
  135. package/lib/sidebar-item/SidebarItem.js +4 -1
  136. package/lib/slider/Slider.js +5 -3
  137. package/lib/stepper/Stepper.js +11 -8
  138. package/lib/swipe/Swipe.js +1 -2
  139. package/lib/swipe/types.d.ts +1 -3
  140. package/lib/switch/Switch.js +1 -0
  141. package/lib/switch/index.css +1 -1
  142. package/lib/switch/index.less +2 -0
  143. package/lib/tab/Tab.js +19 -4
  144. package/lib/tab/index.css +1 -1
  145. package/lib/tab/index.less +1 -1
  146. package/lib/tabbar/Tabbar.d.ts +1 -1
  147. package/lib/tabbar/Tabbar.js +10 -10
  148. package/lib/tabbar-item/TabbarItem.js +11 -4
  149. package/lib/tabs/Tabs.js +9 -3
  150. package/lib/tabs/TabsTitle.d.ts +6 -0
  151. package/lib/tabs/TabsTitle.js +7 -1
  152. package/lib/tabs/types.d.ts +1 -0
  153. package/lib/uploader/UploaderPreviewItem.js +3 -0
  154. package/lib/uploader/utils.d.ts +2 -2
  155. package/lib/uploader/utils.js +3 -2
  156. package/lib/utils/dom.d.ts +1 -0
  157. package/lib/utils/dom.js +9 -2
  158. package/lib/utils/format.js +7 -5
  159. package/lib/vant.es.js +1086 -1068
  160. package/lib/vant.es.min.js +1086 -1068
  161. package/lib/vant.js +1085 -1067
  162. package/lib/vant.min.js +1 -1
  163. package/lib/vue-tsx-shim.d.ts +1 -0
  164. package/package.json +4 -4
  165. package/vetur/attributes.json +340 -340
  166. package/vetur/tags.json +119 -119
  167. package/vetur/web-types.json +1143 -1143
  168. package/es/composables/use-link-field.d.ts +0 -0
  169. package/es/composables/use-link-field.js +0 -0
  170. package/lib/composables/use-link-field.d.ts +0 -0
  171. package/lib/composables/use-link-field.js +0 -1
@@ -13,9 +13,12 @@
13
13
  }
14
14
 
15
15
  .van-pagination {
16
- display: flex;
17
16
  font-size: var(--van-pagination-font-size);
18
17
 
18
+ &__items {
19
+ display: flex;
20
+ }
21
+
19
22
  &__item,
20
23
  &__page-desc {
21
24
  display: flex;
@@ -33,58 +36,56 @@
33
36
  cursor: pointer;
34
37
  user-select: none;
35
38
 
39
+ button {
40
+ flex: 1;
41
+ height: 100%;
42
+ border: none;
43
+ padding: 0;
44
+ background: transparent;
45
+
46
+ &[disabled] {
47
+ cursor: not-allowed;
48
+ }
49
+ }
50
+
36
51
  &:active {
37
52
  color: var(--van-white);
38
53
  background-color: var(--van-pagination-item-default-color);
39
54
  }
40
55
 
41
- &::after {
42
- border-width: var(--van-border-width-base) 0 var(--van-border-width-base)
43
- var(--van-border-width-base);
44
- }
45
-
46
- &:last-child::after {
47
- border-right-width: var(--van-border-width-base);
56
+ &:not(:last-child)::after {
57
+ border-right-width: 0;
48
58
  }
49
59
 
50
60
  &--active {
51
61
  color: var(--van-white);
52
62
  background-color: var(--van-pagination-item-default-color);
53
63
  }
54
- }
55
64
 
56
- &__prev,
57
- &__next {
58
- padding: 0 var(--van-padding-base);
59
- cursor: pointer;
60
- }
65
+ &--page {
66
+ flex-grow: 0;
67
+ }
61
68
 
62
- &__item--disabled {
63
- &,
64
- &:active {
69
+ &--prev,
70
+ &--next {
71
+ padding: 0 var(--van-padding-base);
72
+ cursor: pointer;
73
+ }
74
+
75
+ &--border::after {
76
+ border-width: var(--van-border-width-base);
77
+ }
78
+
79
+ &--disabled {
65
80
  color: var(--van-pagination-item-disabled-color);
66
81
  background-color: var(--van-pagination-item-disabled-background-color);
67
- cursor: not-allowed;
68
82
  opacity: var(--van-pagination-disabled-opacity);
69
83
  }
70
84
  }
71
85
 
72
- &__page {
73
- flex-grow: 0;
74
- }
75
-
76
86
  &__page-desc {
77
87
  flex: 1;
78
88
  height: var(--van-pagination-height);
79
89
  color: var(--van-pagination-desc-color);
80
90
  }
81
-
82
- &--simple {
83
- .van-pagination__prev,
84
- .van-pagination__next {
85
- &::after {
86
- border-width: var(--van-border-width-base);
87
- }
88
- }
89
- }
90
91
  }
@@ -49,9 +49,9 @@ declare const _default: import("vue").DefineComponent<{
49
49
  value: string;
50
50
  focused: boolean;
51
51
  } & {
52
- errorInfo?: string | undefined;
53
52
  gutter?: string | number | undefined;
54
53
  info?: string | undefined;
54
+ errorInfo?: string | undefined;
55
55
  }> & {
56
56
  onFocus?: ((...args: any[]) => any) | undefined;
57
57
  }, {
@@ -29,9 +29,9 @@ export declare const PasswordInput: import("../utils").WithInstall<import("vue")
29
29
  value: string;
30
30
  focused: boolean;
31
31
  } & {
32
- errorInfo?: string | undefined;
33
32
  gutter?: string | number | undefined;
34
33
  info?: string | undefined;
34
+ errorInfo?: string | undefined;
35
35
  }> & {
36
36
  onFocus?: ((...args: any[]) => any) | undefined;
37
37
  }, {
@@ -145,6 +145,8 @@ var _default = (0, _vue.defineComponent)({
145
145
  "style": {
146
146
  color
147
147
  },
148
+ "tabindex": disabled ? undefined : 0,
149
+ "aria-disabled": disabled || undefined,
148
150
  "onClick": () => onClickAction(action, index)
149
151
  }, [icon && (0, _vue.createVNode)(_icon.Icon, {
150
152
  "name": icon,
@@ -91,7 +91,7 @@ declare const _default: import("vue").DefineComponent<{
91
91
  default: PopupCloseIconPosition;
92
92
  };
93
93
  safeAreaInsetBottom: BooleanConstructor;
94
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("open" | "click" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon")[], "open" | "click" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
94
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("open" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon")[], "open" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
95
95
  show?: unknown;
96
96
  zIndex?: unknown;
97
97
  overlay?: unknown;
@@ -137,7 +137,6 @@ declare const _default: import("vue").DefineComponent<{
137
137
  overlayClass?: unknown;
138
138
  transition?: string | undefined;
139
139
  }> & {
140
- onClick?: ((...args: any[]) => any) | undefined;
141
140
  onOpen?: ((...args: any[]) => any) | undefined;
142
141
  onClose?: ((...args: any[]) => any) | undefined;
143
142
  onOpened?: ((...args: any[]) => any) | undefined;
@@ -44,7 +44,7 @@ var _default = (0, _vue.defineComponent)({
44
44
  name,
45
45
  inheritAttrs: false,
46
46
  props: popupProps,
47
- emits: ['open', 'close', 'click', 'opened', 'closed', 'update:show', 'click-overlay', 'click-close-icon'],
47
+ emits: ['open', 'close', 'opened', 'closed', 'update:show', 'click-overlay', 'click-close-icon'],
48
48
 
49
49
  setup(props, _ref) {
50
50
  var {
@@ -136,8 +136,6 @@ var _default = (0, _vue.defineComponent)({
136
136
  }
137
137
  };
138
138
 
139
- var onClick = event => emit('click', event);
140
-
141
139
  var onOpened = () => emit('opened');
142
140
 
143
141
  var onClosed = () => emit('closed');
@@ -156,8 +154,7 @@ var _default = (0, _vue.defineComponent)({
156
154
  [position]: position
157
155
  }), {
158
156
  'van-safe-area-bottom': safeAreaInsetBottom
159
- }],
160
- "onClick": onClick
157
+ }]
161
158
  }, attrs), [slots.default == null ? void 0 : slots.default(), renderCloseIcon()]), [[_vue.vShow, props.show]]);
162
159
  });
163
160
 
@@ -42,7 +42,7 @@ export declare const Popup: import("../utils").WithInstall<import("vue").DefineC
42
42
  default: import("./Popup").PopupCloseIconPosition;
43
43
  };
44
44
  safeAreaInsetBottom: BooleanConstructor;
45
- }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("open" | "click" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon")[], "open" | "click" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
45
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("open" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon")[], "open" | "close" | "opened" | "closed" | "update:show" | "click-overlay" | "click-close-icon", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
46
46
  show?: unknown;
47
47
  zIndex?: unknown;
48
48
  overlay?: unknown;
@@ -88,7 +88,6 @@ export declare const Popup: import("../utils").WithInstall<import("vue").DefineC
88
88
  overlayClass?: unknown;
89
89
  transition?: string | undefined;
90
90
  }> & {
91
- onClick?: ((...args: any[]) => any) | undefined;
92
91
  onOpen?: ((...args: any[]) => any) | undefined;
93
92
  onClose?: ((...args: any[]) => any) | undefined;
94
93
  onOpened?: ((...args: any[]) => any) | undefined;
package/lib/rate/Rate.js CHANGED
@@ -183,8 +183,8 @@ var _default = (0, _vue.defineComponent)({
183
183
  "role": "radio",
184
184
  "style": style,
185
185
  "class": bem('item'),
186
- "tabindex": 0,
187
- "aria-setsize": +count,
186
+ "tabindex": disabled ? undefined : 0,
187
+ "aria-setsize": count,
188
188
  "aria-posinset": score,
189
189
  "aria-checked": !isVoid,
190
190
  "onClick": onClickItem
@@ -219,7 +219,9 @@ var _default = (0, _vue.defineComponent)({
219
219
  readonly: props.readonly,
220
220
  disabled: props.disabled
221
221
  }),
222
- "tabindex": 0,
222
+ "tabindex": props.disabled ? undefined : 0,
223
+ "aria-disabled": props.disabled,
224
+ "aria-readonly": props.readonly,
223
225
  "onTouchstart": onTouchStart,
224
226
  "onTouchmove": onTouchMove
225
227
  }, [list.value.map(renderStar)]);
@@ -9,6 +9,8 @@ var _utils = require("../utils");
9
9
 
10
10
  var _Field = require("../field/Field");
11
11
 
12
+ var _useId = require("../composables/use-id");
13
+
12
14
  var _useExpose = require("../composables/use-expose");
13
15
 
14
16
  var _field = require("../field");
@@ -38,6 +40,7 @@ var _default = (0, _vue.defineComponent)({
38
40
  slots,
39
41
  attrs
40
42
  } = _ref;
43
+ var id = (0, _useId.useId)();
41
44
  var filedRef = (0, _vue.ref)();
42
45
 
43
46
  var onCancel = () => {
@@ -56,11 +59,13 @@ var _default = (0, _vue.defineComponent)({
56
59
  }
57
60
  };
58
61
 
62
+ var getInputId = () => props.id || id + "-input";
63
+
59
64
  var renderLabel = () => {
60
65
  if (slots.label || props.label) {
61
66
  return (0, _vue.createVNode)("label", {
62
67
  "class": bem('label'),
63
- "for": props.id
68
+ "for": getInputId()
64
69
  }, [slots.label ? slots.label() : props.label]);
65
70
  }
66
71
  };
@@ -92,7 +97,9 @@ var _default = (0, _vue.defineComponent)({
92
97
  var fieldPropNames = Object.keys(_Field.fieldSharedProps);
93
98
 
94
99
  var renderField = () => {
95
- var fieldAttrs = (0, _utils.extend)({}, attrs, (0, _utils.pick)(props, fieldPropNames));
100
+ var fieldAttrs = (0, _utils.extend)({}, attrs, (0, _utils.pick)(props, fieldPropNames), {
101
+ id: getInputId()
102
+ });
96
103
 
97
104
  var onInput = value => emit('update:modelValue', value);
98
105
 
@@ -44,6 +44,7 @@ var _default = (0, _vue.defineComponent)({
44
44
  setActive
45
45
  });
46
46
  return () => (0, _vue.createVNode)("div", {
47
+ "role": "tablist",
47
48
  "class": bem()
48
49
  }, [slots.default == null ? void 0 : slots.default()]);
49
50
  }
@@ -68,11 +68,14 @@ var _default = (0, _vue.defineComponent)({
68
68
  disabled
69
69
  } = props;
70
70
  var selected = index.value === parent.getActive();
71
- return (0, _vue.createVNode)("a", {
71
+ return (0, _vue.createVNode)("div", {
72
+ "role": "tab",
72
73
  "class": bem({
73
74
  select: selected,
74
75
  disabled
75
76
  }),
77
+ "tabindex": disabled ? undefined : 0,
78
+ "aria-selected": selected,
76
79
  "onClick": onClick
77
80
  }, [(0, _vue.createVNode)(_badge.Badge, {
78
81
  "dot": dot,
@@ -294,10 +294,12 @@ var _default = (0, _vue.defineComponent)({
294
294
  return (0, _vue.createVNode)("div", {
295
295
  "role": "slider",
296
296
  "class": getButtonClassName(index),
297
- "tabindex": props.disabled || props.readonly ? -1 : 0,
298
- "aria-valuemin": +props.min,
297
+ "tabindex": props.disabled ? undefined : 0,
298
+ "aria-valuemin": props.min,
299
299
  "aria-valuenow": current,
300
- "aria-valuemax": +props.max,
300
+ "aria-valuemax": props.max,
301
+ "aria-disabled": props.disabled || undefined,
302
+ "aria-readonly": props.readonly || undefined,
301
303
  "aria-orientation": props.vertical ? 'vertical' : 'horizontal',
302
304
  "onTouchstart": event => {
303
305
  if (typeof index === 'number') {
@@ -219,14 +219,14 @@ var _default = (0, _vue.defineComponent)({
219
219
  // fix mobile safari page scroll down issue
220
220
  // see: https://github.com/youzan/vant/issues/7690
221
221
  if (props.disableInput) {
222
- event.preventDefault();
222
+ (0, _utils.preventDefault)(event);
223
223
  }
224
224
  };
225
225
 
226
226
  var createListeners = type => ({
227
227
  onClick: event => {
228
228
  // disable double tap scrolling on mobile safari
229
- event.preventDefault();
229
+ (0, _utils.preventDefault)(event);
230
230
  actionType = type;
231
231
  onChange();
232
232
  },
@@ -238,7 +238,7 @@ var _default = (0, _vue.defineComponent)({
238
238
  onTouchcancel: onTouchEnd
239
239
  });
240
240
 
241
- (0, _vue.watch)([() => props.max, () => props.min, () => props.integer, () => props.decimalLength], check);
241
+ (0, _vue.watch)(() => [props.max, props.min, props.integer, props.decimalLength], check);
242
242
  (0, _vue.watch)(() => props.modelValue, value => {
243
243
  if (!isEqual(value, current.value)) {
244
244
  current.value = format(value);
@@ -252,6 +252,7 @@ var _default = (0, _vue.defineComponent)({
252
252
  });
253
253
  (0, _use.useCustomFieldValue)(() => props.modelValue);
254
254
  return () => (0, _vue.createVNode)("div", {
255
+ "role": "group",
255
256
  "class": bem([props.theme])
256
257
  }, [(0, _vue.withDirectives)((0, _vue.createVNode)("button", (0, _vue.mergeProps)({
257
258
  "type": "button",
@@ -260,7 +261,8 @@ var _default = (0, _vue.defineComponent)({
260
261
  disabled: minusDisabled.value
261
262
  }), {
262
263
  [_utils.HAPTICS_FEEDBACK]: !minusDisabled.value
263
- }]
264
+ }],
265
+ "aria-disabled": minusDisabled.value || undefined
264
266
  }, createListeners('minus')), null), [[_vue.vShow, props.showMinus]]), (0, _vue.withDirectives)((0, _vue.createVNode)("input", {
265
267
  "ref": inputRef,
266
268
  "type": props.integer ? 'tel' : 'text',
@@ -272,9 +274,9 @@ var _default = (0, _vue.defineComponent)({
272
274
  "readonly": props.disableInput,
273
275
  "inputmode": props.integer ? 'numeric' : 'decimal',
274
276
  "placeholder": props.placeholder,
275
- "aria-valuemax": +props.max,
276
- "aria-valuemin": +props.min,
277
- "aria-valuenow": +current.value,
277
+ "aria-valuemax": props.max,
278
+ "aria-valuemin": props.min,
279
+ "aria-valuenow": current.value,
278
280
  "onBlur": onBlur,
279
281
  "onInput": onInput,
280
282
  "onFocus": onFocus,
@@ -286,7 +288,8 @@ var _default = (0, _vue.defineComponent)({
286
288
  disabled: plusDisabled.value
287
289
  }), {
288
290
  [_utils.HAPTICS_FEEDBACK]: !plusDisabled.value
289
- }]
291
+ }],
292
+ "aria-disabled": plusDisabled.value || undefined
290
293
  }, createListeners('plus')), null), [[_vue.vShow, props.showPlus]])]);
291
294
  }
292
295
 
@@ -55,7 +55,6 @@ var _default = (0, _vue.defineComponent)({
55
55
  swiping: false
56
56
  });
57
57
  var touch = (0, _useTouch.useTouch)();
58
- var windowSize = (0, _use.useWindowSize)();
59
58
  var {
60
59
  children,
61
60
  linkChildren
@@ -391,7 +390,7 @@ var _default = (0, _vue.defineComponent)({
391
390
  (0, _vue.watch)(() => props.initialSwipe, value => initialize(+value));
392
391
  (0, _vue.watch)(count, () => initialize(state.active));
393
392
  (0, _vue.watch)(() => props.autoplay, autoplay);
394
- (0, _vue.watch)([windowSize.width, windowSize.height], resize);
393
+ (0, _vue.watch)([_utils.windowWidth, _utils.windowHeight], resize);
395
394
  (0, _vue.watch)((0, _use.usePageVisibility)(), visible => {
396
395
  if (visible === 'visible') {
397
396
  autoplay();
@@ -19,9 +19,7 @@ export declare type SwipeExpose = {
19
19
  next: () => void;
20
20
  resize: () => void;
21
21
  swipeTo: (index: number, options?: SwipeToOptions) => void;
22
- /**
23
- * @private
24
- */
22
+ /** @private */
25
23
  state: SwipeState;
26
24
  };
27
25
  export declare type SwipeProvide = {
@@ -81,6 +81,7 @@ var _default = (0, _vue.defineComponent)({
81
81
  disabled
82
82
  }),
83
83
  "style": style,
84
+ "tabindex": disabled ? undefined : 0,
84
85
  "aria-checked": checked,
85
86
  "onClick": onClick
86
87
  }, [(0, _vue.createVNode)("div", {
@@ -1 +1 @@
1
- :root{--van-switch-size:30px;--van-switch-width:2em;--van-switch-height:1em;--van-switch-node-size:1em;--van-switch-node-background-color:var(--van-white);--van-switch-node-box-shadow:0 3px 1px 0 rgba(0, 0, 0, 0.05),0 2px 2px 0 rgba(0, 0, 0, 0.1),0 3px 3px 0 rgba(0, 0, 0, 0.05);--van-switch-background-color:var(--van-background-color-light);--van-switch-on-background-color:var(--van-primary-color);--van-switch-transition-duration:var(--van-animation-duration-base);--van-switch-disabled-opacity:var(--van-disabled-opacity);--van-switch-border:var(--van-border-width-base) solid rgba(0, 0, 0, 0.1)}.van-switch{position:relative;display:inline-block;box-sizing:content-box;width:var(--van-switch-width);height:var(--van-switch-height);font-size:var(--van-switch-size);background:var(--van-switch-background-color);border:var(--van-switch-border);border-radius:var(--van-switch-node-size);cursor:pointer;transition:background-color var(--van-switch-transition-duration)}.van-switch__node{position:absolute;top:0;left:0;width:var(--van-switch-node-size);height:var(--van-switch-node-size);background:var(--van-switch-node-background-color);border-radius:100%;box-shadow:var(--van-switch-node-box-shadow);transition:transform var(--van-switch-transition-duration) cubic-bezier(.3, 1.05, .4, 1.05)}.van-switch__loading{top:25%;left:25%;width:50%;height:50%;line-height:1}.van-switch--on{background:var(--van-switch-on-background-color)}.van-switch--on .van-switch__node{transform:translateX(calc(var(--van-switch-width) - var(--van-switch-node-size)))}.van-switch--on .van-switch__loading{color:var(--van-switch-on-background-color)}.van-switch--disabled{cursor:not-allowed;opacity:var(--van-switch-disabled-opacity)}.van-switch--loading{cursor:default}
1
+ :root{--van-switch-size:30px;--van-switch-width:2em;--van-switch-height:1em;--van-switch-node-size:1em;--van-switch-node-background-color:var(--van-white);--van-switch-node-box-shadow:0 3px 1px 0 rgba(0, 0, 0, 0.05),0 2px 2px 0 rgba(0, 0, 0, 0.1),0 3px 3px 0 rgba(0, 0, 0, 0.05);--van-switch-background-color:var(--van-background-color-light);--van-switch-on-background-color:var(--van-primary-color);--van-switch-transition-duration:var(--van-animation-duration-base);--van-switch-disabled-opacity:var(--van-disabled-opacity);--van-switch-border:var(--van-border-width-base) solid rgba(0, 0, 0, 0.1)}.van-switch{position:relative;display:inline-block;box-sizing:content-box;width:var(--van-switch-width);height:var(--van-switch-height);font-size:var(--van-switch-size);background:var(--van-switch-background-color);border:var(--van-switch-border);border-radius:var(--van-switch-node-size);cursor:pointer;transition:background-color var(--van-switch-transition-duration)}.van-switch__node{position:absolute;top:0;left:0;width:var(--van-switch-node-size);height:var(--van-switch-node-size);font-size:inherit;background:var(--van-switch-node-background-color);border-radius:100%;box-shadow:var(--van-switch-node-box-shadow);transition:transform var(--van-switch-transition-duration) cubic-bezier(.3, 1.05, .4, 1.05)}.van-switch__loading{top:25%;left:25%;width:50%;height:50%;line-height:1}.van-switch--on{background:var(--van-switch-on-background-color)}.van-switch--on .van-switch__node{transform:translateX(calc(var(--van-switch-width) - var(--van-switch-node-size)))}.van-switch--on .van-switch__loading{color:var(--van-switch-on-background-color)}.van-switch--disabled{cursor:not-allowed;opacity:var(--van-switch-disabled-opacity)}.van-switch--loading{cursor:default}
@@ -33,6 +33,8 @@
33
33
  left: 0;
34
34
  width: var(--van-switch-node-size);
35
35
  height: var(--van-switch-node-size);
36
+ // https://github.com/youzan/vant/issues/9839
37
+ font-size: inherit;
36
38
  background: var(--van-switch-node-background-color);
37
39
  border-radius: 100%;
38
40
  box-shadow: var(--van-switch-node-box-shadow);
package/lib/tab/Tab.js CHANGED
@@ -11,6 +11,10 @@ var _Tabs = require("../tabs/Tabs");
11
11
 
12
12
  var _use = require("@vant/use");
13
13
 
14
+ var _useId = require("../composables/use-id");
15
+
16
+ var _useExpose = require("../composables/use-expose");
17
+
14
18
  var _useRoute = require("../composables/use-route");
15
19
 
16
20
  var _useTabStatus = require("../composables/use-tab-status");
@@ -40,6 +44,7 @@ var _default = (0, _vue.defineComponent)({
40
44
  var {
41
45
  slots
42
46
  } = _ref;
47
+ var id = (0, _useId.useId)();
43
48
  var inited = (0, _vue.ref)(false);
44
49
  var {
45
50
  parent,
@@ -85,6 +90,7 @@ var _default = (0, _vue.defineComponent)({
85
90
  });
86
91
  (0, _vue.provide)(_useTabStatus.TAB_STATUS_KEY, active);
87
92
  return () => {
93
+ var label = parent.id + "-" + index.value;
88
94
  var {
89
95
  animated,
90
96
  swipeable,
@@ -100,23 +106,32 @@ var _default = (0, _vue.defineComponent)({
100
106
 
101
107
  if (animated || swipeable) {
102
108
  return (0, _vue.createVNode)(_swipeItem.SwipeItem, {
109
+ "id": id,
103
110
  "role": "tabpanel",
104
- "aria-hidden": !active.value,
105
111
  "class": bem('pane-wrapper', {
106
112
  inactive: !active.value
107
- })
113
+ }),
114
+ "tabindex": active.value ? 0 : -1,
115
+ "aria-hidden": !active.value,
116
+ "aria-labelledby": label
108
117
  }, {
109
118
  default: () => [(0, _vue.createVNode)("div", {
110
- "class": bem('pane')
119
+ "class": bem('panel')
111
120
  }, [slots.default == null ? void 0 : slots.default()])]
112
121
  });
113
122
  }
114
123
 
115
124
  var shouldRender = inited.value || scrollspy || !lazyRender;
116
125
  var Content = shouldRender ? slots.default == null ? void 0 : slots.default() : null;
126
+ (0, _useExpose.useExpose)({
127
+ id
128
+ });
117
129
  return (0, _vue.withDirectives)((0, _vue.createVNode)("div", {
130
+ "id": id,
118
131
  "role": "tabpanel",
119
- "class": bem('pane')
132
+ "class": bem('panel'),
133
+ "tabindex": show ? 0 : -1,
134
+ "aria-labelledby": label
120
135
  }, [Content]), [[_vue.vShow, show]]);
121
136
  };
122
137
  }
package/lib/tab/index.css CHANGED
@@ -1 +1 @@
1
- .van-tab__pane,.van-tab__pane-wrapper{flex-shrink:0;box-sizing:border-box;width:100%}.van-tab__pane-wrapper--inactive{height:0;overflow:visible}
1
+ .van-tab__panel,.van-tab__panel-wrapper{flex-shrink:0;box-sizing:border-box;width:100%}.van-tab__panel-wrapper--inactive{height:0;overflow:visible}
@@ -1,5 +1,5 @@
1
1
  .van-tab {
2
- &__pane {
2
+ &__panel {
3
3
  &,
4
4
  &-wrapper {
5
5
  flex-shrink: 0;
@@ -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
@@ -75,15 +77,17 @@ var _default = (0, _vue.defineComponent)({
75
77
  return pathMatched || nameMatched;
76
78
  }
77
79
 
78
- return (props.name || index.value) === modelValue;
80
+ return ((_props$name = props.name) != null ? _props$name : index.value) === modelValue;
79
81
  });
80
82
 
81
83
  var onClick = event => {
82
- var _props$name;
84
+ if (!active.value) {
85
+ var _props$name2;
86
+
87
+ parent.setActive((_props$name2 = props.name) != null ? _props$name2 : index.value, route);
88
+ }
83
89
 
84
- parent.setActive((_props$name = props.name) != null ? _props$name : index.value);
85
90
  emit('click', event);
86
- route();
87
91
  };
88
92
 
89
93
  var renderIcon = () => {
@@ -112,12 +116,15 @@ var _default = (0, _vue.defineComponent)({
112
116
  } = parent.props;
113
117
  var color = active.value ? activeColor : inactiveColor;
114
118
  return (0, _vue.createVNode)("div", {
119
+ "role": "tab",
115
120
  "class": bem({
116
121
  active: active.value
117
122
  }),
118
123
  "style": {
119
124
  color
120
125
  },
126
+ "tabindex": 0,
127
+ "aria-selected": active.value,
121
128
  "onClick": onClick
122
129
  }, [(0, _vue.createVNode)(_badge.Badge, {
123
130
  "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 {
@@ -303,12 +305,14 @@ var _default = (0, _vue.defineComponent)({
303
305
  };
304
306
 
305
307
  var renderNav = () => children.map((item, index) => (0, _vue.createVNode)(_TabsTitle.default, (0, _vue.mergeProps)({
308
+ "id": id + "-" + index,
306
309
  "ref": setTitleRefs(index),
307
310
  "type": props.type,
308
311
  "color": props.color,
309
312
  "style": item.titleStyle,
310
313
  "class": item.titleClass,
311
314
  "isActive": index === state.currentIndex,
315
+ "controls": item.id,
312
316
  "scrollable": scrollable.value,
313
317
  "renderTitle": item.$slots.title,
314
318
  "activeColor": props.titleActiveColor,
@@ -336,14 +340,15 @@ var _default = (0, _vue.defineComponent)({
336
340
  "class": bem('nav', [type, {
337
341
  complete: scrollable.value
338
342
  }]),
339
- "style": navStyle.value
343
+ "style": navStyle.value,
344
+ "aria-orientation": "horizontal"
340
345
  }, [(_slots$navLeft = slots['nav-left']) == null ? void 0 : _slots$navLeft.call(slots), renderNav(), type === 'line' && (0, _vue.createVNode)("div", {
341
346
  "class": bem('line'),
342
347
  "style": state.lineStyle
343
348
  }, null), (_slots$navRight = slots['nav-right']) == null ? void 0 : _slots$navRight.call(slots)])]);
344
349
  };
345
350
 
346
- (0, _vue.watch)([() => props.color, windowSize.width], setLine);
351
+ (0, _vue.watch)([() => props.color, _utils.windowWidth], setLine);
347
352
  (0, _vue.watch)(() => props.active, value => {
348
353
  if (value !== currentName.value) {
349
354
  setCurrentIndexByName(value);
@@ -393,6 +398,7 @@ var _default = (0, _vue.defineComponent)({
393
398
  target: scroller
394
399
  });
395
400
  linkChildren({
401
+ id,
396
402
  props,
397
403
  setLine,
398
404
  onRendered,