vant 2.12.35 → 2.12.39

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.
@@ -61,28 +61,36 @@ var _default = createComponent({
61
61
  children: 'setActiveItem'
62
62
  },
63
63
  mounted: function mounted() {
64
+ var _this = this;
65
+
64
66
  if (this.placeholder && this.fixed) {
65
- this.height = this.$refs.tabbar.getBoundingClientRect().height;
67
+ var setHeight = function setHeight() {
68
+ _this.height = _this.$refs.tabbar.getBoundingClientRect().height;
69
+ };
70
+
71
+ setHeight(); // https://github.com/youzan/vant/issues/10131
72
+
73
+ setTimeout(setHeight, 100);
66
74
  }
67
75
  },
68
76
  methods: {
69
77
  setActiveItem: function setActiveItem() {
70
- var _this = this;
78
+ var _this2 = this;
71
79
 
72
80
  this.children.forEach(function (item, index) {
73
- item.nameMatched = (item.name || index) === _this.value;
81
+ item.nameMatched = (item.name || index) === _this2.value;
74
82
  });
75
83
  },
76
84
  triggerChange: function triggerChange(active, afterChange) {
77
- var _this2 = this;
85
+ var _this3 = this;
78
86
 
79
87
  (0, _interceptor.callInterceptor)({
80
88
  interceptor: this.beforeChange,
81
89
  args: [active],
82
90
  done: function done() {
83
- _this2.$emit('input', active);
91
+ _this3.$emit('input', active);
84
92
 
85
- _this2.$emit('change', active);
93
+ _this3.$emit('change', active);
86
94
 
87
95
  afterChange();
88
96
  }
@@ -104,6 +104,14 @@ var _default2 = createComponent({
104
104
  return this.fileList;
105
105
  }
106
106
  },
107
+ created: function created() {
108
+ this.urls = [];
109
+ },
110
+ beforeDestroy: function beforeDestroy() {
111
+ this.urls.forEach(function (url) {
112
+ return URL.revokeObjectURL(url);
113
+ });
114
+ },
107
115
  methods: {
108
116
  getDetail: function getDetail(index) {
109
117
  if (index === void 0) {
@@ -282,7 +290,13 @@ var _default2 = createComponent({
282
290
  return (0, _utils2.isImageFile)(item);
283
291
  });
284
292
  var imageContents = imageFiles.map(function (item) {
285
- return item.content || item.url;
293
+ if (item.file && !item.url) {
294
+ item.url = URL.createObjectURL(item.file);
295
+
296
+ _this5.urls.push(item.url);
297
+ }
298
+
299
+ return item.url;
286
300
  });
287
301
  this.imagePreview = (0, _imagePreview.default)((0, _extends2.default)({
288
302
  images: imageContents,
package/lib/vant.js CHANGED
@@ -790,7 +790,7 @@ __webpack_require__.d(__webpack_exports__, "Overlay", function() { return /* ree
790
790
  __webpack_require__.d(__webpack_exports__, "Pagination", function() { return /* reexport */ pagination; });
791
791
  __webpack_require__.d(__webpack_exports__, "Panel", function() { return /* reexport */ panel; });
792
792
  __webpack_require__.d(__webpack_exports__, "PasswordInput", function() { return /* reexport */ password_input; });
793
- __webpack_require__.d(__webpack_exports__, "Picker", function() { return /* reexport */ picker; });
793
+ __webpack_require__.d(__webpack_exports__, "Picker", function() { return /* reexport */ es_picker; });
794
794
  __webpack_require__.d(__webpack_exports__, "Popover", function() { return /* reexport */ popover; });
795
795
  __webpack_require__.d(__webpack_exports__, "Popup", function() { return /* reexport */ popup; });
796
796
  __webpack_require__.d(__webpack_exports__, "Progress", function() { return /* reexport */ es_progress; });
@@ -1194,14 +1194,13 @@ function getVisibleTop(el) {
1194
1194
  }
1195
1195
  // CONCATENATED MODULE: ./es/mixins/touch.js
1196
1196
 
1197
- var MIN_DISTANCE = 10;
1198
1197
 
1199
1198
  function getDirection(x, y) {
1200
- if (x > y && x > MIN_DISTANCE) {
1199
+ if (x > y) {
1201
1200
  return 'horizontal';
1202
1201
  }
1203
1202
 
1204
- if (y > x && y > MIN_DISTANCE) {
1203
+ if (y > x) {
1205
1204
  return 'vertical';
1206
1205
  }
1207
1206
 
@@ -1221,13 +1220,18 @@ var TouchMixin = {
1221
1220
  this.startY = event.touches[0].clientY;
1222
1221
  },
1223
1222
  touchMove: function touchMove(event) {
1224
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
1223
+ var touch = event.touches[0]; // safari back will set clientX to negative number
1225
1224
 
1226
1225
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
1227
1226
  this.deltaY = touch.clientY - this.startY;
1228
1227
  this.offsetX = Math.abs(this.deltaX);
1229
- this.offsetY = Math.abs(this.deltaY);
1230
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
1228
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
1229
+
1230
+ var LOCK_DIRECTION_DISTANCE = 10;
1231
+
1232
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
1233
+ this.direction = getDirection(this.offsetX, this.offsetY);
1234
+ }
1231
1235
  },
1232
1236
  resetTouchStatus: function resetTouchStatus() {
1233
1237
  this.direction = '';
@@ -2560,7 +2564,7 @@ var picker_createNamespace = Object(create["a" /* createNamespace */])('picker')
2560
2564
  picker_bem = picker_createNamespace[1],
2561
2565
  t = picker_createNamespace[2];
2562
2566
 
2563
- /* harmony default export */ var picker = (picker_createComponent({
2567
+ /* harmony default export */ var es_picker = (picker_createComponent({
2564
2568
  props: _extends({}, pickerProps, {
2565
2569
  defaultIndex: {
2566
2570
  type: [Number, String],
@@ -3228,7 +3232,7 @@ function pickSlots(instance, keys) {
3228
3232
  confirm: this.onConfirm
3229
3233
  });
3230
3234
 
3231
- return h(picker, {
3235
+ return h(es_picker, {
3232
3236
  "ref": "picker",
3233
3237
  "class": area_bem(),
3234
3238
  "attrs": {
@@ -6557,6 +6561,10 @@ function copyDates(dates) {
6557
6561
  // CONCATENATED MODULE: ./es/datetime-picker/utils.js
6558
6562
 
6559
6563
  function times(n, iteratee) {
6564
+ if (n < 0) {
6565
+ return [];
6566
+ }
6567
+
6560
6568
  var index = -1;
6561
6569
  var result = Array(n);
6562
6570
 
@@ -6677,11 +6685,9 @@ var Month_createNamespace = Object(create["a" /* createNamespace */])('calendar-
6677
6685
  },
6678
6686
  methods: {
6679
6687
  getHeight: function getHeight() {
6680
- if (!this.height) {
6681
- this.height = this.$el.getBoundingClientRect().height;
6682
- }
6688
+ var _this$$el;
6683
6689
 
6684
- return this.height;
6690
+ return ((_this$$el = this.$el) == null ? void 0 : _this$$el.getBoundingClientRect().height) || 0;
6685
6691
  },
6686
6692
  scrollIntoView: function scrollIntoView(body) {
6687
6693
  var _this$$refs = this.$refs,
@@ -7077,6 +7083,11 @@ var Header_createNamespace = Object(create["a" /* createNamespace */])('calendar
7077
7083
  }
7078
7084
  }
7079
7085
  },
7086
+ inject: {
7087
+ vanPopup: {
7088
+ default: null
7089
+ }
7090
+ },
7080
7091
  data: function data() {
7081
7092
  return {
7082
7093
  subtitle: '',
@@ -7127,7 +7138,11 @@ var Header_createNamespace = Object(create["a" /* createNamespace */])('calendar
7127
7138
  }
7128
7139
  },
7129
7140
  mounted: function mounted() {
7130
- this.init();
7141
+ var _this$vanPopup;
7142
+
7143
+ this.init(); // https://github.com/youzan/vant/issues/9845
7144
+
7145
+ (_this$vanPopup = this.vanPopup) == null ? void 0 : _this$vanPopup.$on('opened', this.onScroll);
7131
7146
  },
7132
7147
 
7133
7148
  /* istanbul ignore next */
@@ -10874,10 +10889,32 @@ var TimePickerMixin = {
10874
10889
  });
10875
10890
  },
10876
10891
  methods: {
10877
- // @exposed-api
10878
10892
  getPicker: function getPicker() {
10879
10893
  return this.$refs.picker;
10880
10894
  },
10895
+ // https://github.com/youzan/vant/issues/10013
10896
+ getProxiedPicker: function getProxiedPicker() {
10897
+ var _this4 = this;
10898
+
10899
+ var picker = this.$refs.picker;
10900
+
10901
+ if (picker) {
10902
+ var proxy = function proxy(fn) {
10903
+ return function () {
10904
+ picker[fn].apply(picker, arguments);
10905
+
10906
+ _this4.updateInnerValue();
10907
+ };
10908
+ };
10909
+
10910
+ return _extends({}, picker, {
10911
+ setValues: proxy('setValues'),
10912
+ setIndexes: proxy('setIndexes'),
10913
+ setColumnIndex: proxy('setColumnIndex'),
10914
+ setColumnValue: proxy('setColumnValue')
10915
+ });
10916
+ }
10917
+ },
10881
10918
  onConfirm: function onConfirm() {
10882
10919
  this.$emit('input', this.innerValue);
10883
10920
  this.$emit('confirm', this.innerValue);
@@ -10887,14 +10924,14 @@ var TimePickerMixin = {
10887
10924
  }
10888
10925
  },
10889
10926
  render: function render() {
10890
- var _this4 = this;
10927
+ var _this5 = this;
10891
10928
 
10892
10929
  var h = arguments[0];
10893
10930
  var props = {};
10894
10931
  Object.keys(pickerProps).forEach(function (key) {
10895
- props[key] = _this4[key];
10932
+ props[key] = _this5[key];
10896
10933
  });
10897
- return h(picker, {
10934
+ return h(es_picker, {
10898
10935
  "ref": "picker",
10899
10936
  "attrs": {
10900
10937
  "columns": this.columns,
@@ -11417,7 +11454,7 @@ var datetime_picker_createNamespace = Object(create["a" /* createNamespace */])(
11417
11454
  methods: {
11418
11455
  // @exposed-api
11419
11456
  getPicker: function getPicker() {
11420
- return this.$refs.root.getPicker();
11457
+ return this.$refs.root.getProxiedPicker();
11421
11458
  }
11422
11459
  },
11423
11460
  render: function render() {
@@ -12787,16 +12824,10 @@ var swipe_createNamespace = Object(create["a" /* createNamespace */])('swipe'),
12787
12824
  },
12788
12825
  onTouchMove: function onTouchMove(event) {
12789
12826
  if (!this.touchable || !this.swiping) return;
12790
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
12791
- // avoid affecting the parent components
12792
-
12793
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
12794
-
12795
- if (shouldPrevent) {
12796
- preventDefault(event, this.stopPropagation);
12797
- }
12827
+ this.touchMove(event);
12798
12828
 
12799
12829
  if (this.isCorrectDirection) {
12830
+ preventDefault(event, this.stopPropagation);
12800
12831
  this.move({
12801
12832
  offset: this.delta
12802
12833
  });
@@ -13238,10 +13269,11 @@ function getDistance(touches) {
13238
13269
  offsetX = _this$offsetX === void 0 ? 0 : _this$offsetX;
13239
13270
  this.touchStart(event);
13240
13271
  this.touchStartTime = new Date();
13272
+ this.fingerNum = touches.length;
13241
13273
  this.startMoveX = this.moveX;
13242
13274
  this.startMoveY = this.moveY;
13243
- this.moving = touches.length === 1 && this.scale !== 1;
13244
- this.zooming = touches.length === 2 && !offsetX;
13275
+ this.moving = this.fingerNum === 1 && this.scale !== 1;
13276
+ this.zooming = this.fingerNum === 2 && !offsetX;
13245
13277
 
13246
13278
  if (this.zooming) {
13247
13279
  this.startScale = this.scale;
@@ -13306,13 +13338,17 @@ function getDistance(touches) {
13306
13338
  checkTap: function checkTap() {
13307
13339
  var _this = this;
13308
13340
 
13341
+ if (this.fingerNum > 1) {
13342
+ return;
13343
+ }
13344
+
13309
13345
  var _this$offsetX2 = this.offsetX,
13310
13346
  offsetX = _this$offsetX2 === void 0 ? 0 : _this$offsetX2,
13311
13347
  _this$offsetY = this.offsetY,
13312
13348
  offsetY = _this$offsetY === void 0 ? 0 : _this$offsetY;
13313
13349
  var deltaTime = new Date() - this.touchStartTime;
13314
13350
  var TAP_TIME = 250;
13315
- var TAP_OFFSET = 10;
13351
+ var TAP_OFFSET = 5;
13316
13352
 
13317
13353
  if (offsetX < TAP_OFFSET && offsetY < TAP_OFFSET && deltaTime < TAP_TIME) {
13318
13354
  if (this.doubleTapTimer) {
@@ -13386,6 +13422,7 @@ function getDistance(touches) {
13386
13422
  className: null,
13387
13423
  closeable: Boolean,
13388
13424
  asyncClose: Boolean,
13425
+ overlayStyle: Object,
13389
13426
  showIndicators: Boolean,
13390
13427
  images: {
13391
13428
  type: Array,
@@ -13619,6 +13656,7 @@ var image_preview_defaultConfig = {
13619
13656
  asyncClose: false,
13620
13657
  transition: 'van-fade',
13621
13658
  getContainer: 'body',
13659
+ overlayStyle: null,
13622
13660
  startPosition: 0,
13623
13661
  swipeDuration: 300,
13624
13662
  showIndicators: false,
@@ -14215,8 +14253,16 @@ var nav_bar_createNamespace = Object(create["a" /* createNamespace */])('nav-bar
14215
14253
  };
14216
14254
  },
14217
14255
  mounted: function mounted() {
14256
+ var _this = this;
14257
+
14218
14258
  if (this.placeholder && this.fixed) {
14219
- this.height = this.$refs.navBar.getBoundingClientRect().height;
14259
+ var setHeight = function setHeight() {
14260
+ _this.height = _this.$refs.navBar.getBoundingClientRect().height;
14261
+ };
14262
+
14263
+ setHeight(); // https://github.com/youzan/vant/issues/10131
14264
+
14265
+ setTimeout(setHeight, 100);
14220
14266
  }
14221
14267
  },
14222
14268
  methods: {
@@ -19143,6 +19189,14 @@ var uploader_createNamespace = Object(create["a" /* createNamespace */])('upload
19143
19189
  return this.fileList;
19144
19190
  }
19145
19191
  },
19192
+ created: function created() {
19193
+ this.urls = [];
19194
+ },
19195
+ beforeDestroy: function beforeDestroy() {
19196
+ this.urls.forEach(function (url) {
19197
+ return URL.revokeObjectURL(url);
19198
+ });
19199
+ },
19146
19200
  methods: {
19147
19201
  getDetail: function getDetail(index) {
19148
19202
  if (index === void 0) {
@@ -19321,7 +19375,13 @@ var uploader_createNamespace = Object(create["a" /* createNamespace */])('upload
19321
19375
  return isImageFile(item);
19322
19376
  });
19323
19377
  var imageContents = imageFiles.map(function (item) {
19324
- return item.content || item.url;
19378
+ if (item.file && !item.url) {
19379
+ item.url = URL.createObjectURL(item.file);
19380
+
19381
+ _this5.urls.push(item.url);
19382
+ }
19383
+
19384
+ return item.url;
19325
19385
  });
19326
19386
  this.imagePreview = image_preview(_extends({
19327
19387
  images: imageContents,
@@ -21064,6 +21124,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21064
21124
  var renderButton = function renderButton(i) {
21065
21125
  var map = ['left', 'right'];
21066
21126
  var isNumber = typeof i === 'number';
21127
+ var current = isNumber ? _this.value[i] : _this.value;
21067
21128
 
21068
21129
  var getClassName = function getClassName() {
21069
21130
  if (isNumber) {
@@ -21081,6 +21142,27 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21081
21142
  return "wrapper";
21082
21143
  };
21083
21144
 
21145
+ var renderButtonContent = function renderButtonContent() {
21146
+ if (isNumber) {
21147
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
21148
+ value: current
21149
+ });
21150
+
21151
+ if (slot) {
21152
+ return slot;
21153
+ }
21154
+ }
21155
+
21156
+ if (_this.slots('button')) {
21157
+ return _this.slots('button');
21158
+ }
21159
+
21160
+ return h("div", {
21161
+ "class": slider_bem('button'),
21162
+ "style": _this.buttonStyle
21163
+ });
21164
+ };
21165
+
21084
21166
  return h("div", {
21085
21167
  "ref": getRefName(),
21086
21168
  "attrs": {
@@ -21103,10 +21185,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21103
21185
  return e.stopPropagation();
21104
21186
  }
21105
21187
  }
21106
- }, [_this.slots('button') || h("div", {
21107
- "class": slider_bem('button'),
21108
- "style": _this.buttonStyle
21109
- })]);
21188
+ }, [renderButtonContent()]);
21110
21189
  };
21111
21190
 
21112
21191
  return h("div", {
@@ -21723,28 +21802,36 @@ var tabbar_createNamespace = Object(create["a" /* createNamespace */])('tabbar')
21723
21802
  children: 'setActiveItem'
21724
21803
  },
21725
21804
  mounted: function mounted() {
21805
+ var _this = this;
21806
+
21726
21807
  if (this.placeholder && this.fixed) {
21727
- this.height = this.$refs.tabbar.getBoundingClientRect().height;
21808
+ var setHeight = function setHeight() {
21809
+ _this.height = _this.$refs.tabbar.getBoundingClientRect().height;
21810
+ };
21811
+
21812
+ setHeight(); // https://github.com/youzan/vant/issues/10131
21813
+
21814
+ setTimeout(setHeight, 100);
21728
21815
  }
21729
21816
  },
21730
21817
  methods: {
21731
21818
  setActiveItem: function setActiveItem() {
21732
- var _this = this;
21819
+ var _this2 = this;
21733
21820
 
21734
21821
  this.children.forEach(function (item, index) {
21735
- item.nameMatched = (item.name || index) === _this.value;
21822
+ item.nameMatched = (item.name || index) === _this2.value;
21736
21823
  });
21737
21824
  },
21738
21825
  triggerChange: function triggerChange(active, afterChange) {
21739
- var _this2 = this;
21826
+ var _this3 = this;
21740
21827
 
21741
21828
  callInterceptor({
21742
21829
  interceptor: this.beforeChange,
21743
21830
  args: [active],
21744
21831
  done: function done() {
21745
- _this2.$emit('input', active);
21832
+ _this3.$emit('input', active);
21746
21833
 
21747
- _this2.$emit('change', active);
21834
+ _this3.$emit('change', active);
21748
21835
 
21749
21836
  afterChange();
21750
21837
  }
@@ -22128,10 +22215,10 @@ TreeSelect.props = {
22128
22215
 
22129
22216
 
22130
22217
 
22131
- var version = '2.12.35';
22218
+ var version = '2.12.39';
22132
22219
 
22133
22220
  function install(Vue) {
22134
- var components = [action_sheet, address_edit, address_list, es_area, badge, es_button, calendar, card, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, contact_card, contact_edit, contact_list, count_down, es_coupon, coupon_cell, coupon_list, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, es_form, goods_action, goods_action_button, goods_action_icon, grid, grid_item, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, es_list, es_loading, locale["a" /* default */], nav_bar, notice_bar, notify, number_keyboard, es_overlay, pagination, panel, password_input, picker, popover, popup, es_progress, pull_refresh, es_radio, radio_group, es_rate, row, search, share_sheet, sidebar, sidebar_item, skeleton, es_sku, slider, es_step, stepper, steps, es_sticky, submit_bar, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, tabs, es_tag, es_toast, tree_select, uploader];
22221
+ var components = [action_sheet, address_edit, address_list, es_area, badge, es_button, calendar, card, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, contact_card, contact_edit, contact_list, count_down, es_coupon, coupon_cell, coupon_list, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, es_form, goods_action, goods_action_button, goods_action_icon, grid, grid_item, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, es_list, es_loading, locale["a" /* default */], nav_bar, notice_bar, notify, number_keyboard, es_overlay, pagination, panel, password_input, es_picker, popover, popup, es_progress, pull_refresh, es_radio, radio_group, es_rate, row, search, share_sheet, sidebar, sidebar_item, skeleton, es_sku, slider, es_step, stepper, steps, es_sticky, submit_bar, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, tabs, es_tag, es_toast, tree_select, uploader];
22135
22222
  components.forEach(function (item) {
22136
22223
  if (item.install) {
22137
22224
  Vue.use(item);