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
@@ -19,6 +19,8 @@ var _button = require("../button");
19
19
 
20
20
  var _coupon = require("../coupon");
21
21
 
22
+ var _use = require("@vant/use");
23
+
22
24
  // Utils
23
25
  // Composables
24
26
  // Components
@@ -56,25 +58,33 @@ var _default = (0, _vue.defineComponent)({
56
58
  slots
57
59
  } = _ref;
58
60
  var [couponRefs, setCouponRefs] = (0, _useRefs.useRefs)();
59
- var state = (0, _vue.reactive)({
60
- tab: 0,
61
- code: props.code
62
- });
63
- var buttonDisabled = (0, _vue.computed)(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !state.code || state.code.length < props.exchangeMinLength));
61
+ var root = (0, _vue.ref)();
62
+ var barRef = (0, _vue.ref)();
63
+ var activeTab = (0, _vue.ref)(0);
64
+ var listHeight = (0, _vue.ref)(0);
65
+ var currentCode = (0, _vue.ref)(props.code);
66
+ var buttonDisabled = (0, _vue.computed)(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
67
+
68
+ var updateListHeight = () => {
69
+ var TABS_HEIGHT = 44;
70
+ var rootHeight = (0, _use.useRect)(root).height;
71
+ var headerHeight = (0, _use.useRect)(barRef).height + TABS_HEIGHT;
72
+ listHeight.value = (rootHeight > headerHeight ? rootHeight : _utils.windowHeight.value) - headerHeight;
73
+ };
64
74
 
65
75
  var onExchange = () => {
66
- emit('exchange', state.code); // auto clear currentCode when not use v-model
76
+ emit('exchange', currentCode.value); // auto clear currentCode when not use v-model
67
77
 
68
78
  if (!props.code) {
69
- state.code = '';
79
+ currentCode.value = '';
70
80
  }
71
81
  };
72
82
 
73
83
  var scrollToCoupon = index => {
74
84
  (0, _vue.nextTick)(() => {
75
- if (couponRefs.value[index]) {
76
- couponRefs.value[index].scrollIntoView();
77
- }
85
+ var _couponRefs$value$ind;
86
+
87
+ return (_couponRefs$value$ind = couponRefs.value[index]) == null ? void 0 : _couponRefs$value$ind.scrollIntoView();
78
88
  });
79
89
  };
80
90
 
@@ -87,10 +97,11 @@ var _default = (0, _vue.defineComponent)({
87
97
  var renderExchangeBar = () => {
88
98
  if (props.showExchangeBar) {
89
99
  return (0, _vue.createVNode)("div", {
100
+ "ref": barRef,
90
101
  "class": bem('exchange-bar')
91
102
  }, [(0, _vue.createVNode)(_field.Field, {
92
- "modelValue": state.code,
93
- "onUpdate:modelValue": $event => state.code = $event,
103
+ "modelValue": currentCode.value,
104
+ "onUpdate:modelValue": $event => currentCode.value = $event,
94
105
  "clearable": true,
95
106
  "border": false,
96
107
  "class": bem('field'),
@@ -121,9 +132,11 @@ var _default = (0, _vue.defineComponent)({
121
132
  }, {
122
133
  default: () => [(0, _vue.createVNode)("div", {
123
134
  "class": bem('list', {
124
- 'with-bar': props.showExchangeBar,
125
135
  'with-bottom': props.showCloseButton
126
- })
136
+ }),
137
+ "style": {
138
+ height: listHeight.value + "px"
139
+ }
127
140
  }, [coupons.map((coupon, index) => (0, _vue.createVNode)(_coupon.Coupon, {
128
141
  "key": coupon.id,
129
142
  "ref": setCouponRefs(index),
@@ -148,9 +161,11 @@ var _default = (0, _vue.defineComponent)({
148
161
  }, {
149
162
  default: () => [(0, _vue.createVNode)("div", {
150
163
  "class": bem('list', {
151
- 'with-bar': props.showExchangeBar,
152
164
  'with-bottom': props.showCloseButton
153
- })
165
+ }),
166
+ "style": {
167
+ height: listHeight.value + "px"
168
+ }
154
169
  }, [disabledCoupons.map(coupon => (0, _vue.createVNode)(_coupon.Coupon, {
155
170
  "disabled": true,
156
171
  "key": coupon.id,
@@ -161,20 +176,22 @@ var _default = (0, _vue.defineComponent)({
161
176
  };
162
177
 
163
178
  (0, _vue.watch)(() => props.code, value => {
164
- state.code = value;
179
+ currentCode.value = value;
165
180
  });
166
- (0, _vue.watch)(() => state.code, value => emit('update:code', value));
181
+ (0, _vue.watch)(_utils.windowHeight, updateListHeight);
182
+ (0, _vue.watch)(currentCode, value => emit('update:code', value));
167
183
  (0, _vue.watch)(() => props.displayedCouponIndex, scrollToCoupon);
168
184
  (0, _vue.onMounted)(() => {
185
+ updateListHeight();
169
186
  scrollToCoupon(props.displayedCouponIndex);
170
187
  });
171
188
  return () => (0, _vue.createVNode)("div", {
189
+ "ref": root,
172
190
  "class": bem()
173
191
  }, [renderExchangeBar(), (0, _vue.createVNode)(_tabs.Tabs, {
174
- "active": state.tab,
175
- "onUpdate:active": $event => state.tab = $event,
176
- "class": bem('tab'),
177
- "border": false
192
+ "active": activeTab.value,
193
+ "onUpdate:active": $event => activeTab.value = $event,
194
+ "class": bem('tab')
178
195
  }, {
179
196
  default: () => [renderCouponTab(), renderDisabledTab()]
180
197
  }), (0, _vue.createVNode)("div", {
@@ -1 +1 @@
1
- :root{--van-coupon-list-background-color:var(--van-background-color);--van-coupon-list-field-padding:5px 0 5px var(--van-padding-md);--van-coupon-list-exchange-button-height:32px;--van-coupon-list-close-button-height:40px;--van-coupon-list-empty-image-size:200px;--van-coupon-list-empty-tip-color:var(--van-text-color-2);--van-coupon-list-empty-tip-font-size:var(--van-font-size-md);--van-coupon-list-empty-tip-line-height:var(--van-line-height-md)}.van-coupon-list{position:relative;height:100%;background:var(--van-coupon-list-background-color)}.van-coupon-list__field{padding:var(--van-coupon-list-field-padding)}.van-coupon-list__field .van-field__body{height:34px;padding-left:var(--van-padding-sm);line-height:34px;background:var(--van-gray-1);border-radius:17px}.van-coupon-list__field .van-field__body::-webkit-input-placeholder{color:var(--van-text-color-3)}.van-coupon-list__field .van-field__body::placeholder{color:var(--van-text-color-3)}.van-coupon-list__field .van-field__clear{margin-right:0}.van-coupon-list__exchange-bar{display:flex;align-items:center;background-color:var(--van-background-color-light)}.van-coupon-list__exchange{flex:none;height:var(--van-coupon-list-exchange-button-height);font-size:var(--van-font-size-lg);line-height:calc(var(--van-coupon-list-exchange-button-height) - 2px);border:0}.van-coupon-list .van-tabs__wrap{box-shadow:0 6px 12px -12px var(--van-gray-6)}.van-coupon-list__list{box-sizing:border-box;height:calc(100vh - 108px);padding:var(--van-padding-md) 0 var(--van-padding-lg);overflow-y:auto;-webkit-overflow-scrolling:touch}.van-coupon-list__list--with-bar{height:calc(100vh - 152px)}.van-coupon-list__list--with-bottom{padding-bottom:50px}.van-coupon-list__bottom{position:absolute;bottom:0;left:0;z-index:999;box-sizing:border-box;width:100%;padding:5px var(--van-padding-md);font-weight:var(--van-font-weight-bold);background-color:var(--van-background-color-light)}.van-coupon-list__close{height:var(--van-coupon-list-close-button-height)}.van-coupon-list__empty{padding-top:60px;text-align:center}.van-coupon-list__empty p{margin:var(--van-padding-md) 0;color:var(--van-coupon-list-empty-tip-color);font-size:var(--van-coupon-list-empty-tip-font-size);line-height:var(--van-coupon-list-empty-tip-line-height)}.van-coupon-list__empty img{width:var(--van-coupon-list-empty-image-size);height:var(--van-coupon-list-empty-image-size)}
1
+ :root{--van-coupon-list-background-color:var(--van-background-color);--van-coupon-list-field-padding:5px 0 5px var(--van-padding-md);--van-coupon-list-exchange-button-height:32px;--van-coupon-list-close-button-height:40px;--van-coupon-list-empty-image-size:200px;--van-coupon-list-empty-tip-color:var(--van-text-color-2);--van-coupon-list-empty-tip-font-size:var(--van-font-size-md);--van-coupon-list-empty-tip-line-height:var(--van-line-height-md)}.van-coupon-list{position:relative;height:100%;background:var(--van-coupon-list-background-color)}.van-coupon-list__field{padding:var(--van-coupon-list-field-padding)}.van-coupon-list__field .van-field__body{height:34px;padding-left:var(--van-padding-sm);line-height:34px;background:var(--van-gray-1);border-radius:17px}.van-coupon-list__field .van-field__body::-webkit-input-placeholder{color:var(--van-text-color-3)}.van-coupon-list__field .van-field__body::placeholder{color:var(--van-text-color-3)}.van-coupon-list__field .van-field__clear{margin-right:0}.van-coupon-list__exchange-bar{display:flex;align-items:center;background-color:var(--van-background-color-light)}.van-coupon-list__exchange{flex:none;height:var(--van-coupon-list-exchange-button-height);font-size:var(--van-font-size-lg);line-height:calc(var(--van-coupon-list-exchange-button-height) - 2px);border:0}.van-coupon-list .van-tabs__wrap{box-shadow:0 6px 12px -12px var(--van-gray-6)}.van-coupon-list__list{box-sizing:border-box;padding:var(--van-padding-md) 0 var(--van-padding-lg);overflow-y:auto;-webkit-overflow-scrolling:touch}.van-coupon-list__list--with-bottom{padding-bottom:50px}.van-coupon-list__bottom{position:absolute;bottom:0;left:0;z-index:999;box-sizing:border-box;width:100%;padding:5px var(--van-padding-md);font-weight:var(--van-font-weight-bold);background-color:var(--van-background-color-light)}.van-coupon-list__close{height:var(--van-coupon-list-close-button-height)}.van-coupon-list__empty{padding-top:60px;text-align:center}.van-coupon-list__empty p{margin:var(--van-padding-md) 0;color:var(--van-coupon-list-empty-tip-color);font-size:var(--van-coupon-list-empty-tip-font-size);line-height:var(--van-coupon-list-empty-tip-line-height)}.van-coupon-list__empty img{width:var(--van-coupon-list-empty-image-size);height:var(--van-coupon-list-empty-image-size)}
@@ -56,15 +56,10 @@
56
56
 
57
57
  &__list {
58
58
  box-sizing: border-box;
59
- height: calc(100vh - 108px);
60
59
  padding: var(--van-padding-md) 0 var(--van-padding-lg);
61
60
  overflow-y: auto;
62
61
  -webkit-overflow-scrolling: touch;
63
62
 
64
- &--with-bar {
65
- height: calc(100vh - 152px);
66
- }
67
-
68
63
  &--with-bottom {
69
64
  padding-bottom: 50px;
70
65
  }
@@ -49,7 +49,8 @@ var _default = (0, _vue.defineComponent)({
49
49
  showWrapper: false
50
50
  });
51
51
  var {
52
- parent
52
+ parent,
53
+ index
53
54
  } = (0, _use.useParent)(_DropdownMenu.DROPDOWN_KEY);
54
55
 
55
56
  if (!parent) {
@@ -138,7 +139,7 @@ var _default = (0, _vue.defineComponent)({
138
139
  };
139
140
 
140
141
  return (0, _vue.createVNode)(_cell.Cell, {
141
- "clickable": true,
142
+ "role": "menuitem",
142
143
  "key": option.value,
143
144
  "icon": option.icon,
144
145
  "title": option.text,
@@ -148,6 +149,8 @@ var _default = (0, _vue.defineComponent)({
148
149
  "style": {
149
150
  color: active ? activeColor : ''
150
151
  },
152
+ "tabindex": active ? 0 : -1,
153
+ "clickable": true,
151
154
  "onClick": onClick
152
155
  }, {
153
156
  value: renderIcon
@@ -180,6 +183,7 @@ var _default = (0, _vue.defineComponent)({
180
183
  }, [(0, _vue.createVNode)(_popup.Popup, {
181
184
  "show": state.showPopup,
182
185
  "onUpdate:show": $event => state.showPopup = $event,
186
+ "role": "menu",
183
187
  "class": bem('content'),
184
188
  "overlay": overlay,
185
189
  "position": direction === 'down' ? 'top' : 'bottom',
@@ -188,6 +192,7 @@ var _default = (0, _vue.defineComponent)({
188
192
  "overlayStyle": {
189
193
  position: 'absolute'
190
194
  },
195
+ "aria-labelledby": parent.id + "-" + index.value,
191
196
  "closeOnClickOverlay": closeOnClickOverlay,
192
197
  "onOpen": onOpen,
193
198
  "onClose": onClose,
@@ -9,17 +9,13 @@ export declare type DropdownItemExpose = {
9
9
  toggle: (show?: boolean, options?: {
10
10
  immediate?: boolean;
11
11
  }) => void;
12
- /**
13
- * @private
14
- */
12
+ /** @private */
15
13
  state: {
16
14
  showPopup: boolean;
17
15
  transition: boolean;
18
16
  showWrapper: boolean;
19
17
  };
20
- /**
21
- * @private
22
- */
18
+ /** @private */
23
19
  renderTitle: () => string | VNode[];
24
20
  };
25
21
  export declare type DropdownItemInstance = ComponentPublicInstance<DropdownItemProps, DropdownItemExpose>;
@@ -7,6 +7,8 @@ var _vue = require("vue");
7
7
 
8
8
  var _utils = require("../utils");
9
9
 
10
+ var _useId = require("../composables/use-id");
11
+
10
12
  var _use = require("@vant/use");
11
13
 
12
14
  // Utils
@@ -32,6 +34,7 @@ var _default = (0, _vue.defineComponent)({
32
34
  var {
33
35
  slots
34
36
  } = _ref;
37
+ var id = (0, _useId.useId)();
35
38
  var root = (0, _vue.ref)();
36
39
  var barRef = (0, _vue.ref)();
37
40
  var offset = (0, _vue.ref)(0);
@@ -64,7 +67,7 @@ var _default = (0, _vue.defineComponent)({
64
67
  if (props.direction === 'down') {
65
68
  offset.value = rect.bottom;
66
69
  } else {
67
- offset.value = window.innerHeight - rect.top;
70
+ offset.value = _utils.windowHeight.value - rect.top;
68
71
  }
69
72
  }
70
73
  };
@@ -97,8 +100,9 @@ var _default = (0, _vue.defineComponent)({
97
100
  titleClass
98
101
  } = item;
99
102
  return (0, _vue.createVNode)("div", {
103
+ "id": id + "-" + index,
100
104
  "role": "button",
101
- "tabindex": disabled ? -1 : 0,
105
+ "tabindex": disabled ? undefined : 0,
102
106
  "class": [bem('item', {
103
107
  disabled
104
108
  }), {
@@ -123,6 +127,7 @@ var _default = (0, _vue.defineComponent)({
123
127
  };
124
128
 
125
129
  linkChildren({
130
+ id,
126
131
  props,
127
132
  offset
128
133
  });
@@ -2,6 +2,7 @@ import type { Ref } from 'vue';
2
2
  import type { DropdownMenuProps } from './DropdownMenu';
3
3
  export declare type DropdownMenuDirection = 'up' | 'down';
4
4
  export declare type DropdownMenuProvide = {
5
+ id: string;
5
6
  props: DropdownMenuProps;
6
7
  offset: Ref<number>;
7
8
  };
@@ -17,71 +17,59 @@ var Network = (0, _vue.createVNode)("svg", {
17
17
  "viewBox": "0 0 160 160"
18
18
  }, [(0, _vue.createVNode)("defs", null, [(0, _vue.createVNode)("linearGradient", {
19
19
  "id": prefix + "1",
20
- "x1": "64.022%",
20
+ "x1": "64%",
21
21
  "y1": "100%",
22
- "x2": "64.022%"
22
+ "x2": "64%"
23
23
  }, [renderStop('#FFF', 0, 0.5), renderStop('#F2F3F5', 100)]), (0, _vue.createVNode)("linearGradient", {
24
24
  "id": prefix + "2",
25
25
  "x1": "50%",
26
26
  "x2": "50%",
27
- "y2": "84.459%"
27
+ "y2": "84%"
28
28
  }, [renderStop('#EBEDF0', 0), renderStop('#DCDEE0', 100, 0)]), (0, _vue.createVNode)("linearGradient", {
29
29
  "id": prefix + "3",
30
30
  "x1": "100%",
31
31
  "x2": "100%",
32
32
  "y2": "100%"
33
- }, [renderStop('#EAEDF0', 0), renderStop('#DCDEE0', 100)]), (0, _vue.createVNode)("linearGradient", {
34
- "id": prefix + "4",
35
- "x1": "100%",
36
- "y1": "100%",
37
- "x2": "100%"
38
33
  }, [renderStop('#EAEDF0', 0), renderStop('#DCDEE0', 100)]), (0, _vue.createVNode)("radialGradient", {
39
- "id": prefix + "5",
34
+ "id": prefix + "4",
40
35
  "cx": "50%",
41
36
  "cy": "0%",
42
37
  "fx": "50%",
43
38
  "fy": "0%",
44
39
  "r": "100%",
45
- "gradientTransform": "matrix(0 1 -.54835 0 .5 -.5)"
40
+ "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
46
41
  }, [renderStop('#EBEDF0', 0), renderStop('#FFF', 100, 0)])]), (0, _vue.createVNode)("g", {
47
42
  "fill": "none"
48
43
  }, [(0, _vue.createVNode)("g", {
49
44
  "opacity": ".8"
50
45
  }, [(0, _vue.createVNode)("path", {
51
- "d": "M0 124V46h20v20h14v58H0z",
52
- "fill": "url(#" + prefix + "1)",
53
- "transform": "matrix(-1 0 0 1 36 7)"
46
+ "d": "M36 131V53H16v20H2v58h34z",
47
+ "fill": "url(#" + prefix + "1)"
54
48
  }, null), (0, _vue.createVNode)("path", {
55
- "d": "M121 8h22.231v14H152v77.37h-31V8z",
56
- "fill": "url(#" + prefix + "1)",
57
- "transform": "translate(2 7)"
49
+ "d": "M123 15h22v14h9v77h-31V15z",
50
+ "fill": "url(#" + prefix + "1)"
58
51
  }, null)]), (0, _vue.createVNode)("path", {
59
- "fill": "url(#" + prefix + "5)",
52
+ "fill": "url(#" + prefix + "4)",
60
53
  "d": "M0 139h160v21H0z"
61
54
  }, null), (0, _vue.createVNode)("path", {
62
- "d": "M37 18a7 7 0 013 13.326v26.742c0 1.23-.997 2.227-2.227 2.227h-1.546A2.227 2.227 0 0134 58.068V31.326A7 7 0 0137 18z",
63
- "fill": "url(#" + prefix + "2)",
64
- "transform": "translate(43 36)"
55
+ "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
56
+ "fill": "url(#" + prefix + "2)"
65
57
  }, null), (0, _vue.createVNode)("g", {
66
58
  "opacity": ".6",
67
59
  "stroke-linecap": "round",
68
60
  "stroke-width": "7"
69
61
  }, [(0, _vue.createVNode)("path", {
70
- "d": "M20.875 11.136a18.868 18.868 0 00-5.284 13.121c0 5.094 2.012 9.718 5.284 13.12",
71
- "stroke": "url(#" + prefix + "3)",
72
- "transform": "translate(43 36)"
62
+ "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
63
+ "stroke": "url(#" + prefix + "3)"
73
64
  }, null), (0, _vue.createVNode)("path", {
74
- "d": "M9.849 0C3.756 6.225 0 14.747 0 24.146c0 9.398 3.756 17.92 9.849 24.145",
75
- "stroke": "url(#" + prefix + "3)",
76
- "transform": "translate(43 36)"
65
+ "d": "M53 36a34 34 0 0 0 0 48",
66
+ "stroke": "url(#" + prefix + "3)"
77
67
  }, null), (0, _vue.createVNode)("path", {
78
- "d": "M57.625 11.136a18.868 18.868 0 00-5.284 13.121c0 5.094 2.012 9.718 5.284 13.12",
79
- "stroke": "url(#" + prefix + "4)",
80
- "transform": "rotate(-180 76.483 42.257)"
68
+ "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
69
+ "stroke": "url(#" + prefix + "3)"
81
70
  }, null), (0, _vue.createVNode)("path", {
82
- "d": "M73.216 0c-6.093 6.225-9.849 14.747-9.849 24.146 0 9.398 3.756 17.92 9.849 24.145",
83
- "stroke": "url(#" + prefix + "4)",
84
- "transform": "rotate(-180 89.791 42.146)"
71
+ "d": "M106 84a34 34 0 0 0 0-48",
72
+ "stroke": "url(#" + prefix + "3)"
85
73
  }, null)]), (0, _vue.createVNode)("g", {
86
74
  "transform": "translate(31 105)"
87
75
  }, [(0, _vue.createVNode)("rect", {
@@ -95,13 +83,13 @@ var Network = (0, _vue.createVNode)("svg", {
95
83
  "y": "8",
96
84
  "width": "80",
97
85
  "height": "18",
98
- "rx": "1.114"
86
+ "rx": "1.1"
99
87
  }, null), (0, _vue.createVNode)("rect", {
100
88
  "fill": "#EBEDF0",
101
89
  "x": "15",
102
90
  "y": "12",
103
91
  "width": "18",
104
92
  "height": "6",
105
- "rx": "1.114"
93
+ "rx": "1.1"
106
94
  }, null)])])]);
107
95
  exports.Network = Network;
@@ -278,12 +278,12 @@ declare const _default: import("vue").DefineComponent<{
278
278
  value?: string | number | undefined;
279
279
  icon?: string | undefined;
280
280
  size?: import("../cell").CellSize | undefined;
281
+ id?: string | undefined;
281
282
  valueClass?: unknown;
282
283
  labelClass?: unknown;
283
284
  titleClass?: unknown;
284
285
  titleStyle?: string | import("vue").CSSProperties | undefined;
285
286
  arrowDirection?: import("../cell").CellArrowDirection | undefined;
286
- id?: string | undefined;
287
287
  leftIcon?: string | undefined;
288
288
  rightIcon?: string | undefined;
289
289
  maxlength?: string | number | undefined;
@@ -13,6 +13,8 @@ var _Cell = require("../cell/Cell");
13
13
 
14
14
  var _use = require("@vant/use");
15
15
 
16
+ var _useId = require("../composables/use-id");
17
+
16
18
  var _useExpose = require("../composables/use-expose");
17
19
 
18
20
  var _icon = require("../icon");
@@ -81,6 +83,7 @@ var _default = (0, _vue.defineComponent)({
81
83
  emit,
82
84
  slots
83
85
  } = _ref;
86
+ var id = (0, _useId.useId)();
84
87
  var state = (0, _vue.reactive)({
85
88
  focused: false,
86
89
  validateFailed: false,
@@ -285,14 +288,16 @@ var _default = (0, _vue.defineComponent)({
285
288
  emit('focus', event);
286
289
  (0, _vue.nextTick)(adjustTextareaSize); // readonly not work in legacy mobile safari
287
290
 
288
- var readonly = getProp('readonly');
289
-
290
- if (readonly) {
291
+ if (getProp('readonly')) {
291
292
  blur();
292
293
  }
293
294
  };
294
295
 
295
296
  var onBlur = event => {
297
+ if (getProp('readonly')) {
298
+ return;
299
+ }
300
+
296
301
  state.focused = false;
297
302
  updateValue(getModelValue(), 'onBlur');
298
303
  emit('blur', event);
@@ -351,6 +356,8 @@ var _default = (0, _vue.defineComponent)({
351
356
  emit('keypress', event);
352
357
  };
353
358
 
359
+ var getInputId = () => props.id || id + "-input";
360
+
354
361
  var renderInput = () => {
355
362
  var controlClass = bem('control', [getProp('inputAlign'), {
356
363
  error: showError.value,
@@ -366,7 +373,7 @@ var _default = (0, _vue.defineComponent)({
366
373
  }
367
374
 
368
375
  var inputAttrs = {
369
- id: props.id,
376
+ id: getInputId(),
370
377
  ref: inputRef,
371
378
  name: props.name,
372
379
  rows: props.rows !== undefined ? +props.rows : undefined,
@@ -377,6 +384,7 @@ var _default = (0, _vue.defineComponent)({
377
384
  autofocus: props.autofocus,
378
385
  placeholder: props.placeholder,
379
386
  autocomplete: props.autocomplete,
387
+ 'aria-labelledby': props.label ? id + "-label" : undefined,
380
388
  onBlur,
381
389
  onFocus,
382
390
  onInput,
@@ -460,7 +468,8 @@ var _default = (0, _vue.defineComponent)({
460
468
 
461
469
  if (props.label) {
462
470
  return (0, _vue.createVNode)("label", {
463
- "for": props.id
471
+ "id": id + "-label",
472
+ "for": getInputId()
464
473
  }, [props.label + colon]);
465
474
  }
466
475
  };
@@ -152,12 +152,12 @@ export declare const Field: import("../utils").WithInstall<import("vue").DefineC
152
152
  value?: string | number | undefined;
153
153
  icon?: string | undefined;
154
154
  size?: import("..").CellSize | undefined;
155
+ id?: string | undefined;
155
156
  valueClass?: unknown;
156
157
  labelClass?: unknown;
157
158
  titleClass?: unknown;
158
159
  titleStyle?: string | import("vue").CSSProperties | undefined;
159
160
  arrowDirection?: import("..").CellArrowDirection | undefined;
160
- id?: string | undefined;
161
161
  leftIcon?: string | undefined;
162
162
  rightIcon?: string | undefined;
163
163
  maxlength?: string | number | undefined;
@@ -201,4 +201,4 @@ export declare const Field: import("../utils").WithInstall<import("vue").DefineC
201
201
  }>>;
202
202
  export default Field;
203
203
  export type { FieldProps };
204
- export type { FieldType, FieldRule, FieldInstance, FieldTextAlign, FieldClearTrigger, FieldFormatTrigger, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, } from './types';
204
+ export type { FieldType, FieldRule, FieldInstance, FieldTextAlign, FieldRuleMessage, FieldClearTrigger, FieldFormatTrigger, FieldRuleValidator, FiledRuleFormatter, FieldValidateError, FieldAutosizeConfig, FieldValidateTrigger, } from './types';
@@ -13,13 +13,16 @@ export declare type FieldValidateError = {
13
13
  name?: string;
14
14
  message: string;
15
15
  };
16
+ export declare type FieldRuleMessage = string | ((value: any, rule: FieldRule) => string);
17
+ export declare type FieldRuleValidator = (value: any, rule: FieldRule) => boolean | string | Promise<boolean | string>;
18
+ export declare type FiledRuleFormatter = (value: any, rule: FieldRule) => string;
16
19
  export declare type FieldRule = {
17
20
  pattern?: RegExp;
18
21
  trigger?: FieldValidateTrigger;
19
- message?: string | ((value: any, rule: FieldRule) => string);
22
+ message?: FieldRuleMessage;
20
23
  required?: boolean;
21
- validator?: (value: any, rule: FieldRule) => boolean | string | Promise<boolean | string>;
22
- formatter?: (value: any, rule: FieldRule) => string;
24
+ validator?: FieldRuleValidator;
25
+ formatter?: FiledRuleFormatter;
23
26
  };
24
27
  export declare type FieldFormSharedProps = 'colon' | 'disabled' | 'readonly' | 'labelWidth' | 'labelAlign' | 'inputAlign' | 'errorMessageAlign';
25
28
  export declare type FieldExpose = {
@@ -27,9 +30,7 @@ export declare type FieldExpose = {
27
30
  focus: () => void | undefined;
28
31
  validate: (rules?: FieldRule[] | undefined) => Promise<void | FieldValidateError>;
29
32
  resetValidation: () => void;
30
- /**
31
- * @private
32
- */
33
+ /** @private */
33
34
  formValue: ComputedRef<unknown>;
34
35
  };
35
36
  export declare type FieldInstance = ComponentPublicInstance<FieldProps, FieldExpose>;
package/lib/form/Form.js CHANGED
@@ -154,7 +154,7 @@ var _default = (0, _vue.defineComponent)({
154
154
  };
155
155
 
156
156
  var onSubmit = event => {
157
- event.preventDefault();
157
+ (0, _utils.preventDefault)(event);
158
158
  submit();
159
159
  };
160
160
 
@@ -46,15 +46,10 @@ var _default = (0, _vue.defineComponent)({
46
46
  $Lazyload
47
47
  } = (0, _vue.getCurrentInstance)().proxy;
48
48
  var style = (0, _vue.computed)(() => {
49
- var style = {};
50
-
51
- if ((0, _utils.isDef)(props.width)) {
52
- style.width = (0, _utils.addUnit)(props.width);
53
- }
54
-
55
- if ((0, _utils.isDef)(props.height)) {
56
- style.height = (0, _utils.addUnit)(props.height);
57
- }
49
+ var style = {
50
+ width: (0, _utils.addUnit)(props.width),
51
+ height: (0, _utils.addUnit)(props.height)
52
+ };
58
53
 
59
54
  if ((0, _utils.isDef)(props.radius)) {
60
55
  style.overflow = 'hidden';
@@ -58,7 +58,6 @@ var _default = (0, _vue.defineComponent)({
58
58
  slots
59
59
  } = _ref;
60
60
  var swipeRef = (0, _vue.ref)();
61
- var windowSize = (0, _use.useWindowSize)();
62
61
  var state = (0, _vue.reactive)({
63
62
  active: 0,
64
63
  rootWidth: 0,
@@ -157,7 +156,7 @@ var _default = (0, _vue.defineComponent)({
157
156
  swipeTo
158
157
  });
159
158
  (0, _vue.onMounted)(resize);
160
- (0, _vue.watch)([windowSize.width, windowSize.height], resize);
159
+ (0, _vue.watch)([_utils.windowWidth, _utils.windowHeight], resize);
161
160
  (0, _vue.watch)(() => props.startPosition, value => setActive(+value));
162
161
  (0, _vue.watch)(() => props.show, value => {
163
162
  var {