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.
@@ -90,11 +90,9 @@ export default createComponent({
90
90
  },
91
91
  methods: {
92
92
  getHeight: function getHeight() {
93
- if (!this.height) {
94
- this.height = this.$el.getBoundingClientRect().height;
95
- }
93
+ var _this$$el;
96
94
 
97
- return this.height;
95
+ return ((_this$$el = this.$el) == null ? void 0 : _this$$el.getBoundingClientRect().height) || 0;
98
96
  },
99
97
  scrollIntoView: function scrollIntoView(body) {
100
98
  var _this$$refs = this.$refs,
@@ -98,6 +98,11 @@ export default createComponent({
98
98
  }
99
99
  }
100
100
  },
101
+ inject: {
102
+ vanPopup: {
103
+ default: null
104
+ }
105
+ },
101
106
  data: function data() {
102
107
  return {
103
108
  subtitle: '',
@@ -148,7 +153,11 @@ export default createComponent({
148
153
  }
149
154
  },
150
155
  mounted: function mounted() {
151
- this.init();
156
+ var _this$vanPopup;
157
+
158
+ this.init(); // https://github.com/youzan/vant/issues/9845
159
+
160
+ (_this$vanPopup = this.vanPopup) == null ? void 0 : _this$vanPopup.$on('opened', this.onScroll);
152
161
  },
153
162
 
154
163
  /* istanbul ignore next */
@@ -272,6 +272,9 @@ export default createComponent({
272
272
  this.updateInnerValue();
273
273
  this.$nextTick(function () {
274
274
  _this4.$nextTick(function () {
275
+ // https://github.com/youzan/vant/issues/9775
276
+ _this4.updateInnerValue();
277
+
275
278
  _this4.$emit('change', picker);
276
279
  });
277
280
  });
@@ -12,7 +12,7 @@ export default createComponent({
12
12
  methods: {
13
13
  // @exposed-api
14
14
  getPicker: function getPicker() {
15
- return this.$refs.root.getPicker();
15
+ return this.$refs.root.getProxiedPicker();
16
16
  }
17
17
  },
18
18
  render: function render() {
@@ -77,10 +77,32 @@ export var TimePickerMixin = {
77
77
  });
78
78
  },
79
79
  methods: {
80
- // @exposed-api
81
80
  getPicker: function getPicker() {
82
81
  return this.$refs.picker;
83
82
  },
83
+ // https://github.com/youzan/vant/issues/10013
84
+ getProxiedPicker: function getProxiedPicker() {
85
+ var _this4 = this;
86
+
87
+ var picker = this.$refs.picker;
88
+
89
+ if (picker) {
90
+ var proxy = function proxy(fn) {
91
+ return function () {
92
+ picker[fn].apply(picker, arguments);
93
+
94
+ _this4.updateInnerValue();
95
+ };
96
+ };
97
+
98
+ return _extends({}, picker, {
99
+ setValues: proxy('setValues'),
100
+ setIndexes: proxy('setIndexes'),
101
+ setColumnIndex: proxy('setColumnIndex'),
102
+ setColumnValue: proxy('setColumnValue')
103
+ });
104
+ }
105
+ },
84
106
  onConfirm: function onConfirm() {
85
107
  this.$emit('input', this.innerValue);
86
108
  this.$emit('confirm', this.innerValue);
@@ -90,12 +112,12 @@ export var TimePickerMixin = {
90
112
  }
91
113
  },
92
114
  render: function render() {
93
- var _this4 = this;
115
+ var _this5 = this;
94
116
 
95
117
  var h = arguments[0];
96
118
  var props = {};
97
119
  Object.keys(pickerProps).forEach(function (key) {
98
- props[key] = _this4[key];
120
+ props[key] = _this5[key];
99
121
  });
100
122
  return h(Picker, {
101
123
  "ref": "picker",
@@ -19,6 +19,7 @@ export default createComponent({
19
19
  className: null,
20
20
  closeable: Boolean,
21
21
  asyncClose: Boolean,
22
+ overlayStyle: Object,
22
23
  showIndicators: Boolean,
23
24
  images: {
24
25
  type: Array,
@@ -18,6 +18,7 @@ var defaultConfig = {
18
18
  asyncClose: false,
19
19
  transition: 'van-fade',
20
20
  getContainer: 'body',
21
+ overlayStyle: null,
21
22
  startPosition: 0,
22
23
  swipeDuration: 300,
23
24
  showIndicators: false,
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.34';
90
+ var version = '2.12.38';
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];
@@ -1,12 +1,11 @@
1
1
  import { on } from '../utils/dom/event';
2
- var MIN_DISTANCE = 10;
3
2
 
4
3
  function getDirection(x, y) {
5
- if (x > y && x > MIN_DISTANCE) {
4
+ if (x > y) {
6
5
  return 'horizontal';
7
6
  }
8
7
 
9
- if (y > x && y > MIN_DISTANCE) {
8
+ if (y > x) {
10
9
  return 'vertical';
11
10
  }
12
11
 
@@ -26,13 +25,18 @@ export var TouchMixin = {
26
25
  this.startY = event.touches[0].clientY;
27
26
  },
28
27
  touchMove: function touchMove(event) {
29
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
28
+ var touch = event.touches[0]; // safari back will set clientX to negative number
30
29
 
31
30
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
32
31
  this.deltaY = touch.clientY - this.startY;
33
32
  this.offsetX = Math.abs(this.deltaX);
34
- this.offsetY = Math.abs(this.deltaY);
35
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
33
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
34
+
35
+ var LOCK_DIRECTION_DISTANCE = 10;
36
+
37
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
38
+ this.direction = getDirection(this.offsetX, this.offsetY);
39
+ }
36
40
  },
37
41
  resetTouchStatus: function resetTouchStatus() {
38
42
  this.direction = '';
@@ -233,6 +233,7 @@ export default createComponent({
233
233
  var renderButton = function renderButton(i) {
234
234
  var map = ['left', 'right'];
235
235
  var isNumber = typeof i === 'number';
236
+ var current = isNumber ? _this.value[i] : _this.value;
236
237
 
237
238
  var getClassName = function getClassName() {
238
239
  if (isNumber) {
@@ -250,6 +251,27 @@ export default createComponent({
250
251
  return "wrapper";
251
252
  };
252
253
 
254
+ var renderButtonContent = function renderButtonContent() {
255
+ if (isNumber) {
256
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
257
+ value: current
258
+ });
259
+
260
+ if (slot) {
261
+ return slot;
262
+ }
263
+ }
264
+
265
+ if (_this.slots('button')) {
266
+ return _this.slots('button');
267
+ }
268
+
269
+ return h("div", {
270
+ "class": bem('button'),
271
+ "style": _this.buttonStyle
272
+ });
273
+ };
274
+
253
275
  return h("div", {
254
276
  "ref": getRefName(),
255
277
  "attrs": {
@@ -272,10 +294,7 @@ export default createComponent({
272
294
  return e.stopPropagation();
273
295
  }
274
296
  }
275
- }, [_this.slots('button') || h("div", {
276
- "class": bem('button'),
277
- "style": _this.buttonStyle
278
- })]);
297
+ }, [renderButtonContent()]);
279
298
  };
280
299
 
281
300
  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}
package/es/swipe/index.js CHANGED
@@ -181,16 +181,10 @@ export default createComponent({
181
181
  },
182
182
  onTouchMove: function onTouchMove(event) {
183
183
  if (!this.touchable || !this.swiping) return;
184
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
185
- // avoid affecting the parent components
186
-
187
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
188
-
189
- if (shouldPrevent) {
190
- preventDefault(event, this.stopPropagation);
191
- }
184
+ this.touchMove(event);
192
185
 
193
186
  if (this.isCorrectDirection) {
187
+ preventDefault(event, this.stopPropagation);
194
188
  this.move({
195
189
  offset: this.delta
196
190
  });
@@ -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
 
@@ -90,6 +90,14 @@ export default createComponent({
90
90
  return this.fileList;
91
91
  }
92
92
  },
93
+ created: function created() {
94
+ this.urls = [];
95
+ },
96
+ beforeDestroy: function beforeDestroy() {
97
+ this.urls.forEach(function (url) {
98
+ return URL.revokeObjectURL(url);
99
+ });
100
+ },
93
101
  methods: {
94
102
  getDetail: function getDetail(index) {
95
103
  if (index === void 0) {
@@ -268,7 +276,13 @@ export default createComponent({
268
276
  return isImageFile(item);
269
277
  });
270
278
  var imageContents = imageFiles.map(function (item) {
271
- return item.content || item.url;
279
+ if (item.file && !item.url) {
280
+ item.url = URL.createObjectURL(item.file);
281
+
282
+ _this5.urls.push(item.url);
283
+ }
284
+
285
+ return item.url;
272
286
  });
273
287
  this.imagePreview = ImagePreview(_extends({
274
288
  images: imageContents,
@@ -98,11 +98,9 @@ var _default = createComponent({
98
98
  },
99
99
  methods: {
100
100
  getHeight: function getHeight() {
101
- if (!this.height) {
102
- this.height = this.$el.getBoundingClientRect().height;
103
- }
101
+ var _this$$el;
104
102
 
105
- return this.height;
103
+ return ((_this$$el = this.$el) == null ? void 0 : _this$$el.getBoundingClientRect().height) || 0;
106
104
  },
107
105
  scrollIntoView: function scrollIntoView(body) {
108
106
  var _this$$refs = this.$refs,
@@ -114,6 +114,11 @@ var _default2 = (0, _utils.createComponent)({
114
114
  }
115
115
  }
116
116
  },
117
+ inject: {
118
+ vanPopup: {
119
+ default: null
120
+ }
121
+ },
117
122
  data: function data() {
118
123
  return {
119
124
  subtitle: '',
@@ -164,7 +169,11 @@ var _default2 = (0, _utils.createComponent)({
164
169
  }
165
170
  },
166
171
  mounted: function mounted() {
167
- this.init();
172
+ var _this$vanPopup;
173
+
174
+ this.init(); // https://github.com/youzan/vant/issues/9845
175
+
176
+ (_this$vanPopup = this.vanPopup) == null ? void 0 : _this$vanPopup.$on('opened', this.onScroll);
168
177
  },
169
178
 
170
179
  /* istanbul ignore next */
@@ -286,6 +286,9 @@ var _default2 = createComponent({
286
286
  this.updateInnerValue();
287
287
  this.$nextTick(function () {
288
288
  _this4.$nextTick(function () {
289
+ // https://github.com/youzan/vant/issues/9775
290
+ _this4.updateInnerValue();
291
+
289
292
  _this4.$emit('change', picker);
290
293
  });
291
294
  });
@@ -22,7 +22,7 @@ var _default = createComponent({
22
22
  methods: {
23
23
  // @exposed-api
24
24
  getPicker: function getPicker() {
25
- return this.$refs.root.getPicker();
25
+ return this.$refs.root.getProxiedPicker();
26
26
  }
27
27
  },
28
28
  render: function render() {
@@ -90,10 +90,32 @@ var TimePickerMixin = {
90
90
  });
91
91
  },
92
92
  methods: {
93
- // @exposed-api
94
93
  getPicker: function getPicker() {
95
94
  return this.$refs.picker;
96
95
  },
96
+ // https://github.com/youzan/vant/issues/10013
97
+ getProxiedPicker: function getProxiedPicker() {
98
+ var _this4 = this;
99
+
100
+ var picker = this.$refs.picker;
101
+
102
+ if (picker) {
103
+ var proxy = function proxy(fn) {
104
+ return function () {
105
+ picker[fn].apply(picker, arguments);
106
+
107
+ _this4.updateInnerValue();
108
+ };
109
+ };
110
+
111
+ return (0, _extends2.default)({}, picker, {
112
+ setValues: proxy('setValues'),
113
+ setIndexes: proxy('setIndexes'),
114
+ setColumnIndex: proxy('setColumnIndex'),
115
+ setColumnValue: proxy('setColumnValue')
116
+ });
117
+ }
118
+ },
97
119
  onConfirm: function onConfirm() {
98
120
  this.$emit('input', this.innerValue);
99
121
  this.$emit('confirm', this.innerValue);
@@ -103,12 +125,12 @@ var TimePickerMixin = {
103
125
  }
104
126
  },
105
127
  render: function render() {
106
- var _this4 = this;
128
+ var _this5 = this;
107
129
 
108
130
  var h = arguments[0];
109
131
  var props = {};
110
132
  Object.keys(_shared.pickerProps).forEach(function (key) {
111
- props[key] = _this4[key];
133
+ props[key] = _this5[key];
112
134
  });
113
135
  return h(_picker.default, {
114
136
  "ref": "picker",
@@ -33,6 +33,7 @@ var _default2 = (0, _shared.createComponent)({
33
33
  className: null,
34
34
  closeable: Boolean,
35
35
  asyncClose: Boolean,
36
+ overlayStyle: Object,
36
37
  showIndicators: Boolean,
37
38
  images: {
38
39
  type: Array,
@@ -29,6 +29,7 @@ var defaultConfig = {
29
29
  asyncClose: false,
30
30
  transition: 'van-fade',
31
31
  getContainer: 'body',
32
+ overlayStyle: null,
32
33
  startPosition: 0,
33
34
  swipeDuration: 300,
34
35
  showIndicators: false,