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
@@ -7,6 +7,7 @@ import { useExpose } from '../composables/use-expose'; // Components
7
7
 
8
8
  import { Area } from '../area';
9
9
  import { Cell } from '../cell';
10
+ import { Form } from '../form';
10
11
  import { Field } from '../field';
11
12
  import { Popup } from '../popup';
12
13
  import { Toast } from '../toast';
@@ -74,18 +75,9 @@ export default defineComponent({
74
75
  slots
75
76
  } = _ref;
76
77
  var areaRef = ref();
77
- var state = reactive({
78
- data: {},
79
- showAreaPopup: false,
80
- detailFocused: false,
81
- errorInfo: {
82
- tel: '',
83
- name: '',
84
- areaCode: '',
85
- postalCode: '',
86
- addressDetail: ''
87
- }
88
- });
78
+ var data = reactive({});
79
+ var showAreaPopup = ref(false);
80
+ var detailFocused = ref(false);
89
81
  var areaListLoaded = computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
90
82
  var areaText = computed(() => {
91
83
  var {
@@ -94,7 +86,7 @@ export default defineComponent({
94
86
  city,
95
87
  county,
96
88
  areaCode
97
- } = state.data;
89
+ } = data;
98
90
 
99
91
  if (areaCode) {
100
92
  var arr = [country, province, city, county];
@@ -112,7 +104,7 @@ export default defineComponent({
112
104
  var hideBottomFields = computed(() => {
113
105
  var _props$searchResult;
114
106
 
115
- return ((_props$searchResult = props.searchResult) == null ? void 0 : _props$searchResult.length) && state.detailFocused;
107
+ return ((_props$searchResult = props.searchResult) == null ? void 0 : _props$searchResult.length) && detailFocused.value;
116
108
  });
117
109
 
118
110
  var assignAreaValues = () => {
@@ -120,77 +112,59 @@ export default defineComponent({
120
112
  var detail = areaRef.value.getArea();
121
113
  detail.areaCode = detail.code;
122
114
  delete detail.code;
123
- extend(state.data, detail);
115
+ extend(data, detail);
124
116
  }
125
117
  };
126
118
 
127
119
  var onFocus = key => {
128
- state.errorInfo[key] = '';
129
- state.detailFocused = key === 'addressDetail';
120
+ detailFocused.value = key === 'addressDetail';
130
121
  emit('focus', key);
131
122
  };
132
123
 
133
- var getErrorMessage = key => {
134
- var value = String(state.data[key] || '').trim();
135
-
136
- if (props.validator) {
137
- var message = props.validator(key, value);
138
-
139
- if (message) {
140
- return message;
141
- }
142
- }
143
-
144
- switch (key) {
145
- case 'name':
146
- return value ? '' : t('nameEmpty');
147
-
148
- case 'tel':
149
- return props.telValidator(value) ? '' : t('telInvalid');
150
-
151
- case 'areaCode':
152
- return value ? '' : t('areaEmpty');
153
-
154
- case 'addressDetail':
155
- return value ? '' : t('addressEmpty');
156
-
157
- case 'postalCode':
158
- return value && !props.postalValidator(value) ? t('postalEmpty') : '';
159
- }
160
- };
161
-
162
- var onSave = () => {
163
- var items = ['name', 'tel'];
164
-
165
- if (props.showArea) {
166
- items.push('areaCode');
167
- }
124
+ var rules = computed(() => {
125
+ var {
126
+ validator,
127
+ telValidator,
128
+ postalValidator
129
+ } = props;
168
130
 
169
- if (props.showDetail) {
170
- items.push('addressDetail');
171
- }
131
+ var makeRule = (name, emptyMessage) => ({
132
+ validator: value => {
133
+ if (validator) {
134
+ var message = validator(name, value);
172
135
 
173
- if (props.showPostal) {
174
- items.push('postalCode');
175
- }
136
+ if (message) {
137
+ return message;
138
+ }
139
+ }
176
140
 
177
- var isValid = items.every(item => {
178
- var msg = getErrorMessage(item);
141
+ if (!value) {
142
+ return emptyMessage;
143
+ }
179
144
 
180
- if (msg) {
181
- state.errorInfo[item] = msg;
145
+ return true;
182
146
  }
183
-
184
- return !msg;
185
147
  });
186
148
 
187
- if (isValid && !props.isSaving) {
188
- emit('save', state.data);
189
- }
190
- };
149
+ return {
150
+ name: [makeRule('name', t('nameEmpty'))],
151
+ tel: [makeRule('tel', t('telInvalid')), {
152
+ validator: telValidator,
153
+ message: t('telInvalid')
154
+ }],
155
+ areaCode: [makeRule('areaCode', t('areaEmpty'))],
156
+ addressDetail: [makeRule('addressDetail', t('addressEmpty'))],
157
+ postalCode: [makeRule('addressDetail', t('postalEmpty')), {
158
+ validator: postalValidator,
159
+ message: t('postalEmpty')
160
+ }]
161
+ };
162
+ });
163
+
164
+ var onSave = () => emit('save', data);
191
165
 
192
166
  var onChangeDetail = val => {
193
- state.data.addressDetail = val;
167
+ data.addressDetail = val;
194
168
  emit('change-detail', val);
195
169
  };
196
170
 
@@ -199,22 +173,25 @@ export default defineComponent({
199
173
 
200
174
  if (values.some(value => !value.code)) {
201
175
  Toast(t('areaEmpty'));
202
- return;
176
+ } else {
177
+ showAreaPopup.value = false;
178
+ assignAreaValues();
179
+ emit('change-area', values);
203
180
  }
204
-
205
- state.showAreaPopup = false;
206
- assignAreaValues();
207
- emit('change-area', values);
208
181
  };
209
182
 
210
- var onDelete = () => emit('delete', state.data); // get values of area component
183
+ var onDelete = () => emit('delete', data); // get values of area component
184
+
211
185
 
186
+ var getArea = () => {
187
+ var _areaRef$value;
212
188
 
213
- var getArea = () => areaRef.value ? areaRef.value.getValues() : []; // set area code to area component
189
+ return ((_areaRef$value = areaRef.value) == null ? void 0 : _areaRef$value.getValues()) || [];
190
+ }; // set area code to area component
214
191
 
215
192
 
216
193
  var setAreaCode = code => {
217
- state.data.areaCode = code || '';
194
+ data.areaCode = code || '';
218
195
 
219
196
  if (code) {
220
197
  nextTick(assignAreaValues);
@@ -224,20 +201,20 @@ export default defineComponent({
224
201
  var onDetailBlur = () => {
225
202
  // await for click search event
226
203
  setTimeout(() => {
227
- state.detailFocused = false;
204
+ detailFocused.value = false;
228
205
  });
229
206
  };
230
207
 
231
208
  var setAddressDetail = value => {
232
- state.data.addressDetail = value;
209
+ data.addressDetail = value;
233
210
  };
234
211
 
235
212
  var renderSetDefaultCell = () => {
236
213
  if (props.showSetDefault) {
237
214
  var _slots = {
238
215
  'right-icon': () => _createVNode(Switch, {
239
- "modelValue": state.data.isDefault,
240
- "onUpdate:modelValue": $event => state.data.isDefault = $event,
216
+ "modelValue": data.isDefault,
217
+ "onUpdate:modelValue": $event => data.isDefault = $event,
241
218
  "size": "24",
242
219
  "onChange": event => emit('change-default', event)
243
220
  }, null)
@@ -248,8 +225,6 @@ export default defineComponent({
248
225
  "class": bem('default')
249
226
  }, _slots), [[_vShow, !hideBottomFields.value]]);
250
227
  }
251
-
252
- return null;
253
228
  };
254
229
 
255
230
  useExpose({
@@ -257,115 +232,114 @@ export default defineComponent({
257
232
  setAreaCode,
258
233
  setAddressDetail
259
234
  });
260
- watch(() => props.areaList, () => setAreaCode(state.data.areaCode));
235
+ watch(() => props.areaList, () => setAreaCode(data.areaCode));
261
236
  watch(() => props.addressInfo, value => {
262
- state.data = extend({}, DEFAULT_DATA, value);
237
+ extend(data, DEFAULT_DATA, value);
263
238
  setAreaCode(value.areaCode);
264
239
  }, {
265
240
  deep: true,
266
241
  immediate: true
267
242
  });
268
243
  return () => {
269
- var {
270
- data,
271
- errorInfo
272
- } = state;
273
244
  var {
274
245
  disableArea
275
246
  } = props;
276
- return _createVNode("div", {
277
- "class": bem()
278
- }, [_createVNode("div", {
279
- "class": bem('fields')
280
- }, [_createVNode(Field, {
281
- "modelValue": data.name,
282
- "onUpdate:modelValue": $event => data.name = $event,
283
- "clearable": true,
284
- "label": t('name'),
285
- "placeholder": t('name'),
286
- "errorMessage": errorInfo.name,
287
- "onFocus": () => onFocus('name')
288
- }, null), _createVNode(Field, {
289
- "modelValue": data.tel,
290
- "onUpdate:modelValue": $event => data.tel = $event,
291
- "clearable": true,
292
- "type": "tel",
293
- "label": t('tel'),
294
- "maxlength": props.telMaxlength,
295
- "placeholder": t('tel'),
296
- "errorMessage": errorInfo.tel,
297
- "onFocus": () => onFocus('tel')
298
- }, null), _withDirectives(_createVNode(Field, {
299
- "readonly": true,
300
- "label": t('area'),
301
- "is-link": !disableArea,
302
- "modelValue": areaText.value,
303
- "placeholder": props.areaPlaceholder || t('area'),
304
- "errorMessage": errorInfo.areaCode,
305
- "onFocus": () => onFocus('areaCode'),
306
- "onClick": () => {
307
- emit('click-area');
308
- state.showAreaPopup = !disableArea;
309
- }
310
- }, null), [[_vShow, props.showArea]]), _createVNode(AddressEditDetail, {
311
- "show": props.showDetail,
312
- "value": data.addressDetail,
313
- "focused": state.detailFocused,
314
- "detailRows": props.detailRows,
315
- "errorMessage": errorInfo.addressDetail,
316
- "searchResult": props.searchResult,
317
- "detailMaxlength": props.detailMaxlength,
318
- "showSearchResult": props.showSearchResult,
319
- "onBlur": onDetailBlur,
320
- "onFocus": () => onFocus('addressDetail'),
321
- "onInput": onChangeDetail,
322
- "onSelect-search": event => emit('select-search', event)
323
- }, null), props.showPostal && _withDirectives(_createVNode(Field, {
324
- "modelValue": data.postalCode,
325
- "onUpdate:modelValue": $event => data.postalCode = $event,
326
- "type": "tel",
327
- "label": t('postal'),
328
- "maxlength": "6",
329
- "placeholder": t('postal'),
330
- "errorMessage": errorInfo.postalCode,
331
- "onFocus": () => onFocus('postalCode')
332
- }, null), [[_vShow, !hideBottomFields.value]]), slots.default == null ? void 0 : slots.default()]), renderSetDefaultCell(), _withDirectives(_createVNode("div", {
333
- "class": bem('buttons')
334
- }, [_createVNode(Button, {
335
- "block": true,
336
- "round": true,
337
- "type": "danger",
338
- "text": props.saveButtonText || t('save'),
339
- "class": bem('button'),
340
- "loading": props.isSaving,
341
- "onClick": onSave
342
- }, null), props.showDelete && _createVNode(Button, {
343
- "block": true,
344
- "round": true,
345
- "class": bem('button'),
346
- "loading": props.isDeleting,
347
- "text": props.deleteButtonText || t('delete'),
348
- "onClick": onDelete
349
- }, null)]), [[_vShow, !hideBottomFields.value]]), _createVNode(Popup, {
350
- "show": state.showAreaPopup,
351
- "onUpdate:show": $event => state.showAreaPopup = $event,
352
- "round": true,
353
- "teleport": "body",
354
- "position": "bottom",
355
- "lazyRender": false
247
+ return _createVNode(Form, {
248
+ "class": bem(),
249
+ "onSubmit": onSave
356
250
  }, {
357
- default: () => [_createVNode(Area, {
358
- "ref": areaRef,
359
- "value": data.areaCode,
360
- "loading": !areaListLoaded.value,
361
- "areaList": props.areaList,
362
- "columnsPlaceholder": props.areaColumnsPlaceholder,
363
- "onConfirm": onAreaConfirm,
364
- "onCancel": () => {
365
- state.showAreaPopup = false;
251
+ default: () => [_createVNode("div", {
252
+ "class": bem('fields')
253
+ }, [_createVNode(Field, {
254
+ "modelValue": data.name,
255
+ "onUpdate:modelValue": $event => data.name = $event,
256
+ "clearable": true,
257
+ "label": t('name'),
258
+ "rules": rules.value.name,
259
+ "placeholder": t('name'),
260
+ "onFocus": () => onFocus('name')
261
+ }, null), _createVNode(Field, {
262
+ "modelValue": data.tel,
263
+ "onUpdate:modelValue": $event => data.tel = $event,
264
+ "clearable": true,
265
+ "type": "tel",
266
+ "label": t('tel'),
267
+ "rules": rules.value.tel,
268
+ "maxlength": props.telMaxlength,
269
+ "placeholder": t('tel'),
270
+ "onFocus": () => onFocus('tel')
271
+ }, null), _withDirectives(_createVNode(Field, {
272
+ "readonly": true,
273
+ "label": t('area'),
274
+ "is-link": !disableArea,
275
+ "modelValue": areaText.value,
276
+ "rules": rules.value.areaCode,
277
+ "placeholder": props.areaPlaceholder || t('area'),
278
+ "onFocus": () => onFocus('areaCode'),
279
+ "onClick": () => {
280
+ emit('click-area');
281
+ showAreaPopup.value = !disableArea;
366
282
  }
367
- }, null)]
368
- })]);
283
+ }, null), [[_vShow, props.showArea]]), _createVNode(AddressEditDetail, {
284
+ "show": props.showDetail,
285
+ "rows": props.detailRows,
286
+ "rules": rules.value.addressDetail,
287
+ "value": data.addressDetail,
288
+ "focused": detailFocused.value,
289
+ "maxlength": props.detailMaxlength,
290
+ "searchResult": props.searchResult,
291
+ "showSearchResult": props.showSearchResult,
292
+ "onBlur": onDetailBlur,
293
+ "onFocus": () => onFocus('addressDetail'),
294
+ "onInput": onChangeDetail,
295
+ "onSelect-search": event => emit('select-search', event)
296
+ }, null), props.showPostal && _withDirectives(_createVNode(Field, {
297
+ "modelValue": data.postalCode,
298
+ "onUpdate:modelValue": $event => data.postalCode = $event,
299
+ "type": "tel",
300
+ "rules": rules.value.postalCode,
301
+ "label": t('postal'),
302
+ "maxlength": "6",
303
+ "placeholder": t('postal'),
304
+ "onFocus": () => onFocus('postalCode')
305
+ }, null), [[_vShow, !hideBottomFields.value]]), slots.default == null ? void 0 : slots.default()]), renderSetDefaultCell(), _withDirectives(_createVNode("div", {
306
+ "class": bem('buttons')
307
+ }, [_createVNode(Button, {
308
+ "block": true,
309
+ "round": true,
310
+ "type": "danger",
311
+ "text": props.saveButtonText || t('save'),
312
+ "class": bem('button'),
313
+ "loading": props.isSaving,
314
+ "nativeType": "submit"
315
+ }, null), props.showDelete && _createVNode(Button, {
316
+ "block": true,
317
+ "round": true,
318
+ "class": bem('button'),
319
+ "loading": props.isDeleting,
320
+ "text": props.deleteButtonText || t('delete'),
321
+ "onClick": onDelete
322
+ }, null)]), [[_vShow, !hideBottomFields.value]]), _createVNode(Popup, {
323
+ "show": showAreaPopup.value,
324
+ "onUpdate:show": $event => showAreaPopup.value = $event,
325
+ "round": true,
326
+ "teleport": "body",
327
+ "position": "bottom",
328
+ "lazyRender": false
329
+ }, {
330
+ default: () => [_createVNode(Area, {
331
+ "ref": areaRef,
332
+ "value": data.areaCode,
333
+ "loading": !areaListLoaded.value,
334
+ "areaList": props.areaList,
335
+ "columnsPlaceholder": props.areaColumnsPlaceholder,
336
+ "onConfirm": onAreaConfirm,
337
+ "onCancel": () => {
338
+ showAreaPopup.value = false;
339
+ }
340
+ }, null)]
341
+ })]
342
+ });
369
343
  };
370
344
  }
371
345
 
@@ -1,22 +1,23 @@
1
1
  import { PropType } from 'vue';
2
2
  import type { AddressEditSearchItem } from './types';
3
+ import type { FieldRule } from '../field/types';
3
4
  declare const _default: import("vue").DefineComponent<{
4
5
  show: BooleanConstructor;
6
+ rows: (NumberConstructor | StringConstructor)[];
5
7
  value: StringConstructor;
8
+ rules: PropType<FieldRule[]>;
6
9
  focused: BooleanConstructor;
7
- detailRows: (NumberConstructor | StringConstructor)[];
10
+ maxlength: (NumberConstructor | StringConstructor)[];
8
11
  searchResult: PropType<AddressEditSearchItem[]>;
9
- errorMessage: StringConstructor;
10
- detailMaxlength: (NumberConstructor | StringConstructor)[];
11
12
  showSearchResult: BooleanConstructor;
12
13
  }, () => JSX.Element | undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("input" | "focus" | "blur" | "select-search")[], "input" | "focus" | "blur" | "select-search", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("@vue/runtime-core").ComponentCustomProps, Readonly<{
13
14
  show?: unknown;
15
+ rows?: unknown;
14
16
  value?: unknown;
17
+ rules?: unknown;
15
18
  focused?: unknown;
16
- detailRows?: unknown;
19
+ maxlength?: unknown;
17
20
  searchResult?: unknown;
18
- errorMessage?: unknown;
19
- detailMaxlength?: unknown;
20
21
  showSearchResult?: unknown;
21
22
  } & {
22
23
  focused: boolean;
@@ -24,10 +25,10 @@ declare const _default: import("vue").DefineComponent<{
24
25
  showSearchResult: boolean;
25
26
  } & {
26
27
  value?: string | undefined;
27
- errorMessage?: string | undefined;
28
+ maxlength?: string | number | undefined;
29
+ rows?: string | number | undefined;
30
+ rules?: FieldRule[] | undefined;
28
31
  searchResult?: AddressEditSearchItem[] | undefined;
29
- detailRows?: string | number | undefined;
30
- detailMaxlength?: string | number | undefined;
31
32
  }> & {
32
33
  onFocus?: ((...args: any[]) => any) | undefined;
33
34
  onBlur?: ((...args: any[]) => any) | undefined;
@@ -11,12 +11,12 @@ export default defineComponent({
11
11
  name,
12
12
  props: {
13
13
  show: Boolean,
14
+ rows: numericProp,
14
15
  value: String,
16
+ rules: Array,
15
17
  focused: Boolean,
16
- detailRows: numericProp,
18
+ maxlength: numericProp,
17
19
  searchResult: Array,
18
- errorMessage: String,
19
- detailMaxlength: numericProp,
20
20
  showSearchResult: Boolean
21
21
  },
22
22
  emits: ['blur', 'focus', 'input', 'select-search'],
@@ -77,14 +77,14 @@ export default defineComponent({
77
77
  "clearable": true,
78
78
  "ref": field,
79
79
  "class": bem(),
80
- "rows": props.detailRows,
80
+ "rows": props.rows,
81
81
  "type": "textarea",
82
+ "rules": props.rules,
82
83
  "label": t('label'),
83
84
  "border": !showSearchResult(),
84
- "maxlength": props.detailMaxlength,
85
+ "maxlength": props.maxlength,
85
86
  "modelValue": props.value,
86
87
  "placeholder": t('placeholder'),
87
- "errorMessage": props.errorMessage,
88
88
  "onBlur": onBlur,
89
89
  "onFocus": onFocus,
90
90
  "onUpdate:modelValue": onInput
@@ -1,7 +1,7 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { defineComponent } from 'vue'; // Utils
3
3
 
4
- import { extend, numericProp, makeStringProp, createNamespace, BORDER_SURROUND } from '../utils';
4
+ import { extend, numericProp, preventDefault, makeStringProp, createNamespace, BORDER_SURROUND } from '../utils';
5
5
  import { useRoute, routeProps } from '../composables/use-route'; // Components
6
6
 
7
7
  import { Icon } from '../icon';
@@ -118,7 +118,7 @@ export default defineComponent({
118
118
 
119
119
  var onClick = event => {
120
120
  if (props.loading) {
121
- event.preventDefault();
121
+ preventDefault(event);
122
122
  } else if (!props.disabled) {
123
123
  emit('click', event);
124
124
  route();
@@ -220,7 +220,7 @@ export default defineComponent({
220
220
  months.value.some((month, index) => {
221
221
  if (compareMonth(month, targetDate) === 0) {
222
222
  if (bodyRef.value) {
223
- monthRefs.value[index].scrollIntoView(bodyRef.value);
223
+ monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
224
224
  }
225
225
 
226
226
  return true;
@@ -230,10 +230,9 @@ export default defineComponent({
230
230
  });
231
231
  onScroll();
232
232
  });
233
- }; // scroll to current month
234
-
233
+ };
235
234
 
236
- var scrollIntoView = () => {
235
+ var scrollToCurrentDate = () => {
237
236
  if (props.poppable && !props.show) {
238
237
  return;
239
238
  }
@@ -255,7 +254,7 @@ export default defineComponent({
255
254
  // add Math.floor to avoid decimal height issues
256
255
  // https://github.com/youzan/vant/issues/5640
257
256
  bodyHeight = Math.floor(useRect(bodyRef).height);
258
- scrollIntoView();
257
+ scrollToCurrentDate();
259
258
  });
260
259
  };
261
260
 
@@ -265,7 +264,7 @@ export default defineComponent({
265
264
  }
266
265
 
267
266
  currentDate.value = date;
268
- scrollIntoView();
267
+ scrollToCurrentDate();
269
268
  };
270
269
 
271
270
  var checkRange = date => {
@@ -303,13 +302,8 @@ export default defineComponent({
303
302
  var valid = checkRange(date);
304
303
 
305
304
  if (!valid) {
306
- // auto selected to max range if showConfirm
307
- if (props.showConfirm) {
308
- setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
309
- } else {
310
- setCurrentDate(date);
311
- }
312
-
305
+ // auto selected to max range
306
+ setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
313
307
  return;
314
308
  }
315
309
  }
@@ -467,7 +461,7 @@ export default defineComponent({
467
461
  }
468
462
 
469
463
  currentDate.value = value;
470
- scrollIntoView();
464
+ scrollToCurrentDate();
471
465
  });
472
466
  useExpose({
473
467
  reset,
@@ -30,9 +30,7 @@ export default defineComponent({
30
30
  }
31
31
  };
32
32
 
33
- var onClickSubtitle = event => {
34
- emit('click-subtitle', event);
35
- };
33
+ var onClickSubtitle = event => emit('click-subtitle', event);
36
34
 
37
35
  var renderSubtitle = () => {
38
36
  if (props.showSubtitle) {
@@ -58,15 +58,6 @@ export default defineComponent({
58
58
 
59
59
  var getTitle = () => title.value;
60
60
 
61
- var scrollIntoView = body => {
62
- var el = props.showSubtitle ? daysRef.value : monthRef.value;
63
-
64
- if (el) {
65
- var scrollTop = useRect(el).top - useRect(body).top + body.scrollTop;
66
- setScrollTop(body, scrollTop);
67
- }
68
- };
69
-
70
61
  var getMultipleDayType = day => {
71
62
  var isSelected = date => props.currentDate.some(item => compareDay(item, date) === 0);
72
63
 
@@ -219,6 +210,16 @@ export default defineComponent({
219
210
  });
220
211
  var disabledDays = computed(() => days.value.filter(day => day.type === 'disabled'));
221
212
 
213
+ var scrollToDate = (body, targetDate) => {
214
+ if (daysRef.value) {
215
+ var daysRect = useRect(daysRef.value);
216
+ var totalRows = placeholders.value.length;
217
+ var currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
218
+ var rowOffset = (currentRow - 1) * daysRect.height / totalRows;
219
+ setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
220
+ }
221
+ };
222
+
222
223
  var renderDay = (item, index) => _createVNode(CalendarDay, {
223
224
  "item": item,
224
225
  "index": index,
@@ -238,7 +239,7 @@ export default defineComponent({
238
239
  getTitle,
239
240
  getHeight: () => height.value,
240
241
  setVisible,
241
- scrollIntoView,
242
+ scrollToDate,
242
243
  disabledDays
243
244
  });
244
245
  return () => _createVNode("div", {
@@ -21,6 +21,6 @@ export declare type CalendarMonthInstance = ComponentPublicInstance<CalendarMont
21
21
  getTitle: () => string;
22
22
  getHeight: () => number;
23
23
  setVisible: (value?: boolean | undefined) => void;
24
- scrollIntoView: (body: Element) => void;
24
+ scrollToDate: (body: Element, targetDate: Date) => void;
25
25
  disabledDays: Ref<ComputedRef<CalendarDayItem[]>>;
26
26
  }>;