zartui 2.0.18 → 2.0.20
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/es/datetime-picker/DatePicker.js +11 -0
- package/es/datetime-picker/TimePicker.js +3 -0
- package/es/datetime-picker/index.js +1 -1
- package/es/datetime-picker/shared.js +25 -3
- package/es/datetime-picker/utils.js +4 -0
- package/es/index.js +1 -1
- package/es/picker/PickerColumn.js +64 -17
- package/es/picker/index.js +2 -2
- package/lib/datetime-picker/DatePicker.js +11 -0
- package/lib/datetime-picker/TimePicker.js +3 -0
- package/lib/datetime-picker/index.js +1 -1
- package/lib/datetime-picker/shared.js +25 -3
- package/lib/datetime-picker/utils.js +4 -0
- package/lib/index.js +1 -1
- package/lib/picker/PickerColumn.js +64 -14
- package/lib/picker/index.js +2 -2
- package/lib/zart.js +114 -27
- package/lib/zart.min.js +1 -1
- package/package.json +1 -1
|
@@ -123,6 +123,14 @@ export default createComponent({
|
|
|
123
123
|
formatValue: function formatValue(value) {
|
|
124
124
|
var _this2 = this;
|
|
125
125
|
|
|
126
|
+
if (typeof value === "string") {
|
|
127
|
+
try {
|
|
128
|
+
value = new Date(value);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error("datetime-picker strToDate error", error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
if (!isDate(value)) {
|
|
127
135
|
return null;
|
|
128
136
|
}
|
|
@@ -276,6 +284,9 @@ export default createComponent({
|
|
|
276
284
|
this.updateInnerValue();
|
|
277
285
|
this.$nextTick(function () {
|
|
278
286
|
_this4.$nextTick(function () {
|
|
287
|
+
// https://github.com/vant-ui/vant/issues/9775
|
|
288
|
+
_this4.updateInnerValue();
|
|
289
|
+
|
|
279
290
|
_this4.$emit('change', picker);
|
|
280
291
|
});
|
|
281
292
|
});
|
|
@@ -122,6 +122,9 @@ export default createComponent({
|
|
|
122
122
|
this.updateInnerValue();
|
|
123
123
|
this.$nextTick(function () {
|
|
124
124
|
_this2.$nextTick(function () {
|
|
125
|
+
// https://github.com/vant-ui/vant/issues/9775
|
|
126
|
+
_this2.updateInnerValue();
|
|
127
|
+
|
|
125
128
|
_this2.$emit('change', picker);
|
|
126
129
|
});
|
|
127
130
|
});
|
|
@@ -123,10 +123,32 @@ export var TimePickerMixin = {
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
methods: {
|
|
126
|
-
// @exposed-api
|
|
127
126
|
getPicker: function getPicker() {
|
|
128
127
|
return this.$refs.picker;
|
|
129
128
|
},
|
|
129
|
+
// https://github.com/vant-ui/vant/issues/10013
|
|
130
|
+
getProxiedPicker: function getProxiedPicker() {
|
|
131
|
+
var _this5 = this;
|
|
132
|
+
|
|
133
|
+
var picker = this.$refs.picker;
|
|
134
|
+
|
|
135
|
+
if (picker) {
|
|
136
|
+
var proxy = function proxy(fn) {
|
|
137
|
+
return function () {
|
|
138
|
+
picker[fn].apply(picker, arguments);
|
|
139
|
+
|
|
140
|
+
_this5.updateInnerValue();
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return _extends({}, picker, {
|
|
145
|
+
setValues: proxy('setValues'),
|
|
146
|
+
setIndexes: proxy('setIndexes'),
|
|
147
|
+
setColumnIndex: proxy('setColumnIndex'),
|
|
148
|
+
setColumnValue: proxy('setColumnValue')
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
},
|
|
130
152
|
onConfirm: function onConfirm() {
|
|
131
153
|
this.$emit('input', this.innerValue);
|
|
132
154
|
this.$emit('confirm', this.innerValue);
|
|
@@ -136,12 +158,12 @@ export var TimePickerMixin = {
|
|
|
136
158
|
}
|
|
137
159
|
},
|
|
138
160
|
render: function render() {
|
|
139
|
-
var
|
|
161
|
+
var _this6 = this;
|
|
140
162
|
|
|
141
163
|
var h = arguments[0];
|
|
142
164
|
var props = {};
|
|
143
165
|
Object.keys(pickerProps).forEach(function (key) {
|
|
144
|
-
props[key] =
|
|
166
|
+
props[key] = _this6[key];
|
|
145
167
|
});
|
|
146
168
|
return h(Picker, {
|
|
147
169
|
"attrs": {
|
package/es/index.js
CHANGED
|
@@ -76,7 +76,7 @@ import Tag from './tag';
|
|
|
76
76
|
import Timeline from './timeline';
|
|
77
77
|
import Toast from './toast';
|
|
78
78
|
import Uploader from './uploader';
|
|
79
|
-
var version = '2.0.
|
|
79
|
+
var version = '2.0.20';
|
|
80
80
|
|
|
81
81
|
function install(Vue) {
|
|
82
82
|
var components = [ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, PdfViewer, PdfViewerV2, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, Timeline, Toast, Uploader];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import _mergeJSXProps2 from "@vue/babel-helper-vue-jsx-merge-props";
|
|
2
2
|
import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
|
|
3
3
|
import { deepClone } from '../utils/deep-clone';
|
|
4
|
-
import { createNamespace, isObject } from '../utils';
|
|
4
|
+
import { createNamespace, inBrowser, 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 = inBrowser && 'onwheel' in window;
|
|
33
|
+
var mousewheelTimer = null;
|
|
30
34
|
export default createComponent({
|
|
31
35
|
mixins: [TouchMixin],
|
|
32
36
|
props: {
|
|
@@ -64,11 +68,19 @@ export default createComponent({
|
|
|
64
68
|
},
|
|
65
69
|
mounted: function mounted() {
|
|
66
70
|
this.bindTouchEvent(this.$el);
|
|
71
|
+
|
|
72
|
+
if (supportMousewheel) {
|
|
73
|
+
on(this.$el, 'wheel', this.onMouseWheel, false);
|
|
74
|
+
}
|
|
67
75
|
},
|
|
68
76
|
destroyed: function destroyed() {
|
|
69
77
|
if (this.columnCollector) {
|
|
70
78
|
this.columnCollector.splice(this.columnCollector.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
|
|
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 !==
|
|
197
|
-
|
|
245
|
+
if (index !== _this3.currentIndex) {
|
|
246
|
+
_this3.currentIndex = index;
|
|
198
247
|
|
|
199
248
|
if (emitChange) {
|
|
200
|
-
|
|
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
|
|
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 =
|
|
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 ===
|
|
315
|
+
selected: index === _this4.currentIndex
|
|
267
316
|
})],
|
|
268
317
|
on: {
|
|
269
318
|
click: function click() {
|
|
270
|
-
|
|
319
|
+
_this4.onClickItem(index);
|
|
271
320
|
}
|
|
272
321
|
}
|
|
273
322
|
};
|
|
274
323
|
var childData = {
|
|
275
324
|
class: 'zt-ellipsis',
|
|
276
|
-
domProps: (_domProps = {}, _domProps[
|
|
325
|
+
domProps: (_domProps = {}, _domProps[_this4.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
|
|
277
326
|
};
|
|
278
|
-
return h("li", _mergeJSXProps2([{}, data]), [
|
|
327
|
+
return h("li", _mergeJSXProps2([{}, data]), [_this4.slots('option', option) || h("div", _mergeJSXProps([{}, childData]))]);
|
|
279
328
|
});
|
|
280
329
|
},
|
|
281
330
|
recordConfirmIndex: function recordConfirmIndex() {
|
|
@@ -284,8 +333,6 @@ export default createComponent({
|
|
|
284
333
|
setConfirmIndex: function setConfirmIndex() {
|
|
285
334
|
if (this.confirmIndex || this.confirmIndex === 0) {
|
|
286
335
|
this.setIndex(this.confirmIndex, true);
|
|
287
|
-
} else {
|
|
288
|
-
this.setIndex(this.defaultIndex, true);
|
|
289
336
|
}
|
|
290
337
|
}
|
|
291
338
|
},
|
package/es/picker/index.js
CHANGED
|
@@ -152,7 +152,7 @@ export default createComponent({
|
|
|
152
152
|
} else {
|
|
153
153
|
var values = this.getValues(); // compatible with old version of wrong parameters
|
|
154
154
|
// should be removed in next major version
|
|
155
|
-
// see: https://github.com/
|
|
155
|
+
// see: https://github.com/vant-ui/vant/issues/5905
|
|
156
156
|
|
|
157
157
|
if (this.dataType === 'cascade') {
|
|
158
158
|
values = values.map(function (item) {
|
|
@@ -191,7 +191,7 @@ export default createComponent({
|
|
|
191
191
|
} else {
|
|
192
192
|
var values = this.getValues(); // compatible with old version of wrong parameters
|
|
193
193
|
// should be removed in next major version
|
|
194
|
-
// see: https://github.com/
|
|
194
|
+
// see: https://github.com/vant-ui/vant/issues/5905
|
|
195
195
|
|
|
196
196
|
if (this.dataType === 'cascade') {
|
|
197
197
|
values = values.map(function (item) {
|
|
@@ -137,6 +137,14 @@ var _default2 = createComponent({
|
|
|
137
137
|
formatValue: function formatValue(value) {
|
|
138
138
|
var _this2 = this;
|
|
139
139
|
|
|
140
|
+
if (typeof value === "string") {
|
|
141
|
+
try {
|
|
142
|
+
value = new Date(value);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error("datetime-picker strToDate error", error);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
140
148
|
if (!(0, _date.isDate)(value)) {
|
|
141
149
|
return null;
|
|
142
150
|
}
|
|
@@ -290,6 +298,9 @@ var _default2 = createComponent({
|
|
|
290
298
|
this.updateInnerValue();
|
|
291
299
|
this.$nextTick(function () {
|
|
292
300
|
_this4.$nextTick(function () {
|
|
301
|
+
// https://github.com/vant-ui/vant/issues/9775
|
|
302
|
+
_this4.updateInnerValue();
|
|
303
|
+
|
|
293
304
|
_this4.$emit('change', picker);
|
|
294
305
|
});
|
|
295
306
|
});
|
|
@@ -133,6 +133,9 @@ var _default = createComponent({
|
|
|
133
133
|
this.updateInnerValue();
|
|
134
134
|
this.$nextTick(function () {
|
|
135
135
|
_this2.$nextTick(function () {
|
|
136
|
+
// https://github.com/vant-ui/vant/issues/9775
|
|
137
|
+
_this2.updateInnerValue();
|
|
138
|
+
|
|
136
139
|
_this2.$emit('change', picker);
|
|
137
140
|
});
|
|
138
141
|
});
|
|
@@ -137,10 +137,32 @@ var TimePickerMixin = {
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
methods: {
|
|
140
|
-
// @exposed-api
|
|
141
140
|
getPicker: function getPicker() {
|
|
142
141
|
return this.$refs.picker;
|
|
143
142
|
},
|
|
143
|
+
// https://github.com/vant-ui/vant/issues/10013
|
|
144
|
+
getProxiedPicker: function getProxiedPicker() {
|
|
145
|
+
var _this5 = this;
|
|
146
|
+
|
|
147
|
+
var picker = this.$refs.picker;
|
|
148
|
+
|
|
149
|
+
if (picker) {
|
|
150
|
+
var proxy = function proxy(fn) {
|
|
151
|
+
return function () {
|
|
152
|
+
picker[fn].apply(picker, arguments);
|
|
153
|
+
|
|
154
|
+
_this5.updateInnerValue();
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
return (0, _extends2.default)({}, picker, {
|
|
159
|
+
setValues: proxy('setValues'),
|
|
160
|
+
setIndexes: proxy('setIndexes'),
|
|
161
|
+
setColumnIndex: proxy('setColumnIndex'),
|
|
162
|
+
setColumnValue: proxy('setColumnValue')
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
},
|
|
144
166
|
onConfirm: function onConfirm() {
|
|
145
167
|
this.$emit('input', this.innerValue);
|
|
146
168
|
this.$emit('confirm', this.innerValue);
|
|
@@ -150,12 +172,12 @@ var TimePickerMixin = {
|
|
|
150
172
|
}
|
|
151
173
|
},
|
|
152
174
|
render: function render() {
|
|
153
|
-
var
|
|
175
|
+
var _this6 = this;
|
|
154
176
|
|
|
155
177
|
var h = arguments[0];
|
|
156
178
|
var props = {};
|
|
157
179
|
Object.keys(_shared.pickerProps).forEach(function (key) {
|
|
158
|
-
props[key] =
|
|
180
|
+
props[key] = _this6[key];
|
|
159
181
|
});
|
|
160
182
|
return h(_picker.default, {
|
|
161
183
|
"attrs": {
|
package/lib/index.js
CHANGED
|
@@ -317,7 +317,7 @@ exports.Toast = _toast.default;
|
|
|
317
317
|
var _uploader = _interopRequireDefault(require("./uploader"));
|
|
318
318
|
|
|
319
319
|
exports.Uploader = _uploader.default;
|
|
320
|
-
var version = '2.0.
|
|
320
|
+
var version = '2.0.20';
|
|
321
321
|
exports.version = version;
|
|
322
322
|
|
|
323
323
|
function install(Vue) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.MOMENTUM_LIMIT_DISTANCE = exports.MOMENTUM_LIMIT_TIME = void 0;
|
|
7
7
|
|
|
8
8
|
var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
|
|
9
9
|
|
|
@@ -22,7 +22,9 @@ var DEFAULT_DURATION = 200; // 惯性滑动思路:
|
|
|
22
22
|
// 距离大于 `MOMENTUM_LIMIT_DISTANCE` 时,执行惯性滑动
|
|
23
23
|
|
|
24
24
|
var MOMENTUM_LIMIT_TIME = 300;
|
|
25
|
+
exports.MOMENTUM_LIMIT_TIME = MOMENTUM_LIMIT_TIME;
|
|
25
26
|
var MOMENTUM_LIMIT_DISTANCE = 15;
|
|
27
|
+
exports.MOMENTUM_LIMIT_DISTANCE = MOMENTUM_LIMIT_DISTANCE;
|
|
26
28
|
|
|
27
29
|
var _createNamespace = (0, _utils.createNamespace)('picker-column'),
|
|
28
30
|
createComponent = _createNamespace[0],
|
|
@@ -37,7 +39,12 @@ function getElementTranslateY(element) {
|
|
|
37
39
|
|
|
38
40
|
function isOptionDisabled(option) {
|
|
39
41
|
return (0, _utils.isObject)(option) && option.disabled;
|
|
40
|
-
}
|
|
42
|
+
} // use standard WheelEvent:
|
|
43
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var supportMousewheel = _utils.inBrowser && 'onwheel' in window;
|
|
47
|
+
var mousewheelTimer = null;
|
|
41
48
|
|
|
42
49
|
var _default2 = createComponent({
|
|
43
50
|
mixins: [_touch.TouchMixin],
|
|
@@ -76,11 +83,19 @@ var _default2 = createComponent({
|
|
|
76
83
|
},
|
|
77
84
|
mounted: function mounted() {
|
|
78
85
|
this.bindTouchEvent(this.$el);
|
|
86
|
+
|
|
87
|
+
if (supportMousewheel) {
|
|
88
|
+
(0, _event.on)(this.$el, 'wheel', this.onMouseWheel, false);
|
|
89
|
+
}
|
|
79
90
|
},
|
|
80
91
|
destroyed: function destroyed() {
|
|
81
92
|
if (this.columnCollector) {
|
|
82
93
|
this.columnCollector.splice(this.columnCollector.indexOf(this), 1);
|
|
83
94
|
}
|
|
95
|
+
|
|
96
|
+
if (supportMousewheel) {
|
|
97
|
+
(0, _event.off)(this.$el, 'wheel');
|
|
98
|
+
}
|
|
84
99
|
},
|
|
85
100
|
watch: {
|
|
86
101
|
initialOptions: 'setOptions',
|
|
@@ -168,6 +183,43 @@ var _default2 = createComponent({
|
|
|
168
183
|
_this.moving = false;
|
|
169
184
|
}, 0);
|
|
170
185
|
},
|
|
186
|
+
onMouseWheel: function onMouseWheel(event) {
|
|
187
|
+
var _this2 = this;
|
|
188
|
+
|
|
189
|
+
if (this.readonly) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
(0, _event.preventDefault)(event, true); // simply combine touchstart and touchmove
|
|
194
|
+
|
|
195
|
+
var translateY = getElementTranslateY(this.$refs.wrapper);
|
|
196
|
+
this.startOffset = Math.min(0, translateY - this.baseOffset);
|
|
197
|
+
this.momentumOffset = this.startOffset;
|
|
198
|
+
this.transitionEndTrigger = null; // directly use deltaY, see https://caniuse.com/?search=deltaY
|
|
199
|
+
// use deltaY to detect direction for not special setting device
|
|
200
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event
|
|
201
|
+
|
|
202
|
+
var deltaY = event.deltaY;
|
|
203
|
+
|
|
204
|
+
if (this.startOffset === 0 && deltaY < 0) {
|
|
205
|
+
return;
|
|
206
|
+
} // get offset
|
|
207
|
+
// if necessary, can adjust distance value to make scrolling smoother
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
var distance = -deltaY;
|
|
211
|
+
this.offset = (0, _number.range)(this.startOffset + distance, -(this.count * this.itemHeight), this.itemHeight);
|
|
212
|
+
|
|
213
|
+
if (mousewheelTimer) {
|
|
214
|
+
clearTimeout(mousewheelTimer);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
mousewheelTimer = setTimeout(function () {
|
|
218
|
+
_this2.onTouchEnd();
|
|
219
|
+
|
|
220
|
+
_this2.touchStartTime = 0;
|
|
221
|
+
}, MOMENTUM_LIMIT_TIME);
|
|
222
|
+
},
|
|
171
223
|
onTransitionEnd: function onTransitionEnd() {
|
|
172
224
|
this.stopMomentum();
|
|
173
225
|
},
|
|
@@ -199,17 +251,17 @@ var _default2 = createComponent({
|
|
|
199
251
|
return option;
|
|
200
252
|
},
|
|
201
253
|
setIndex: function setIndex(index, emitChange) {
|
|
202
|
-
var
|
|
254
|
+
var _this3 = this;
|
|
203
255
|
|
|
204
256
|
index = this.adjustIndex(index) || 0;
|
|
205
257
|
var offset = -index * this.itemHeight;
|
|
206
258
|
|
|
207
259
|
var trigger = function trigger() {
|
|
208
|
-
if (index !==
|
|
209
|
-
|
|
260
|
+
if (index !== _this3.currentIndex) {
|
|
261
|
+
_this3.currentIndex = index;
|
|
210
262
|
|
|
211
263
|
if (emitChange) {
|
|
212
|
-
|
|
264
|
+
_this3.$emit('change', index);
|
|
213
265
|
}
|
|
214
266
|
}
|
|
215
267
|
}; // trigger the change event after transitionend when moving
|
|
@@ -255,7 +307,7 @@ var _default2 = createComponent({
|
|
|
255
307
|
}
|
|
256
308
|
},
|
|
257
309
|
genOptions: function genOptions() {
|
|
258
|
-
var
|
|
310
|
+
var _this4 = this;
|
|
259
311
|
|
|
260
312
|
var h = this.$createElement;
|
|
261
313
|
var optionStyle = {
|
|
@@ -264,7 +316,7 @@ var _default2 = createComponent({
|
|
|
264
316
|
return this.options.map(function (option, index) {
|
|
265
317
|
var _domProps;
|
|
266
318
|
|
|
267
|
-
var text =
|
|
319
|
+
var text = _this4.getOptionText(option);
|
|
268
320
|
|
|
269
321
|
var disabled = isOptionDisabled(option);
|
|
270
322
|
var data = {
|
|
@@ -275,19 +327,19 @@ var _default2 = createComponent({
|
|
|
275
327
|
},
|
|
276
328
|
class: [bem('item', {
|
|
277
329
|
disabled: disabled,
|
|
278
|
-
selected: index ===
|
|
330
|
+
selected: index === _this4.currentIndex
|
|
279
331
|
})],
|
|
280
332
|
on: {
|
|
281
333
|
click: function click() {
|
|
282
|
-
|
|
334
|
+
_this4.onClickItem(index);
|
|
283
335
|
}
|
|
284
336
|
}
|
|
285
337
|
};
|
|
286
338
|
var childData = {
|
|
287
339
|
class: 'zt-ellipsis',
|
|
288
|
-
domProps: (_domProps = {}, _domProps[
|
|
340
|
+
domProps: (_domProps = {}, _domProps[_this4.allowHtml ? 'innerHTML' : 'textContent'] = text, _domProps)
|
|
289
341
|
};
|
|
290
|
-
return h("li", (0, _babelHelperVueJsxMergeProps.default)([{}, data]), [
|
|
342
|
+
return h("li", (0, _babelHelperVueJsxMergeProps.default)([{}, data]), [_this4.slots('option', option) || h("div", (0, _babelHelperVueJsxMergeProps.default)([{}, childData]))]);
|
|
291
343
|
});
|
|
292
344
|
},
|
|
293
345
|
recordConfirmIndex: function recordConfirmIndex() {
|
|
@@ -296,8 +348,6 @@ var _default2 = createComponent({
|
|
|
296
348
|
setConfirmIndex: function setConfirmIndex() {
|
|
297
349
|
if (this.confirmIndex || this.confirmIndex === 0) {
|
|
298
350
|
this.setIndex(this.confirmIndex, true);
|
|
299
|
-
} else {
|
|
300
|
-
this.setIndex(this.defaultIndex, true);
|
|
301
351
|
}
|
|
302
352
|
}
|
|
303
353
|
},
|
package/lib/picker/index.js
CHANGED
|
@@ -168,7 +168,7 @@ var _default2 = createComponent({
|
|
|
168
168
|
} else {
|
|
169
169
|
var values = this.getValues(); // compatible with old version of wrong parameters
|
|
170
170
|
// should be removed in next major version
|
|
171
|
-
// see: https://github.com/
|
|
171
|
+
// see: https://github.com/vant-ui/vant/issues/5905
|
|
172
172
|
|
|
173
173
|
if (this.dataType === 'cascade') {
|
|
174
174
|
values = values.map(function (item) {
|
|
@@ -207,7 +207,7 @@ var _default2 = createComponent({
|
|
|
207
207
|
} else {
|
|
208
208
|
var values = this.getValues(); // compatible with old version of wrong parameters
|
|
209
209
|
// should be removed in next major version
|
|
210
|
-
// see: https://github.com/
|
|
210
|
+
// see: https://github.com/vant-ui/vant/issues/5905
|
|
211
211
|
|
|
212
212
|
if (this.dataType === 'cascade') {
|
|
213
213
|
values = values.map(function (item) {
|