vant 2.12.34 → 2.12.38

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.
package/lib/index.js CHANGED
@@ -361,7 +361,7 @@ exports.TreeSelect = _treeSelect.default;
361
361
  var _uploader = _interopRequireDefault(require("./uploader"));
362
362
 
363
363
  exports.Uploader = _uploader.default;
364
- var version = '2.12.34';
364
+ var version = '2.12.38';
365
365
  exports.version = version;
366
366
 
367
367
  function install(Vue) {
@@ -5,14 +5,12 @@ exports.TouchMixin = void 0;
5
5
 
6
6
  var _event = require("../utils/dom/event");
7
7
 
8
- var MIN_DISTANCE = 10;
9
-
10
8
  function getDirection(x, y) {
11
- if (x > y && x > MIN_DISTANCE) {
9
+ if (x > y) {
12
10
  return 'horizontal';
13
11
  }
14
12
 
15
- if (y > x && y > MIN_DISTANCE) {
13
+ if (y > x) {
16
14
  return 'vertical';
17
15
  }
18
16
 
@@ -32,13 +30,18 @@ var TouchMixin = {
32
30
  this.startY = event.touches[0].clientY;
33
31
  },
34
32
  touchMove: function touchMove(event) {
35
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
33
+ var touch = event.touches[0]; // safari back will set clientX to negative number
36
34
 
37
35
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
38
36
  this.deltaY = touch.clientY - this.startY;
39
37
  this.offsetX = Math.abs(this.deltaX);
40
- this.offsetY = Math.abs(this.deltaY);
41
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
38
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
39
+
40
+ var LOCK_DIRECTION_DISTANCE = 10;
41
+
42
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
43
+ this.direction = getDirection(this.offsetX, this.offsetY);
44
+ }
42
45
  },
43
46
  resetTouchStatus: function resetTouchStatus() {
44
47
  this.direction = '';
@@ -243,6 +243,7 @@ var _default = createComponent({
243
243
  var renderButton = function renderButton(i) {
244
244
  var map = ['left', 'right'];
245
245
  var isNumber = typeof i === 'number';
246
+ var current = isNumber ? _this.value[i] : _this.value;
246
247
 
247
248
  var getClassName = function getClassName() {
248
249
  if (isNumber) {
@@ -260,6 +261,27 @@ var _default = createComponent({
260
261
  return "wrapper";
261
262
  };
262
263
 
264
+ var renderButtonContent = function renderButtonContent() {
265
+ if (isNumber) {
266
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
267
+ value: current
268
+ });
269
+
270
+ if (slot) {
271
+ return slot;
272
+ }
273
+ }
274
+
275
+ if (_this.slots('button')) {
276
+ return _this.slots('button');
277
+ }
278
+
279
+ return h("div", {
280
+ "class": bem('button'),
281
+ "style": _this.buttonStyle
282
+ });
283
+ };
284
+
263
285
  return h("div", {
264
286
  "ref": getRefName(),
265
287
  "attrs": {
@@ -282,10 +304,7 @@ var _default = createComponent({
282
304
  return e.stopPropagation();
283
305
  }
284
306
  }
285
- }, [_this.slots('button') || h("div", {
286
- "class": bem('button'),
287
- "style": _this.buttonStyle
288
- })]);
307
+ }, [renderButtonContent()]);
289
308
  };
290
309
 
291
310
  return h("div", {
@@ -1 +1 @@
1
- .van-swipe{position:relative;overflow:hidden;cursor:grab;-webkit-user-select:none;user-select:none}.van-swipe__track{display:-webkit-box;display:-webkit-flex;display:flex;height:100%}.van-swipe__track--vertical{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column}.van-swipe__indicators{position:absolute;bottom:12px;left:50%;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-transform:translateX(-50%);transform:translateX(-50%)}.van-swipe__indicators--vertical{top:50%;bottom:auto;left:12px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.van-swipe__indicators--vertical .van-swipe__indicator:not(:last-child){margin-bottom:6px}.van-swipe__indicator{width:6px;height:6px;background-color:#ebedf0;border-radius:100%;opacity:.3;-webkit-transition:opacity .2s,background-color .2s;transition:opacity .2s,background-color .2s}.van-swipe__indicator:not(:last-child){margin-right:6px}.van-swipe__indicator--active{background-color:#1989fa;opacity:1}
1
+ .van-swipe{position:relative;overflow:hidden;-webkit-transform:translateZ(0);transform:translateZ(0);cursor:grab;-webkit-user-select:none;user-select:none}.van-swipe__track{display:-webkit-box;display:-webkit-flex;display:flex;height:100%}.van-swipe__track--vertical{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column}.van-swipe__indicators{position:absolute;bottom:12px;left:50%;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-transform:translateX(-50%);transform:translateX(-50%)}.van-swipe__indicators--vertical{top:50%;bottom:auto;left:12px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.van-swipe__indicators--vertical .van-swipe__indicator:not(:last-child){margin-bottom:6px}.van-swipe__indicator{width:6px;height:6px;background-color:#ebedf0;border-radius:100%;opacity:.3;-webkit-transition:opacity .2s,background-color .2s;transition:opacity .2s,background-color .2s}.van-swipe__indicator:not(:last-child){margin-right:6px}.van-swipe__indicator--active{background-color:#1989fa;opacity:1}
@@ -193,16 +193,10 @@ var _default = createComponent({
193
193
  },
194
194
  onTouchMove: function onTouchMove(event) {
195
195
  if (!this.touchable || !this.swiping) return;
196
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
197
- // avoid affecting the parent components
198
-
199
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
200
-
201
- if (shouldPrevent) {
202
- (0, _event.preventDefault)(event, this.stopPropagation);
203
- }
196
+ this.touchMove(event);
204
197
 
205
198
  if (this.isCorrectDirection) {
199
+ (0, _event.preventDefault)(event, this.stopPropagation);
206
200
  this.move({
207
201
  offset: this.delta
208
202
  });
@@ -3,6 +3,8 @@
3
3
  .van-swipe {
4
4
  position: relative;
5
5
  overflow: hidden;
6
+ // https://github.com/youzan/vant/issues/9931
7
+ transform: translateZ(0);
6
8
  cursor: grab;
7
9
  user-select: none;
8
10
 
@@ -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": {
@@ -6677,11 +6681,9 @@ var Month_createNamespace = Object(create["a" /* createNamespace */])('calendar-
6677
6681
  },
6678
6682
  methods: {
6679
6683
  getHeight: function getHeight() {
6680
- if (!this.height) {
6681
- this.height = this.$el.getBoundingClientRect().height;
6682
- }
6684
+ var _this$$el;
6683
6685
 
6684
- return this.height;
6686
+ return ((_this$$el = this.$el) == null ? void 0 : _this$$el.getBoundingClientRect().height) || 0;
6685
6687
  },
6686
6688
  scrollIntoView: function scrollIntoView(body) {
6687
6689
  var _this$$refs = this.$refs,
@@ -7077,6 +7079,11 @@ var Header_createNamespace = Object(create["a" /* createNamespace */])('calendar
7077
7079
  }
7078
7080
  }
7079
7081
  },
7082
+ inject: {
7083
+ vanPopup: {
7084
+ default: null
7085
+ }
7086
+ },
7080
7087
  data: function data() {
7081
7088
  return {
7082
7089
  subtitle: '',
@@ -7127,7 +7134,11 @@ var Header_createNamespace = Object(create["a" /* createNamespace */])('calendar
7127
7134
  }
7128
7135
  },
7129
7136
  mounted: function mounted() {
7130
- this.init();
7137
+ var _this$vanPopup;
7138
+
7139
+ this.init(); // https://github.com/youzan/vant/issues/9845
7140
+
7141
+ (_this$vanPopup = this.vanPopup) == null ? void 0 : _this$vanPopup.$on('opened', this.onScroll);
7131
7142
  },
7132
7143
 
7133
7144
  /* istanbul ignore next */
@@ -10874,10 +10885,32 @@ var TimePickerMixin = {
10874
10885
  });
10875
10886
  },
10876
10887
  methods: {
10877
- // @exposed-api
10878
10888
  getPicker: function getPicker() {
10879
10889
  return this.$refs.picker;
10880
10890
  },
10891
+ // https://github.com/youzan/vant/issues/10013
10892
+ getProxiedPicker: function getProxiedPicker() {
10893
+ var _this4 = this;
10894
+
10895
+ var picker = this.$refs.picker;
10896
+
10897
+ if (picker) {
10898
+ var proxy = function proxy(fn) {
10899
+ return function () {
10900
+ picker[fn].apply(picker, arguments);
10901
+
10902
+ _this4.updateInnerValue();
10903
+ };
10904
+ };
10905
+
10906
+ return _extends({}, picker, {
10907
+ setValues: proxy('setValues'),
10908
+ setIndexes: proxy('setIndexes'),
10909
+ setColumnIndex: proxy('setColumnIndex'),
10910
+ setColumnValue: proxy('setColumnValue')
10911
+ });
10912
+ }
10913
+ },
10881
10914
  onConfirm: function onConfirm() {
10882
10915
  this.$emit('input', this.innerValue);
10883
10916
  this.$emit('confirm', this.innerValue);
@@ -10887,14 +10920,14 @@ var TimePickerMixin = {
10887
10920
  }
10888
10921
  },
10889
10922
  render: function render() {
10890
- var _this4 = this;
10923
+ var _this5 = this;
10891
10924
 
10892
10925
  var h = arguments[0];
10893
10926
  var props = {};
10894
10927
  Object.keys(pickerProps).forEach(function (key) {
10895
- props[key] = _this4[key];
10928
+ props[key] = _this5[key];
10896
10929
  });
10897
- return h(picker, {
10930
+ return h(es_picker, {
10898
10931
  "ref": "picker",
10899
10932
  "attrs": {
10900
10933
  "columns": this.columns,
@@ -11362,6 +11395,9 @@ var DatePicker_createNamespace = Object(create["a" /* createNamespace */])('date
11362
11395
  this.updateInnerValue();
11363
11396
  this.$nextTick(function () {
11364
11397
  _this4.$nextTick(function () {
11398
+ // https://github.com/youzan/vant/issues/9775
11399
+ _this4.updateInnerValue();
11400
+
11365
11401
  _this4.$emit('change', picker);
11366
11402
  });
11367
11403
  });
@@ -11414,7 +11450,7 @@ var datetime_picker_createNamespace = Object(create["a" /* createNamespace */])(
11414
11450
  methods: {
11415
11451
  // @exposed-api
11416
11452
  getPicker: function getPicker() {
11417
- return this.$refs.root.getPicker();
11453
+ return this.$refs.root.getProxiedPicker();
11418
11454
  }
11419
11455
  },
11420
11456
  render: function render() {
@@ -12784,16 +12820,10 @@ var swipe_createNamespace = Object(create["a" /* createNamespace */])('swipe'),
12784
12820
  },
12785
12821
  onTouchMove: function onTouchMove(event) {
12786
12822
  if (!this.touchable || !this.swiping) return;
12787
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
12788
- // avoid affecting the parent components
12789
-
12790
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
12791
-
12792
- if (shouldPrevent) {
12793
- preventDefault(event, this.stopPropagation);
12794
- }
12823
+ this.touchMove(event);
12795
12824
 
12796
12825
  if (this.isCorrectDirection) {
12826
+ preventDefault(event, this.stopPropagation);
12797
12827
  this.move({
12798
12828
  offset: this.delta
12799
12829
  });
@@ -13383,6 +13413,7 @@ function getDistance(touches) {
13383
13413
  className: null,
13384
13414
  closeable: Boolean,
13385
13415
  asyncClose: Boolean,
13416
+ overlayStyle: Object,
13386
13417
  showIndicators: Boolean,
13387
13418
  images: {
13388
13419
  type: Array,
@@ -13616,6 +13647,7 @@ var image_preview_defaultConfig = {
13616
13647
  asyncClose: false,
13617
13648
  transition: 'van-fade',
13618
13649
  getContainer: 'body',
13650
+ overlayStyle: null,
13619
13651
  startPosition: 0,
13620
13652
  swipeDuration: 300,
13621
13653
  showIndicators: false,
@@ -19140,6 +19172,14 @@ var uploader_createNamespace = Object(create["a" /* createNamespace */])('upload
19140
19172
  return this.fileList;
19141
19173
  }
19142
19174
  },
19175
+ created: function created() {
19176
+ this.urls = [];
19177
+ },
19178
+ beforeDestroy: function beforeDestroy() {
19179
+ this.urls.forEach(function (url) {
19180
+ return URL.revokeObjectURL(url);
19181
+ });
19182
+ },
19143
19183
  methods: {
19144
19184
  getDetail: function getDetail(index) {
19145
19185
  if (index === void 0) {
@@ -19318,7 +19358,13 @@ var uploader_createNamespace = Object(create["a" /* createNamespace */])('upload
19318
19358
  return isImageFile(item);
19319
19359
  });
19320
19360
  var imageContents = imageFiles.map(function (item) {
19321
- return item.content || item.url;
19361
+ if (item.file && !item.url) {
19362
+ item.url = URL.createObjectURL(item.file);
19363
+
19364
+ _this5.urls.push(item.url);
19365
+ }
19366
+
19367
+ return item.url;
19322
19368
  });
19323
19369
  this.imagePreview = image_preview(_extends({
19324
19370
  images: imageContents,
@@ -21061,6 +21107,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21061
21107
  var renderButton = function renderButton(i) {
21062
21108
  var map = ['left', 'right'];
21063
21109
  var isNumber = typeof i === 'number';
21110
+ var current = isNumber ? _this.value[i] : _this.value;
21064
21111
 
21065
21112
  var getClassName = function getClassName() {
21066
21113
  if (isNumber) {
@@ -21078,6 +21125,27 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21078
21125
  return "wrapper";
21079
21126
  };
21080
21127
 
21128
+ var renderButtonContent = function renderButtonContent() {
21129
+ if (isNumber) {
21130
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
21131
+ value: current
21132
+ });
21133
+
21134
+ if (slot) {
21135
+ return slot;
21136
+ }
21137
+ }
21138
+
21139
+ if (_this.slots('button')) {
21140
+ return _this.slots('button');
21141
+ }
21142
+
21143
+ return h("div", {
21144
+ "class": slider_bem('button'),
21145
+ "style": _this.buttonStyle
21146
+ });
21147
+ };
21148
+
21081
21149
  return h("div", {
21082
21150
  "ref": getRefName(),
21083
21151
  "attrs": {
@@ -21100,10 +21168,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21100
21168
  return e.stopPropagation();
21101
21169
  }
21102
21170
  }
21103
- }, [_this.slots('button') || h("div", {
21104
- "class": slider_bem('button'),
21105
- "style": _this.buttonStyle
21106
- })]);
21171
+ }, [renderButtonContent()]);
21107
21172
  };
21108
21173
 
21109
21174
  return h("div", {
@@ -22125,10 +22190,10 @@ TreeSelect.props = {
22125
22190
 
22126
22191
 
22127
22192
 
22128
- var version = '2.12.34';
22193
+ var version = '2.12.38';
22129
22194
 
22130
22195
  function install(Vue) {
22131
- 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];
22196
+ 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];
22132
22197
  components.forEach(function (item) {
22133
22198
  if (item.install) {
22134
22199
  Vue.use(item);