vant 2.12.30-beta.0 → 2.12.32

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 = ('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) {
@@ -14256,7 +14310,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14256
14310
  mixins: [BindEventMixin(function (bind) {
14257
14311
  // fix cache issues with forwards and back history in safari
14258
14312
  // see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
14259
- bind(window, 'pageshow', this.start);
14313
+ bind(window, 'pageshow', this.reset);
14260
14314
  })],
14261
14315
  inject: {
14262
14316
  vanPopup: {
@@ -14293,24 +14347,20 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14293
14347
  };
14294
14348
  },
14295
14349
  watch: {
14296
- scrollable: 'start',
14350
+ scrollable: 'reset',
14297
14351
  text: {
14298
- handler: 'start',
14352
+ handler: 'reset',
14299
14353
  immediate: true
14300
14354
  }
14301
14355
  },
14302
14356
  created: function created() {
14303
- var _this = this; // https://github.com/youzan/vant/issues/8634
14304
-
14305
-
14357
+ // https://github.com/youzan/vant/issues/8634
14306
14358
  if (this.vanPopup) {
14307
- this.vanPopup.onReopen(function () {
14308
- _this.start();
14309
- });
14359
+ this.vanPopup.onReopen(this.reset);
14310
14360
  }
14311
14361
  },
14312
14362
  activated: function activated() {
14313
- this.start();
14363
+ this.reset();
14314
14364
  },
14315
14365
  methods: {
14316
14366
  onClickIcon: function onClickIcon(event) {
@@ -14320,7 +14370,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14320
14370
  }
14321
14371
  },
14322
14372
  onTransitionEnd: function onTransitionEnd() {
14323
- var _this2 = this;
14373
+ var _this = this;
14324
14374
 
14325
14375
  this.offset = this.wrapWidth;
14326
14376
  this.duration = 0; // wait for Vue to render offset
@@ -14329,50 +14379,52 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14329
14379
  Object(raf["c" /* raf */])(function () {
14330
14380
  // use double raf to ensure animation can start
14331
14381
  Object(raf["b" /* doubleRaf */])(function () {
14332
- _this2.offset = -_this2.contentWidth;
14333
- _this2.duration = (_this2.contentWidth + _this2.wrapWidth) / _this2.speed;
14382
+ _this.offset = -_this.contentWidth;
14383
+ _this.duration = (_this.contentWidth + _this.wrapWidth) / _this.speed;
14334
14384
 
14335
- _this2.$emit('replay');
14385
+ _this.$emit('replay');
14336
14386
  });
14337
14387
  });
14338
14388
  },
14389
+ // not an exposed-api, but may used by some users
14390
+ start: function start() {
14391
+ this.reset();
14392
+ },
14393
+ // @exposed-api
14339
14394
  reset: function reset() {
14395
+ var _this2 = this;
14396
+
14397
+ var delay = Object(utils["c" /* isDef */])(this.delay) ? this.delay * 1000 : 0;
14340
14398
  this.offset = 0;
14341
14399
  this.duration = 0;
14342
14400
  this.wrapWidth = 0;
14343
14401
  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
14402
  clearTimeout(this.startTimer);
14351
14403
  this.startTimer = setTimeout(function () {
14352
- var _this3$$refs = _this3.$refs,
14353
- wrap = _this3$$refs.wrap,
14354
- content = _this3$$refs.content;
14404
+ var _this2$$refs = _this2.$refs,
14405
+ wrap = _this2$$refs.wrap,
14406
+ content = _this2$$refs.content;
14355
14407
 
14356
- if (!wrap || !content || _this3.scrollable === false) {
14408
+ if (!wrap || !content || _this2.scrollable === false) {
14357
14409
  return;
14358
14410
  }
14359
14411
 
14360
14412
  var wrapWidth = wrap.getBoundingClientRect().width;
14361
14413
  var contentWidth = content.getBoundingClientRect().width;
14362
14414
 
14363
- if (_this3.scrollable || contentWidth > wrapWidth) {
14415
+ if (_this2.scrollable || contentWidth > wrapWidth) {
14364
14416
  Object(raf["b" /* doubleRaf */])(function () {
14365
- _this3.offset = -contentWidth;
14366
- _this3.duration = contentWidth / _this3.speed;
14367
- _this3.wrapWidth = wrapWidth;
14368
- _this3.contentWidth = contentWidth;
14417
+ _this2.offset = -contentWidth;
14418
+ _this2.duration = contentWidth / _this2.speed;
14419
+ _this2.wrapWidth = wrapWidth;
14420
+ _this2.contentWidth = contentWidth;
14369
14421
  });
14370
14422
  }
14371
14423
  }, delay);
14372
14424
  }
14373
14425
  },
14374
14426
  render: function render() {
14375
- var _this4 = this;
14427
+ var _this3 = this;
14376
14428
 
14377
14429
  var h = arguments[0];
14378
14430
  var slots = this.slots,
@@ -14447,7 +14499,7 @@ var notice_bar_createNamespace = Object(create["a" /* createNamespace */])('noti
14447
14499
  "style": barStyle,
14448
14500
  "on": {
14449
14501
  "click": function click(event) {
14450
- _this4.$emit('click', event);
14502
+ _this3.$emit('click', event);
14451
14503
  }
14452
14504
  }
14453
14505
  }, [LeftIcon(), h("div", {
@@ -15613,10 +15665,10 @@ var right = 'right';
15613
15665
  var esm_left = 'left';
15614
15666
  var auto = 'auto';
15615
15667
  var basePlacements = [esm_top, esm_bottom, right, esm_left];
15616
- var esm_start = 'start';
15668
+ var start = 'start';
15617
15669
  var end = 'end';
15618
15670
  var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
15619
- return acc.concat([placement, placement + "-" + esm_start, placement + "-" + end]);
15671
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
15620
15672
  }, []); // modifiers that need to read the DOM
15621
15673
 
15622
15674
  var beforeRead = 'beforeRead';
@@ -15869,7 +15921,7 @@ function computeOffsets(_ref) {
15869
15921
  var len = mainAxis === 'y' ? 'height' : 'width';
15870
15922
 
15871
15923
  switch (variation) {
15872
- case esm_start:
15924
+ case start:
15873
15925
  offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
15874
15926
  break;
15875
15927
 
@@ -16651,11 +16703,16 @@ var popover_createNamespace = Object(create["a" /* createNamespace */])('popover
16651
16703
  // CONCATENATED MODULE: ./es/progress/index.js
16652
16704
 
16653
16705
 
16706
+
16654
16707
  var progress_createNamespace = Object(create["a" /* createNamespace */])('progress'),
16655
16708
  progress_createComponent = progress_createNamespace[0],
16656
16709
  progress_bem = progress_createNamespace[1];
16657
16710
 
16658
16711
  /* harmony default export */ var es_progress = (progress_createComponent({
16712
+ mixins: [BindEventMixin(function (bind) {
16713
+ bind(window, 'resize', this.resize, true);
16714
+ bind(window, 'orientationchange', this.resize, true);
16715
+ })],
16659
16716
  props: {
16660
16717
  color: String,
16661
16718
  inactive: Boolean,
@@ -21663,23 +21720,23 @@ var tabbar_createNamespace = Object(create["a" /* createNamespace */])('tabbar')
21663
21720
  var _this = this;
21664
21721
 
21665
21722
  this.children.forEach(function (item, index) {
21666
- item.active = (item.name || index) === _this.value;
21723
+ item.nameMatched = (item.name || index) === _this.value;
21667
21724
  });
21668
21725
  },
21669
- onChange: function onChange(active) {
21726
+ triggerChange: function triggerChange(active, afterChange) {
21670
21727
  var _this2 = this;
21671
21728
 
21672
- if (active !== this.value) {
21673
- callInterceptor({
21674
- interceptor: this.beforeChange,
21675
- args: [active],
21676
- done: function done() {
21677
- _this2.$emit('input', active);
21729
+ callInterceptor({
21730
+ interceptor: this.beforeChange,
21731
+ args: [active],
21732
+ done: function done() {
21733
+ _this2.$emit('input', active);
21678
21734
 
21679
- _this2.$emit('change', active);
21680
- }
21681
- });
21682
- }
21735
+ _this2.$emit('change', active);
21736
+
21737
+ afterChange();
21738
+ }
21739
+ });
21683
21740
  },
21684
21741
  genTabbar: function genTabbar() {
21685
21742
  var _ref;
@@ -21740,11 +21797,11 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21740
21797
  }),
21741
21798
  data: function data() {
21742
21799
  return {
21743
- active: false
21800
+ nameMatched: false
21744
21801
  };
21745
21802
  },
21746
21803
  computed: {
21747
- routeActive: function routeActive() {
21804
+ routeMatched: function routeMatched() {
21748
21805
  var to = this.to,
21749
21806
  $route = this.$route;
21750
21807
 
@@ -21756,18 +21813,27 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21756
21813
  var nameMatched = Object(utils["c" /* isDef */])(config.name) && config.name === $route.name;
21757
21814
  return pathMatched || nameMatched;
21758
21815
  }
21816
+ },
21817
+ active: function active() {
21818
+ return this.parent.route ? this.routeMatched : this.nameMatched;
21759
21819
  }
21760
21820
  },
21761
21821
  methods: {
21762
21822
  onClick: function onClick(event) {
21763
- this.parent.onChange(this.name || this.index);
21823
+ var _this = this;
21824
+
21825
+ if (!this.active) {
21826
+ this.parent.triggerChange(this.name || this.index, function () {
21827
+ route(_this.$router, _this);
21828
+ });
21829
+ }
21830
+
21764
21831
  this.$emit('click', event);
21765
- route(this.$router, this);
21766
21832
  },
21767
- genIcon: function genIcon(active) {
21833
+ genIcon: function genIcon() {
21768
21834
  var h = this.$createElement;
21769
21835
  var slot = this.slots('icon', {
21770
- active: active
21836
+ active: this.active
21771
21837
  });
21772
21838
 
21773
21839
  if (slot) {
@@ -21788,7 +21854,7 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21788
21854
  var _this$badge;
21789
21855
 
21790
21856
  var h = arguments[0];
21791
- var active = this.parent.route ? this.routeActive : this.active;
21857
+ var active = this.active;
21792
21858
  var color = this.parent[active ? 'activeColor' : 'inactiveColor'];
21793
21859
 
21794
21860
  if (false) {}
@@ -21805,7 +21871,7 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21805
21871
  }
21806
21872
  }, [h("div", {
21807
21873
  "class": tabbar_item_bem('icon')
21808
- }, [this.genIcon(active), h(es_info, {
21874
+ }, [this.genIcon(), h(es_info, {
21809
21875
  "attrs": {
21810
21876
  "dot": this.dot,
21811
21877
  "info": (_this$badge = this.badge) != null ? _this$badge : this.info
@@ -22048,7 +22114,7 @@ TreeSelect.props = {
22048
22114
 
22049
22115
 
22050
22116
 
22051
- var version = '2.12.30-beta.0';
22117
+ var version = '2.12.32';
22052
22118
 
22053
22119
  function install(Vue) {
22054
22120
  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];