vant 2.12.30 → 2.12.34-beta.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.
package/lib/vant.js CHANGED
@@ -2221,8 +2221,12 @@ function getElementTranslateY(element) {
2221
2221
 
2222
2222
  function isOptionDisabled(option) {
2223
2223
  return Object(utils["f" /* isObject */])(option) && option.disabled;
2224
- }
2224
+ } // use standard WheelEvent:
2225
+ // https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
2226
+
2225
2227
 
2228
+ var supportMousewheel = utils["b" /* inBrowser */] && 'onwheel' in window;
2229
+ var mousewheelTimer = null;
2226
2230
  /* harmony default export */ var PickerColumn = (PickerColumn_createComponent({
2227
2231
  mixins: [TouchMixin],
2228
2232
  props: {
@@ -2258,6 +2262,10 @@ function isOptionDisabled(option) {
2258
2262
  },
2259
2263
  mounted: function mounted() {
2260
2264
  this.bindTouchEvent(this.$el);
2265
+
2266
+ if (supportMousewheel) {
2267
+ event_on(this.$el, 'wheel', this.onMouseWheel, false);
2268
+ }
2261
2269
  },
2262
2270
  destroyed: function destroyed() {
2263
2271
  var children = this.$parent.children;
@@ -2265,6 +2273,10 @@ function isOptionDisabled(option) {
2265
2273
  if (children) {
2266
2274
  children.splice(children.indexOf(this), 1);
2267
2275
  }
2276
+
2277
+ if (supportMousewheel) {
2278
+ off(this.$el, 'wheel');
2279
+ }
2268
2280
  },
2269
2281
  watch: {
2270
2282
  initialOptions: 'setOptions',
@@ -2352,6 +2364,43 @@ function isOptionDisabled(option) {
2352
2364
  _this.moving = false;
2353
2365
  }, 0);
2354
2366
  },
2367
+ onMouseWheel: function onMouseWheel(event) {
2368
+ var _this2 = this;
2369
+
2370
+ if (this.readonly) {
2371
+ return;
2372
+ }
2373
+
2374
+ preventDefault(event, true); // simply combine touchstart and touchmove
2375
+
2376
+ var translateY = getElementTranslateY(this.$refs.wrapper);
2377
+ this.startOffset = Math.min(0, translateY - this.baseOffset);
2378
+ this.momentumOffset = this.startOffset;
2379
+ this.transitionEndTrigger = null; // directly use deltaY, see https://caniuse.com/?search=deltaY
2380
+ // use deltaY to detect direction for not special setting device
2381
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event
2382
+
2383
+ var deltaY = event.deltaY;
2384
+
2385
+ if (this.startOffset === 0 && deltaY < 0) {
2386
+ return;
2387
+ } // get offset
2388
+ // if necessary, can adjust distance value to make scrolling smoother
2389
+
2390
+
2391
+ var distance = -deltaY;
2392
+ this.offset = range(this.startOffset + distance, -(this.count * this.itemHeight), this.itemHeight);
2393
+
2394
+ if (mousewheelTimer) {
2395
+ clearTimeout(mousewheelTimer);
2396
+ }
2397
+
2398
+ mousewheelTimer = setTimeout(function () {
2399
+ _this2.onTouchEnd();
2400
+
2401
+ _this2.touchStartTime = 0;
2402
+ }, MOMENTUM_LIMIT_TIME);
2403
+ },
2355
2404
  onTransitionEnd: function onTransitionEnd() {
2356
2405
  this.stopMomentum();
2357
2406
  },
@@ -2383,17 +2432,17 @@ function isOptionDisabled(option) {
2383
2432
  return option;
2384
2433
  },
2385
2434
  setIndex: function setIndex(index, emitChange) {
2386
- var _this2 = this;
2435
+ var _this3 = this;
2387
2436
 
2388
2437
  index = this.adjustIndex(index) || 0;
2389
2438
  var offset = -index * this.itemHeight;
2390
2439
 
2391
2440
  var trigger = function trigger() {
2392
- if (index !== _this2.currentIndex) {
2393
- _this2.currentIndex = index;
2441
+ if (index !== _this3.currentIndex) {
2442
+ _this3.currentIndex = index;
2394
2443
 
2395
2444
  if (emitChange) {
2396
- _this2.$emit('change', index);
2445
+ _this3.$emit('change', index);
2397
2446
  }
2398
2447
  }
2399
2448
  }; // trigger the change event after transitionend when moving
@@ -2439,7 +2488,7 @@ function isOptionDisabled(option) {
2439
2488
  }
2440
2489
  },
2441
2490
  genOptions: function genOptions() {
2442
- var _this3 = this;
2491
+ var _this4 = this;
2443
2492
 
2444
2493
  var h = this.$createElement;
2445
2494
  var optionStyle = {
@@ -2448,7 +2497,7 @@ function isOptionDisabled(option) {
2448
2497
  return this.options.map(function (option, index) {
2449
2498
  var _domProps;
2450
2499
 
2451
- var text = _this3.getOptionText(option);
2500
+ var text = _this4.getOptionText(option);
2452
2501
 
2453
2502
  var disabled = isOptionDisabled(option);
2454
2503
  var data = {
@@ -2459,19 +2508,19 @@ function isOptionDisabled(option) {
2459
2508
  },
2460
2509
  class: [PickerColumn_bem('item', {
2461
2510
  disabled: disabled,
2462
- selected: index === _this3.currentIndex
2511
+ selected: index === _this4.currentIndex
2463
2512
  })],
2464
2513
  on: {
2465
2514
  click: function click() {
2466
- _this3.onClickItem(index);
2515
+ _this4.onClickItem(index);
2467
2516
  }
2468
2517
  }
2469
2518
  };
2470
2519
  var childData = {
2471
2520
  class: 'van-ellipsis',
2472
- domProps: (_domProps = {}, _domProps[_this3.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
2521
+ domProps: (_domProps = {}, _domProps[_this4.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
2473
2522
  };
2474
- return h("li", helper_default()([{}, data]), [_this3.slots('option', option) || h("div", helper_default()([{}, childData]))]);
2523
+ return h("li", helper_default()([{}, data]), [_this4.slots('option', option) || h("div", helper_default()([{}, childData]))]);
2475
2524
  });
2476
2525
  }
2477
2526
  },
@@ -3745,21 +3794,26 @@ var field_createNamespace = Object(create["a" /* createNamespace */])('field'),
3745
3794
  },
3746
3795
  onFocus: function onFocus(event) {
3747
3796
  this.focused = true;
3748
- this.$emit('focus', event); // readonly not work in legacy mobile safari
3797
+ this.$emit('focus', event); // https://github.com/youzan/vant/issues/9715
3749
3798
 
3750
- /* istanbul ignore if */
3799
+ this.$nextTick(this.adjustSize); // readonly not work in legacy mobile safari
3751
3800
 
3752
- var readonly = this.getProp('readonly');
3801
+ /* istanbul ignore if */
3753
3802
 
3754
- if (readonly) {
3803
+ if (this.getProp('readonly')) {
3755
3804
  this.blur();
3756
3805
  }
3757
3806
  },
3758
3807
  onBlur: function onBlur(event) {
3808
+ if (this.getProp('readonly')) {
3809
+ return;
3810
+ }
3811
+
3759
3812
  this.focused = false;
3760
3813
  this.updateValue(this.value, 'onBlur');
3761
3814
  this.$emit('blur', event);
3762
3815
  this.validateWithTrigger('onBlur');
3816
+ this.$nextTick(this.adjustSize);
3763
3817
  resetScroll();
3764
3818
  },
3765
3819
  onClick: function onClick(event) {
@@ -12727,10 +12781,16 @@ var swipe_createNamespace = Object(create["a" /* createNamespace */])('swipe'),
12727
12781
  },
12728
12782
  onTouchMove: function onTouchMove(event) {
12729
12783
  if (!this.touchable || !this.swiping) return;
12730
- this.touchMove(event);
12784
+ this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
12785
+ // avoid affecting the parent components
12731
12786
 
12732
- if (this.isCorrectDirection) {
12787
+ var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
12788
+
12789
+ if (shouldPrevent) {
12733
12790
  preventDefault(event, this.stopPropagation);
12791
+ }
12792
+
12793
+ if (this.isCorrectDirection) {
12734
12794
  this.move({
12735
12795
  offset: this.delta
12736
12796
  });
@@ -14256,7 +14316,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14256
14316
  mixins: [BindEventMixin(function (bind) {
14257
14317
  // fix cache issues with forwards and back history in safari
14258
14318
  // see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
14259
- bind(window, 'pageshow', this.start);
14319
+ bind(window, 'pageshow', this.reset);
14260
14320
  })],
14261
14321
  inject: {
14262
14322
  vanPopup: {
@@ -14293,24 +14353,20 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14293
14353
  };
14294
14354
  },
14295
14355
  watch: {
14296
- scrollable: 'start',
14356
+ scrollable: 'reset',
14297
14357
  text: {
14298
- handler: 'start',
14358
+ handler: 'reset',
14299
14359
  immediate: true
14300
14360
  }
14301
14361
  },
14302
14362
  created: function created() {
14303
- var _this = this; // https://github.com/youzan/vant/issues/8634
14304
-
14305
-
14363
+ // https://github.com/youzan/vant/issues/8634
14306
14364
  if (this.vanPopup) {
14307
- this.vanPopup.onReopen(function () {
14308
- _this.start();
14309
- });
14365
+ this.vanPopup.onReopen(this.reset);
14310
14366
  }
14311
14367
  },
14312
14368
  activated: function activated() {
14313
- this.start();
14369
+ this.reset();
14314
14370
  },
14315
14371
  methods: {
14316
14372
  onClickIcon: function onClickIcon(event) {
@@ -14320,7 +14376,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14320
14376
  }
14321
14377
  },
14322
14378
  onTransitionEnd: function onTransitionEnd() {
14323
- var _this2 = this;
14379
+ var _this = this;
14324
14380
 
14325
14381
  this.offset = this.wrapWidth;
14326
14382
  this.duration = 0; // wait for Vue to render offset
@@ -14329,50 +14385,52 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14329
14385
  Object(raf["c" /* raf */])(function () {
14330
14386
  // use double raf to ensure animation can start
14331
14387
  Object(raf["b" /* doubleRaf */])(function () {
14332
- _this2.offset = -_this2.contentWidth;
14333
- _this2.duration = (_this2.contentWidth + _this2.wrapWidth) / _this2.speed;
14388
+ _this.offset = -_this.contentWidth;
14389
+ _this.duration = (_this.contentWidth + _this.wrapWidth) / _this.speed;
14334
14390
 
14335
- _this2.$emit('replay');
14391
+ _this.$emit('replay');
14336
14392
  });
14337
14393
  });
14338
14394
  },
14395
+ // not an exposed-api, but may used by some users
14396
+ start: function start() {
14397
+ this.reset();
14398
+ },
14399
+ // @exposed-api
14339
14400
  reset: function reset() {
14401
+ var _this2 = this;
14402
+
14403
+ var delay = Object(utils["c" /* isDef */])(this.delay) ? this.delay * 1000 : 0;
14340
14404
  this.offset = 0;
14341
14405
  this.duration = 0;
14342
14406
  this.wrapWidth = 0;
14343
14407
  this.contentWidth = 0;
14344
- },
14345
- start: function start() {
14346
- var _this3 = this;
14347
-
14348
- var delay = Object(utils["c" /* isDef */])(this.delay) ? this.delay * 1000 : 0;
14349
- this.reset();
14350
14408
  clearTimeout(this.startTimer);
14351
14409
  this.startTimer = setTimeout(function () {
14352
- var _this3$$refs = _this3.$refs,
14353
- wrap = _this3$$refs.wrap,
14354
- content = _this3$$refs.content;
14410
+ var _this2$$refs = _this2.$refs,
14411
+ wrap = _this2$$refs.wrap,
14412
+ content = _this2$$refs.content;
14355
14413
 
14356
- if (!wrap || !content || _this3.scrollable === false) {
14414
+ if (!wrap || !content || _this2.scrollable === false) {
14357
14415
  return;
14358
14416
  }
14359
14417
 
14360
14418
  var wrapWidth = wrap.getBoundingClientRect().width;
14361
14419
  var contentWidth = content.getBoundingClientRect().width;
14362
14420
 
14363
- if (_this3.scrollable || contentWidth > wrapWidth) {
14421
+ if (_this2.scrollable || contentWidth > wrapWidth) {
14364
14422
  Object(raf["b" /* doubleRaf */])(function () {
14365
- _this3.offset = -contentWidth;
14366
- _this3.duration = contentWidth / _this3.speed;
14367
- _this3.wrapWidth = wrapWidth;
14368
- _this3.contentWidth = contentWidth;
14423
+ _this2.offset = -contentWidth;
14424
+ _this2.duration = contentWidth / _this2.speed;
14425
+ _this2.wrapWidth = wrapWidth;
14426
+ _this2.contentWidth = contentWidth;
14369
14427
  });
14370
14428
  }
14371
14429
  }, delay);
14372
14430
  }
14373
14431
  },
14374
14432
  render: function render() {
14375
- var _this4 = this;
14433
+ var _this3 = this;
14376
14434
 
14377
14435
  var h = arguments[0];
14378
14436
  var slots = this.slots,
@@ -14447,7 +14505,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14447
14505
  "style": barStyle,
14448
14506
  "on": {
14449
14507
  "click": function click(event) {
14450
- _this4.$emit('click', event);
14508
+ _this3.$emit('click', event);
14451
14509
  }
14452
14510
  }
14453
14511
  }, [LeftIcon(), h("div", {
@@ -15613,10 +15671,10 @@ var right = 'right';
15613
15671
  var esm_left = 'left';
15614
15672
  var auto = 'auto';
15615
15673
  var basePlacements = [esm_top, esm_bottom, right, esm_left];
15616
- var esm_start = 'start';
15674
+ var start = 'start';
15617
15675
  var end = 'end';
15618
15676
  var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
15619
- return acc.concat([placement, placement + "-" + esm_start, placement + "-" + end]);
15677
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
15620
15678
  }, []); // modifiers that need to read the DOM
15621
15679
 
15622
15680
  var beforeRead = 'beforeRead';
@@ -15869,7 +15927,7 @@ function computeOffsets(_ref) {
15869
15927
  var len = mainAxis === 'y' ? 'height' : 'width';
15870
15928
 
15871
15929
  switch (variation) {
15872
- case esm_start:
15930
+ case start:
15873
15931
  offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
15874
15932
  break;
15875
15933
 
@@ -16651,11 +16709,16 @@ var popover_createNamespace = Object(create["a" /* createNamespace */])('popover
16651
16709
  // CONCATENATED MODULE: ./es/progress/index.js
16652
16710
 
16653
16711
 
16712
+
16654
16713
  var progress_createNamespace = Object(create["a" /* createNamespace */])('progress'),
16655
16714
  progress_createComponent = progress_createNamespace[0],
16656
16715
  progress_bem = progress_createNamespace[1];
16657
16716
 
16658
16717
  /* harmony default export */ var es_progress = (progress_createComponent({
16718
+ mixins: [BindEventMixin(function (bind) {
16719
+ bind(window, 'resize', this.resize, true);
16720
+ bind(window, 'orientationchange', this.resize, true);
16721
+ })],
16659
16722
  props: {
16660
16723
  color: String,
16661
16724
  inactive: Boolean,
@@ -21663,23 +21726,23 @@ var tabbar_createNamespace = Object(create["a" /* createNamespace */])('tabbar')
21663
21726
  var _this = this;
21664
21727
 
21665
21728
  this.children.forEach(function (item, index) {
21666
- item.active = (item.name || index) === _this.value;
21729
+ item.nameMatched = (item.name || index) === _this.value;
21667
21730
  });
21668
21731
  },
21669
- onChange: function onChange(active) {
21732
+ triggerChange: function triggerChange(active, afterChange) {
21670
21733
  var _this2 = this;
21671
21734
 
21672
- if (active !== this.value) {
21673
- callInterceptor({
21674
- interceptor: this.beforeChange,
21675
- args: [active],
21676
- done: function done() {
21677
- _this2.$emit('input', active);
21735
+ callInterceptor({
21736
+ interceptor: this.beforeChange,
21737
+ args: [active],
21738
+ done: function done() {
21739
+ _this2.$emit('input', active);
21678
21740
 
21679
- _this2.$emit('change', active);
21680
- }
21681
- });
21682
- }
21741
+ _this2.$emit('change', active);
21742
+
21743
+ afterChange();
21744
+ }
21745
+ });
21683
21746
  },
21684
21747
  genTabbar: function genTabbar() {
21685
21748
  var _ref;
@@ -21740,11 +21803,11 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21740
21803
  }),
21741
21804
  data: function data() {
21742
21805
  return {
21743
- active: false
21806
+ nameMatched: false
21744
21807
  };
21745
21808
  },
21746
21809
  computed: {
21747
- routeActive: function routeActive() {
21810
+ routeMatched: function routeMatched() {
21748
21811
  var to = this.to,
21749
21812
  $route = this.$route;
21750
21813
 
@@ -21752,22 +21815,33 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21752
21815
  var config = Object(utils["f" /* isObject */])(to) ? to : {
21753
21816
  path: to
21754
21817
  };
21755
- var pathMatched = config.path === $route.path;
21756
- var nameMatched = Object(utils["c" /* isDef */])(config.name) && config.name === $route.name;
21757
- return pathMatched || nameMatched;
21818
+ return !!$route.matched.find(function (r) {
21819
+ var pathMatched = config.path === r.path;
21820
+ var nameMatched = Object(utils["c" /* isDef */])(config.name) && config.name === r.name;
21821
+ return pathMatched || nameMatched;
21822
+ });
21758
21823
  }
21824
+ },
21825
+ active: function active() {
21826
+ return this.parent.route ? this.routeMatched : this.nameMatched;
21759
21827
  }
21760
21828
  },
21761
21829
  methods: {
21762
21830
  onClick: function onClick(event) {
21763
- this.parent.onChange(this.name || this.index);
21831
+ var _this = this;
21832
+
21833
+ if (!this.active) {
21834
+ this.parent.triggerChange(this.name || this.index, function () {
21835
+ route(_this.$router, _this);
21836
+ });
21837
+ }
21838
+
21764
21839
  this.$emit('click', event);
21765
- route(this.$router, this);
21766
21840
  },
21767
- genIcon: function genIcon(active) {
21841
+ genIcon: function genIcon() {
21768
21842
  var h = this.$createElement;
21769
21843
  var slot = this.slots('icon', {
21770
- active: active
21844
+ active: this.active
21771
21845
  });
21772
21846
 
21773
21847
  if (slot) {
@@ -21788,7 +21862,7 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21788
21862
  var _this$badge;
21789
21863
 
21790
21864
  var h = arguments[0];
21791
- var active = this.parent.route ? this.routeActive : this.active;
21865
+ var active = this.active;
21792
21866
  var color = this.parent[active ? 'activeColor' : 'inactiveColor'];
21793
21867
 
21794
21868
  if (false) {}
@@ -21805,7 +21879,7 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21805
21879
  }
21806
21880
  }, [h("div", {
21807
21881
  "class": tabbar_item_bem('icon')
21808
- }, [this.genIcon(active), h(es_info, {
21882
+ }, [this.genIcon(), h(es_info, {
21809
21883
  "attrs": {
21810
21884
  "dot": this.dot,
21811
21885
  "info": (_this$badge = this.badge) != null ? _this$badge : this.info
@@ -22048,7 +22122,7 @@ TreeSelect.props = {
22048
22122
 
22049
22123
 
22050
22124
 
22051
- var version = '2.12.30';
22125
+ var version = '2.12.34-beta.0';
22052
22126
 
22053
22127
  function install(Vue) {
22054
22128
  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];