vant 2.12.31 → 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/README.md CHANGED
@@ -87,11 +87,12 @@ Vant 3 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3).
87
87
 
88
88
  | Project | Description |
89
89
  | --- | --- |
90
- | [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components base on Vant |
90
+ | [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant |
91
91
  | [mxdi9i7/vant-react](https://github.com/mxdi9i7/vant-react) | Mobile UI Components built on React and TS, inspired by Vant |
92
92
  | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
93
93
  | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
94
- | [vant-theme](https://github.com/Aisen60/vant-theme) | online theme preview built on Vant UI |
94
+ | [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
95
+ | [@antmjs/vantui](https://github.com/antmjs/vantui) | Mobile UI Components based on Vant, supporting Taro and React |
95
96
 
96
97
  ## Links
97
98
 
package/README.zh-CN.md CHANGED
@@ -96,11 +96,12 @@ Vant 3 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一致
96
96
 
97
97
  | 项目 | 描述 |
98
98
  | --- | --- |
99
- | [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 框架移动端组件库 |
99
+ | [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 移动端组件库 |
100
100
  | [mxdi9i7/vant-react](https://github.com/mxdi9i7/vant-react) | 基于 React 和 TS 构建的移动端组件库 |
101
101
  | [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 |
102
102
  | [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 |
103
103
  | [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
104
+ | [@antmjs/vantui](https://github.com/antmjs/vantui) | 基于 Vant Weapp 开发的多端组件库,同时支持 Taro 和 React |
104
105
 
105
106
  ## 链接
106
107
 
package/es/field/index.js CHANGED
@@ -339,13 +339,15 @@ export default createComponent({
339
339
 
340
340
  /* istanbul ignore if */
341
341
 
342
- var readonly = this.getProp('readonly');
343
-
344
- if (readonly) {
342
+ if (this.getProp('readonly')) {
345
343
  this.blur();
346
344
  }
347
345
  },
348
346
  onBlur: function onBlur(event) {
347
+ if (this.getProp('readonly')) {
348
+ return;
349
+ }
350
+
349
351
  this.focused = false;
350
352
  this.updateValue(this.value, 'onBlur');
351
353
  this.$emit('blur', event);
package/es/index.js CHANGED
@@ -87,7 +87,7 @@ import Tag from './tag';
87
87
  import Toast from './toast';
88
88
  import TreeSelect from './tree-select';
89
89
  import Uploader from './uploader';
90
- var version = '2.12.31';
90
+ var version = '2.12.32';
91
91
 
92
92
  function install(Vue) {
93
93
  var components = [ActionSheet, AddressEdit, AddressList, Area, Badge, Button, Calendar, Card, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Circle, Col, Collapse, CollapseItem, ContactCard, ContactEdit, ContactList, CountDown, Coupon, CouponCell, CouponList, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, GoodsAction, GoodsActionButton, GoodsActionIcon, Grid, GridItem, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, List, Loading, Locale, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Panel, PasswordInput, Picker, Popover, Popup, Progress, PullRefresh, Radio, RadioGroup, Rate, Row, Search, ShareSheet, Sidebar, SidebarItem, Skeleton, Sku, Slider, Step, Stepper, Steps, Sticky, SubmitBar, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, TreeSelect, Uploader];
@@ -11,7 +11,7 @@ export default createComponent({
11
11
  mixins: [BindEventMixin(function (bind) {
12
12
  // fix cache issues with forwards and back history in safari
13
13
  // see: https://guwii.com/cache-issues-with-forwards-and-back-history-in-safari/
14
- bind(window, 'pageshow', this.start);
14
+ bind(window, 'pageshow', this.reset);
15
15
  })],
16
16
  inject: {
17
17
  vanPopup: {
@@ -48,24 +48,20 @@ export default createComponent({
48
48
  };
49
49
  },
50
50
  watch: {
51
- scrollable: 'start',
51
+ scrollable: 'reset',
52
52
  text: {
53
- handler: 'start',
53
+ handler: 'reset',
54
54
  immediate: true
55
55
  }
56
56
  },
57
57
  created: function created() {
58
- var _this = this;
59
-
60
58
  // https://github.com/youzan/vant/issues/8634
61
59
  if (this.vanPopup) {
62
- this.vanPopup.onReopen(function () {
63
- _this.start();
64
- });
60
+ this.vanPopup.onReopen(this.reset);
65
61
  }
66
62
  },
67
63
  activated: function activated() {
68
- this.start();
64
+ this.reset();
69
65
  },
70
66
  methods: {
71
67
  onClickIcon: function onClickIcon(event) {
@@ -75,7 +71,7 @@ export default createComponent({
75
71
  }
76
72
  },
77
73
  onTransitionEnd: function onTransitionEnd() {
78
- var _this2 = this;
74
+ var _this = this;
79
75
 
80
76
  this.offset = this.wrapWidth;
81
77
  this.duration = 0; // wait for Vue to render offset
@@ -84,50 +80,52 @@ export default createComponent({
84
80
  raf(function () {
85
81
  // use double raf to ensure animation can start
86
82
  doubleRaf(function () {
87
- _this2.offset = -_this2.contentWidth;
88
- _this2.duration = (_this2.contentWidth + _this2.wrapWidth) / _this2.speed;
83
+ _this.offset = -_this.contentWidth;
84
+ _this.duration = (_this.contentWidth + _this.wrapWidth) / _this.speed;
89
85
 
90
- _this2.$emit('replay');
86
+ _this.$emit('replay');
91
87
  });
92
88
  });
93
89
  },
90
+ // not an exposed-api, but may used by some users
91
+ start: function start() {
92
+ this.reset();
93
+ },
94
+ // @exposed-api
94
95
  reset: function reset() {
96
+ var _this2 = this;
97
+
98
+ var delay = isDef(this.delay) ? this.delay * 1000 : 0;
95
99
  this.offset = 0;
96
100
  this.duration = 0;
97
101
  this.wrapWidth = 0;
98
102
  this.contentWidth = 0;
99
- },
100
- start: function start() {
101
- var _this3 = this;
102
-
103
- var delay = isDef(this.delay) ? this.delay * 1000 : 0;
104
- this.reset();
105
103
  clearTimeout(this.startTimer);
106
104
  this.startTimer = setTimeout(function () {
107
- var _this3$$refs = _this3.$refs,
108
- wrap = _this3$$refs.wrap,
109
- content = _this3$$refs.content;
105
+ var _this2$$refs = _this2.$refs,
106
+ wrap = _this2$$refs.wrap,
107
+ content = _this2$$refs.content;
110
108
 
111
- if (!wrap || !content || _this3.scrollable === false) {
109
+ if (!wrap || !content || _this2.scrollable === false) {
112
110
  return;
113
111
  }
114
112
 
115
113
  var wrapWidth = wrap.getBoundingClientRect().width;
116
114
  var contentWidth = content.getBoundingClientRect().width;
117
115
 
118
- if (_this3.scrollable || contentWidth > wrapWidth) {
116
+ if (_this2.scrollable || contentWidth > wrapWidth) {
119
117
  doubleRaf(function () {
120
- _this3.offset = -contentWidth;
121
- _this3.duration = contentWidth / _this3.speed;
122
- _this3.wrapWidth = wrapWidth;
123
- _this3.contentWidth = contentWidth;
118
+ _this2.offset = -contentWidth;
119
+ _this2.duration = contentWidth / _this2.speed;
120
+ _this2.wrapWidth = wrapWidth;
121
+ _this2.contentWidth = contentWidth;
124
122
  });
125
123
  }
126
124
  }, delay);
127
125
  }
128
126
  },
129
127
  render: function render() {
130
- var _this4 = this;
128
+ var _this3 = this;
131
129
 
132
130
  var h = arguments[0];
133
131
  var slots = this.slots,
@@ -202,7 +200,7 @@ export default createComponent({
202
200
  "style": barStyle,
203
201
  "on": {
204
202
  "click": function click(event) {
205
- _this4.$emit('click', event);
203
+ _this3.$emit('click', event);
206
204
  }
207
205
  }
208
206
  }, [LeftIcon(), h("div", {
@@ -3,14 +3,14 @@ import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
3
3
  import { deepClone } from '../utils/deep-clone';
4
4
  import { createNamespace, isObject } from '../utils';
5
5
  import { range } from '../utils/format/number';
6
- import { preventDefault } from '../utils/dom/event';
6
+ import { preventDefault, on, off } from '../utils/dom/event';
7
7
  import { TouchMixin } from '../mixins/touch';
8
8
  var DEFAULT_DURATION = 200; // 惯性滑动思路:
9
9
  // 在手指离开屏幕时,如果和上一次 move 时的间隔小于 `MOMENTUM_LIMIT_TIME` 且 move
10
10
  // 距离大于 `MOMENTUM_LIMIT_DISTANCE` 时,执行惯性滑动
11
11
 
12
- var MOMENTUM_LIMIT_TIME = 300;
13
- var MOMENTUM_LIMIT_DISTANCE = 15;
12
+ export var MOMENTUM_LIMIT_TIME = 300;
13
+ export var MOMENTUM_LIMIT_DISTANCE = 15;
14
14
 
15
15
  var _createNamespace = createNamespace('picker-column'),
16
16
  createComponent = _createNamespace[0],
@@ -25,8 +25,12 @@ function getElementTranslateY(element) {
25
25
 
26
26
  function isOptionDisabled(option) {
27
27
  return isObject(option) && option.disabled;
28
- }
28
+ } // use standard WheelEvent:
29
+ // https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
30
+
29
31
 
32
+ var supportMousewheel = ('onwheel' in window);
33
+ var mousewheelTimer = null;
30
34
  export default createComponent({
31
35
  mixins: [TouchMixin],
32
36
  props: {
@@ -62,6 +66,10 @@ export default createComponent({
62
66
  },
63
67
  mounted: function mounted() {
64
68
  this.bindTouchEvent(this.$el);
69
+
70
+ if (supportMousewheel) {
71
+ on(this.$el, 'wheel', this.onMouseWheel, false);
72
+ }
65
73
  },
66
74
  destroyed: function destroyed() {
67
75
  var children = this.$parent.children;
@@ -69,6 +77,10 @@ export default createComponent({
69
77
  if (children) {
70
78
  children.splice(children.indexOf(this), 1);
71
79
  }
80
+
81
+ if (supportMousewheel) {
82
+ off(this.$el, 'wheel');
83
+ }
72
84
  },
73
85
  watch: {
74
86
  initialOptions: 'setOptions',
@@ -156,6 +168,43 @@ export default createComponent({
156
168
  _this.moving = false;
157
169
  }, 0);
158
170
  },
171
+ onMouseWheel: function onMouseWheel(event) {
172
+ var _this2 = this;
173
+
174
+ if (this.readonly) {
175
+ return;
176
+ }
177
+
178
+ preventDefault(event, true); // simply combine touchstart and touchmove
179
+
180
+ var translateY = getElementTranslateY(this.$refs.wrapper);
181
+ this.startOffset = Math.min(0, translateY - this.baseOffset);
182
+ this.momentumOffset = this.startOffset;
183
+ this.transitionEndTrigger = null; // directly use deltaY, see https://caniuse.com/?search=deltaY
184
+ // use deltaY to detect direction for not special setting device
185
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event
186
+
187
+ var deltaY = event.deltaY;
188
+
189
+ if (this.startOffset === 0 && deltaY < 0) {
190
+ return;
191
+ } // get offset
192
+ // if necessary, can adjust distance value to make scrolling smoother
193
+
194
+
195
+ var distance = -deltaY;
196
+ this.offset = range(this.startOffset + distance, -(this.count * this.itemHeight), this.itemHeight);
197
+
198
+ if (mousewheelTimer) {
199
+ clearTimeout(mousewheelTimer);
200
+ }
201
+
202
+ mousewheelTimer = setTimeout(function () {
203
+ _this2.onTouchEnd();
204
+
205
+ _this2.touchStartTime = 0;
206
+ }, MOMENTUM_LIMIT_TIME);
207
+ },
159
208
  onTransitionEnd: function onTransitionEnd() {
160
209
  this.stopMomentum();
161
210
  },
@@ -187,17 +236,17 @@ export default createComponent({
187
236
  return option;
188
237
  },
189
238
  setIndex: function setIndex(index, emitChange) {
190
- var _this2 = this;
239
+ var _this3 = this;
191
240
 
192
241
  index = this.adjustIndex(index) || 0;
193
242
  var offset = -index * this.itemHeight;
194
243
 
195
244
  var trigger = function trigger() {
196
- if (index !== _this2.currentIndex) {
197
- _this2.currentIndex = index;
245
+ if (index !== _this3.currentIndex) {
246
+ _this3.currentIndex = index;
198
247
 
199
248
  if (emitChange) {
200
- _this2.$emit('change', index);
249
+ _this3.$emit('change', index);
201
250
  }
202
251
  }
203
252
  }; // trigger the change event after transitionend when moving
@@ -243,7 +292,7 @@ export default createComponent({
243
292
  }
244
293
  },
245
294
  genOptions: function genOptions() {
246
- var _this3 = this;
295
+ var _this4 = this;
247
296
 
248
297
  var h = this.$createElement;
249
298
  var optionStyle = {
@@ -252,7 +301,7 @@ export default createComponent({
252
301
  return this.options.map(function (option, index) {
253
302
  var _domProps;
254
303
 
255
- var text = _this3.getOptionText(option);
304
+ var text = _this4.getOptionText(option);
256
305
 
257
306
  var disabled = isOptionDisabled(option);
258
307
  var data = {
@@ -263,19 +312,19 @@ export default createComponent({
263
312
  },
264
313
  class: [bem('item', {
265
314
  disabled: disabled,
266
- selected: index === _this3.currentIndex
315
+ selected: index === _this4.currentIndex
267
316
  })],
268
317
  on: {
269
318
  click: function click() {
270
- _this3.onClickItem(index);
319
+ _this4.onClickItem(index);
271
320
  }
272
321
  }
273
322
  };
274
323
  var childData = {
275
324
  class: 'van-ellipsis',
276
- domProps: (_domProps = {}, _domProps[_this3.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
325
+ domProps: (_domProps = {}, _domProps[_this4.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
277
326
  };
278
- return h("li", _mergeJSXProps([{}, data]), [_this3.slots('option', option) || h("div", _mergeJSXProps2([{}, childData]))]);
327
+ return h("li", _mergeJSXProps([{}, data]), [_this4.slots('option', option) || h("div", _mergeJSXProps2([{}, childData]))]);
279
328
  });
280
329
  }
281
330
  },
@@ -1 +1 @@
1
- .van-switch{position:relative;display:inline-block;box-sizing:content-box;width:2em;height:1em;font-size:30px;background-color:#fff;border:1px solid rgba(0,0,0,.1);border-radius:1em;cursor:pointer;-webkit-transition:background-color .3s;transition:background-color .3s}.van-switch__node{position:absolute;top:0;left:0;width:1em;height:1em;background-color:#fff;border-radius:100%;box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);-webkit-transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{top:25%;left:25%;width:50%;height:50%;line-height:1}.van-switch--on{background-color:#1989fa}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em)}.van-switch--on .van-switch__loading{color:#1989fa}.van-switch--disabled{cursor:not-allowed;opacity:.5}.van-switch--loading{cursor:default}
1
+ .van-switch{position:relative;display:inline-block;box-sizing:content-box;width:2em;height:1em;font-size:30px;background-color:#fff;border:1px solid rgba(0,0,0,.1);border-radius:1em;cursor:pointer;-webkit-transition:background-color .3s;transition:background-color .3s}.van-switch__node{position:absolute;top:0;left:0;width:1em;height:1em;font-size:inherit;background-color:#fff;border-radius:100%;box-shadow:0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05);-webkit-transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05);transition:transform .3s cubic-bezier(.3,1.05,.4,1.05),-webkit-transform .3s cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{top:25%;left:25%;width:50%;height:50%;line-height:1}.van-switch--on{background-color:#1989fa}.van-switch--on .van-switch__node{-webkit-transform:translateX(1em);transform:translateX(1em)}.van-switch--on .van-switch__loading{color:#1989fa}.van-switch--disabled{cursor:not-allowed;opacity:.5}.van-switch--loading{cursor:default}
@@ -19,6 +19,8 @@
19
19
  left: 0;
20
20
  width: @switch-node-size;
21
21
  height: @switch-node-size;
22
+ // https://github.com/youzan/vant/issues/9839
23
+ font-size: inherit;
22
24
  background-color: @switch-node-background-color;
23
25
  border-radius: 100%;
24
26
  box-shadow: @switch-node-box-shadow;
@@ -62,23 +62,23 @@ export default createComponent({
62
62
  var _this = this;
63
63
 
64
64
  this.children.forEach(function (item, index) {
65
- item.active = (item.name || index) === _this.value;
65
+ item.nameMatched = (item.name || index) === _this.value;
66
66
  });
67
67
  },
68
- onChange: function onChange(active) {
68
+ triggerChange: function triggerChange(active, afterChange) {
69
69
  var _this2 = this;
70
70
 
71
- if (active !== this.value) {
72
- callInterceptor({
73
- interceptor: this.beforeChange,
74
- args: [active],
75
- done: function done() {
76
- _this2.$emit('input', active);
71
+ callInterceptor({
72
+ interceptor: this.beforeChange,
73
+ args: [active],
74
+ done: function done() {
75
+ _this2.$emit('input', active);
77
76
 
78
- _this2.$emit('change', active);
79
- }
80
- });
81
- }
77
+ _this2.$emit('change', active);
78
+
79
+ afterChange();
80
+ }
81
+ });
82
82
  },
83
83
  genTabbar: function genTabbar() {
84
84
  var _ref;
@@ -25,11 +25,11 @@ export default createComponent({
25
25
  }),
26
26
  data: function data() {
27
27
  return {
28
- active: false
28
+ nameMatched: false
29
29
  };
30
30
  },
31
31
  computed: {
32
- routeActive: function routeActive() {
32
+ routeMatched: function routeMatched() {
33
33
  var to = this.to,
34
34
  $route = this.$route;
35
35
 
@@ -41,18 +41,27 @@ export default createComponent({
41
41
  var nameMatched = isDef(config.name) && config.name === $route.name;
42
42
  return pathMatched || nameMatched;
43
43
  }
44
+ },
45
+ active: function active() {
46
+ return this.parent.route ? this.routeMatched : this.nameMatched;
44
47
  }
45
48
  },
46
49
  methods: {
47
50
  onClick: function onClick(event) {
48
- this.parent.onChange(this.name || this.index);
51
+ var _this = this;
52
+
53
+ if (!this.active) {
54
+ this.parent.triggerChange(this.name || this.index, function () {
55
+ route(_this.$router, _this);
56
+ });
57
+ }
58
+
49
59
  this.$emit('click', event);
50
- route(this.$router, this);
51
60
  },
52
- genIcon: function genIcon(active) {
61
+ genIcon: function genIcon() {
53
62
  var h = this.$createElement;
54
63
  var slot = this.slots('icon', {
55
- active: active
64
+ active: this.active
56
65
  });
57
66
 
58
67
  if (slot) {
@@ -73,7 +82,7 @@ export default createComponent({
73
82
  var _this$badge;
74
83
 
75
84
  var h = arguments[0];
76
- var active = this.parent.route ? this.routeActive : this.active;
85
+ var active = this.active;
77
86
  var color = this.parent[active ? 'activeColor' : 'inactiveColor'];
78
87
 
79
88
  if (process.env.NODE_ENV === 'development' && this.info) {
@@ -92,7 +101,7 @@ export default createComponent({
92
101
  }
93
102
  }, [h("div", {
94
103
  "class": bem('icon')
95
- }, [this.genIcon(active), h(Info, {
104
+ }, [this.genIcon(), h(Info, {
96
105
  "attrs": {
97
106
  "dot": this.dot,
98
107
  "info": (_this$badge = this.badge) != null ? _this$badge : this.info
@@ -354,13 +354,15 @@ var _default = createComponent({
354
354
 
355
355
  /* istanbul ignore if */
356
356
 
357
- var readonly = this.getProp('readonly');
358
-
359
- if (readonly) {
357
+ if (this.getProp('readonly')) {
360
358
  this.blur();
361
359
  }
362
360
  },
363
361
  onBlur: function onBlur(event) {
362
+ if (this.getProp('readonly')) {
363
+ return;
364
+ }
365
+
364
366
  this.focused = false;
365
367
  this.updateValue(this.value, 'onBlur');
366
368
  this.$emit('blur', event);