zartui 2.0.79 → 2.0.80-beta.1
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/action-sheet/index.js +15 -26
- package/es/area/index.js +5 -41
- package/es/avatar/index.js +3 -16
- package/es/back-top/index.js +4 -19
- package/es/badge/index.js +4 -12
- package/es/button/index.js +20 -40
- package/es/calendar/components/Header.js +3 -12
- package/es/calendar/components/Month.js +12 -65
- package/es/calendar/index.js +23 -94
- package/es/calendar/types.js +0 -6
- package/es/calendar/utils.js +5 -16
- package/es/cascader/index.js +4 -37
- package/es/cell/index.js +19 -37
- package/es/cell-group/index.js +5 -8
- package/es/checkbox/index.js +4 -11
- package/es/checkbox-group/index.js +4 -9
- package/es/col/index.js +6 -11
- package/es/collapse/index.js +2 -5
- package/es/collapse-item/index.js +19 -35
- package/es/count-down/index.js +2 -15
- package/es/count-down/utils.js +3 -10
- package/es/datetime-picker/DatePicker.js +12 -70
- package/es/datetime-picker/TimePicker.js +10 -23
- package/es/datetime-picker/index.js +2 -4
- package/es/datetime-picker/shared.js +5 -19
- package/es/datetime-picker/utils.js +0 -5
- package/es/dialog/Dialog.js +6 -21
- package/es/dialog/index.js +0 -16
- package/es/divider/index.js +5 -6
- package/es/dropdown-item/index.js +22 -35
- package/es/dropdown-menu/index.js +4 -9
- package/es/empty/index.js +3 -11
- package/es/field/index.js +20 -83
- package/es/fold-dialog/index.js +5 -20
- package/es/form/index.js +2 -18
- package/es/grid/index.js +2 -6
- package/es/grid-item/index.js +17 -30
- package/es/hierarchy-select/breadcrumb.js +2 -6
- package/es/hierarchy-select/index.js +3 -12
- package/es/hierarchy-select/markList.js +2 -25
- package/es/hierarchy-select/svg/SubIcon.js +0 -1
- package/es/icon/index.js +9 -13
- package/es/image/index.js +2 -17
- package/es/image-preview/ImagePreview.js +4 -8
- package/es/image-preview/ImagePreviewItem.js +14 -30
- package/es/image-preview/index.js +0 -12
- package/es/image-preview/shared.js +2 -4
- package/es/index-anchor/index.js +2 -6
- package/es/index-bar/IndexIndicate.js +0 -1
- package/es/index-bar/index.js +7 -28
- package/es/index.js +1 -4
- package/es/info/index.js +6 -8
- package/es/list/index.js +11 -27
- package/es/loading/index.js +7 -15
- package/es/locale/index.js +0 -2
- package/es/media-picker/index.js +33 -117
- package/es/media-picker/media-util.js +2 -5
- package/es/media-picker/type.js +0 -5
- package/es/media-player/index.js +7 -17
- package/es/mixins/bind-event.js +0 -3
- package/es/mixins/checkbox.js +5 -11
- package/es/mixins/click-outside.js +0 -2
- package/es/mixins/close-on-popstate.js +0 -1
- package/es/mixins/field.js +0 -2
- package/es/mixins/popup/index.js +12 -28
- package/es/mixins/popup/overlay.js +1 -11
- package/es/mixins/portal.js +2 -8
- package/es/mixins/relation.js +0 -8
- package/es/mixins/slots.js +1 -4
- package/es/mixins/touch.js +4 -9
- package/es/multiple-picker/MultiplePickerOptions.js +2 -18
- package/es/multiple-picker/index.js +5 -17
- package/es/nav-bar/index.js +4 -12
- package/es/notice-bar/index.js +10 -28
- package/es/number-keyboard/Key.js +2 -10
- package/es/number-keyboard/index.js +4 -19
- package/es/overlay/index.js +5 -8
- package/es/password-input/index.js +10 -16
- package/es/picker/PickerColumn.js +20 -54
- package/es/picker/index.js +13 -42
- package/es/popover/index.js +11 -20
- package/es/popup/index.js +5 -21
- package/es/pull-refresh/index.js +15 -32
- package/es/radio/index.js +2 -4
- package/es/radio-group/index.js +2 -4
- package/es/rate/index.js +12 -26
- package/es/row/index.js +3 -9
- package/es/search/index.js +8 -13
- package/es/signature/bezier.js +5 -12
- package/es/signature/force-landscape.js +0 -5
- package/es/signature/index.js +5 -24
- package/es/signature/point.js +1 -6
- package/es/signature/throttle.js +1 -10
- package/es/skeleton/index.js +5 -15
- package/es/slider/index.js +19 -55
- package/es/step/index.js +5 -12
- package/es/stepper/index.js +10 -37
- package/es/steps/index.js +2 -4
- package/es/sticky/index.js +8 -50
- package/es/swipe/index.js +19 -62
- package/es/swipe-cell/index.js +7 -23
- package/es/swipe-item/index.js +9 -19
- package/es/switch/index.js +8 -10
- package/es/switch/shared.js +1 -0
- package/es/switch-cell/index.js +7 -7
- package/es/tab/index.js +4 -15
- package/es/tabbar/index.js +4 -14
- package/es/tabbar-item/index.js +7 -15
- package/es/table/index.js +10 -35
- package/es/tabs/Content.js +5 -9
- package/es/tabs/Title.js +11 -19
- package/es/tabs/index.js +16 -51
- package/es/tabs/utils.js +0 -8
- package/es/tag/index.js +13 -17
- package/es/timeline/index.js +2 -25
- package/es/toast/Toast.js +11 -23
- package/es/toast/index.js +6 -33
- package/es/toast/lock-click.js +0 -2
- package/es/uploader/index.js +11 -62
- package/es/uploader/utils.js +0 -10
- package/es/utils/constant.js +2 -1
- package/es/utils/create/bem.js +1 -5
- package/es/utils/create/component.js +4 -7
- package/es/utils/create/i18n.js +0 -2
- package/es/utils/deep-assign.js +0 -4
- package/es/utils/deep-clone.js +0 -3
- package/es/utils/dom/event.js +2 -5
- package/es/utils/dom/node.js +0 -1
- package/es/utils/dom/raf.js +7 -6
- package/es/utils/dom/reset-scroll.js +2 -1
- package/es/utils/dom/scroll.js +8 -17
- package/es/utils/dom/style.js +3 -2
- package/es/utils/easings.js +2 -4
- package/es/utils/format/date-util.js +54 -122
- package/es/utils/format/number.js +2 -11
- package/es/utils/format/string.js +0 -3
- package/es/utils/format/unit.js +2 -12
- package/es/utils/functional.js +6 -9
- package/es/utils/getScroll.js +0 -5
- package/es/utils/index.js +3 -5
- package/es/utils/interceptor.js +2 -4
- package/es/utils/media/image-util.js +7 -19
- package/es/utils/raf.js +4 -12
- package/es/utils/router.js +7 -6
- package/es/utils/scrollTo.js +7 -12
- package/es/utils/validate/number.js +2 -2
- package/es/utils/vnodes.js +2 -8
- package/lib/action-sheet/index.js +11 -35
- package/lib/area/index.js +5 -45
- package/lib/avatar/index.js +3 -18
- package/lib/back-top/index.js +4 -25
- package/lib/badge/index.js +4 -15
- package/lib/button/index.js +19 -50
- package/lib/calendar/components/Header.js +3 -18
- package/lib/calendar/components/Month.js +12 -71
- package/lib/calendar/index.js +21 -106
- package/lib/calendar/types.js +0 -7
- package/lib/calendar/utils.js +5 -32
- package/lib/cascader/index.js +4 -46
- package/lib/cell/index.js +18 -48
- package/lib/cell-group/index.js +5 -15
- package/lib/checkbox/index.js +4 -14
- package/lib/checkbox-group/index.js +4 -13
- package/lib/col/index.js +6 -14
- package/lib/collapse/index.js +2 -8
- package/lib/collapse-item/index.js +18 -43
- package/lib/count-down/index.js +2 -19
- package/lib/count-down/utils.js +3 -15
- package/lib/datetime-picker/DatePicker.js +12 -81
- package/lib/datetime-picker/TimePicker.js +10 -30
- package/lib/datetime-picker/index.js +2 -10
- package/lib/datetime-picker/shared.js +5 -27
- package/lib/datetime-picker/utils.js +0 -9
- package/lib/dialog/Dialog.js +6 -28
- package/lib/dialog/index.js +0 -22
- package/lib/divider/index.js +5 -12
- package/lib/dropdown-item/index.js +21 -44
- package/lib/dropdown-menu/index.js +4 -15
- package/lib/empty/index.js +3 -23
- package/lib/field/index.js +20 -96
- package/lib/fold-dialog/index.js +5 -22
- package/lib/form/index.js +2 -21
- package/lib/grid/index.js +2 -10
- package/lib/grid-item/index.js +16 -37
- package/lib/hierarchy-select/breadcrumb.js +3 -10
- package/lib/hierarchy-select/index.js +4 -20
- package/lib/hierarchy-select/markList.js +3 -31
- package/lib/hierarchy-select/svg/SubIcon.js +0 -1
- package/lib/icon/index.js +8 -19
- package/lib/image/index.js +2 -22
- package/lib/image-preview/ImagePreview.js +0 -16
- package/lib/image-preview/ImagePreviewItem.js +13 -36
- package/lib/image-preview/index.js +0 -16
- package/lib/image-preview/shared.js +2 -5
- package/lib/index-anchor/index.js +2 -11
- package/lib/index-bar/IndexIndicate.js +0 -1
- package/lib/index-bar/index.js +7 -37
- package/lib/index.js +1 -157
- package/lib/info/index.js +6 -14
- package/lib/lazyload/index.js +0 -3
- package/lib/list/index.js +10 -33
- package/lib/loading/index.js +7 -21
- package/lib/locale/index.js +0 -7
- package/lib/media-picker/index.js +27 -153
- package/lib/media-picker/media-util.js +2 -15
- package/lib/media-picker/type.js +0 -5
- package/lib/media-player/index.js +6 -22
- package/lib/mixins/bind-event.js +1 -6
- package/lib/mixins/checkbox.js +6 -18
- package/lib/mixins/click-outside.js +1 -5
- package/lib/mixins/close-on-popstate.js +0 -4
- package/lib/mixins/field.js +0 -2
- package/lib/mixins/popup/index.js +11 -36
- package/lib/mixins/popup/overlay.js +1 -23
- package/lib/mixins/portal.js +2 -9
- package/lib/mixins/relation.js +0 -11
- package/lib/mixins/slots.js +1 -5
- package/lib/mixins/touch.js +4 -11
- package/lib/multiple-picker/MultiplePickerOptions.js +2 -23
- package/lib/multiple-picker/index.js +5 -26
- package/lib/nav-bar/index.js +4 -16
- package/lib/notice-bar/index.js +10 -40
- package/lib/number-keyboard/Key.js +2 -17
- package/lib/number-keyboard/index.js +4 -26
- package/lib/overlay/index.js +5 -16
- package/lib/password-input/index.js +10 -23
- package/lib/picker/PickerColumn.js +19 -63
- package/lib/picker/index.js +13 -53
- package/lib/popover/index.js +9 -27
- package/lib/popup/index.js +5 -27
- package/lib/pull-refresh/index.js +14 -38
- package/lib/radio/index.js +2 -7
- package/lib/radio-group/index.js +2 -8
- package/lib/rate/index.js +11 -31
- package/lib/row/index.js +3 -12
- package/lib/search/index.js +7 -21
- package/lib/signature/bezier.js +5 -15
- package/lib/signature/force-landscape.js +0 -11
- package/lib/signature/index.js +6 -31
- package/lib/signature/point.js +0 -8
- package/lib/signature/throttle.js +1 -11
- package/lib/skeleton/index.js +5 -21
- package/lib/slider/index.js +19 -63
- package/lib/step/index.js +5 -18
- package/lib/stepper/index.js +10 -46
- package/lib/steps/index.js +2 -7
- package/lib/sticky/index.js +8 -59
- package/lib/swipe/index.js +19 -70
- package/lib/swipe-cell/index.js +7 -29
- package/lib/swipe-item/index.js +9 -24
- package/lib/switch/index.js +7 -14
- package/lib/switch/shared.js +1 -1
- package/lib/switch-cell/index.js +6 -16
- package/lib/tab/index.js +4 -21
- package/lib/tabbar/index.js +4 -19
- package/lib/tabbar-item/index.js +5 -21
- package/lib/table/index.js +10 -38
- package/lib/tabs/Content.js +5 -15
- package/lib/tabs/Title.js +11 -23
- package/lib/tabs/index.js +15 -65
- package/lib/tabs/utils.js +0 -13
- package/lib/tag/index.js +12 -23
- package/lib/timeline/index.js +2 -32
- package/lib/toast/Toast.js +10 -30
- package/lib/toast/index.js +6 -38
- package/lib/toast/lock-click.js +0 -3
- package/lib/uploader/index.js +10 -72
- package/lib/uploader/utils.js +0 -17
- package/lib/utils/constant.js +2 -1
- package/lib/utils/create/bem.js +1 -6
- package/lib/utils/create/component.js +5 -14
- package/lib/utils/create/i18n.js +0 -8
- package/lib/utils/create/index.js +0 -4
- package/lib/utils/deep-assign.js +0 -6
- package/lib/utils/deep-clone.js +0 -5
- package/lib/utils/device.js +0 -2
- package/lib/utils/dom/event.js +2 -10
- package/lib/utils/dom/node.js +0 -2
- package/lib/utils/dom/raf.js +7 -11
- package/lib/utils/dom/reset-scroll.js +2 -4
- package/lib/utils/dom/scroll.js +8 -28
- package/lib/utils/dom/style.js +3 -3
- package/lib/utils/easings.js +2 -5
- package/lib/utils/format/date-util.js +54 -168
- package/lib/utils/format/number.js +2 -13
- package/lib/utils/format/string.js +0 -5
- package/lib/utils/format/unit.js +2 -16
- package/lib/utils/functional.js +6 -14
- package/lib/utils/getScroll.js +0 -7
- package/lib/utils/index.js +3 -19
- package/lib/utils/interceptor.js +2 -6
- package/lib/utils/media/image-util.js +7 -25
- package/lib/utils/raf.js +4 -13
- package/lib/utils/router.js +7 -9
- package/lib/utils/scrollTo.js +9 -21
- package/lib/utils/validate/date.js +0 -2
- package/lib/utils/validate/email.js +0 -1
- package/lib/utils/validate/mobile.js +0 -1
- package/lib/utils/validate/number.js +2 -4
- package/lib/utils/validate/system.js +0 -3
- package/lib/utils/vnodes.js +2 -9
- package/lib/zart.js +57 -18
- package/lib/zart.min.js +1 -1
- package/package.json +17 -18
|
@@ -5,30 +5,27 @@ import { createNamespace, inBrowser, isObject } from '../utils';
|
|
|
5
5
|
import { range } from '../utils/format/number';
|
|
6
6
|
import { preventDefault, on, off } from '../utils/dom/event';
|
|
7
7
|
import { TouchMixin } from '../mixins/touch';
|
|
8
|
-
var DEFAULT_DURATION = 200;
|
|
8
|
+
var DEFAULT_DURATION = 200;
|
|
9
|
+
|
|
10
|
+
// 惯性滑动思路:
|
|
9
11
|
// 在手指离开屏幕时,如果和上一次 move 时的间隔小于 `MOMENTUM_LIMIT_TIME` 且 move
|
|
10
12
|
// 距离大于 `MOMENTUM_LIMIT_DISTANCE` 时,执行惯性滑动
|
|
11
|
-
|
|
12
13
|
export var MOMENTUM_LIMIT_TIME = 300;
|
|
13
14
|
export var MOMENTUM_LIMIT_DISTANCE = 15;
|
|
14
|
-
|
|
15
15
|
var _createNamespace = createNamespace('picker-column'),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
createComponent = _createNamespace[0],
|
|
17
|
+
bem = _createNamespace[1];
|
|
19
18
|
function getElementTranslateY(element) {
|
|
20
19
|
var style = window.getComputedStyle(element);
|
|
21
20
|
var transform = style.transform || style.webkitTransform;
|
|
22
21
|
var translateY = transform.slice(7, transform.length - 1).split(', ')[5];
|
|
23
22
|
return Number(translateY);
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
function isOptionDisabled(option) {
|
|
27
25
|
return isObject(option) && option.disabled;
|
|
28
|
-
}
|
|
26
|
+
}
|
|
27
|
+
// use standard WheelEvent:
|
|
29
28
|
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
|
|
30
|
-
|
|
31
|
-
|
|
32
29
|
var supportMousewheel = inBrowser && 'onwheel' in window;
|
|
33
30
|
var mousewheelTimer = null;
|
|
34
31
|
export default createComponent({
|
|
@@ -63,12 +60,10 @@ export default createComponent({
|
|
|
63
60
|
if (this.columnCollector) {
|
|
64
61
|
this.columnCollector.push(this);
|
|
65
62
|
}
|
|
66
|
-
|
|
67
63
|
this.setIndex(this.currentIndex);
|
|
68
64
|
},
|
|
69
65
|
mounted: function mounted() {
|
|
70
66
|
this.bindTouchEvent(this.$el);
|
|
71
|
-
|
|
72
67
|
if (supportMousewheel) {
|
|
73
68
|
on(this.$el, 'wheel', this.onMouseWheel, false);
|
|
74
69
|
}
|
|
@@ -77,7 +72,6 @@ export default createComponent({
|
|
|
77
72
|
if (this.columnCollector) {
|
|
78
73
|
this.columnCollector.splice(this.columnCollector.indexOf(this), 1);
|
|
79
74
|
}
|
|
80
|
-
|
|
81
75
|
if (supportMousewheel) {
|
|
82
76
|
off(this.$el, 'wheel');
|
|
83
77
|
}
|
|
@@ -107,9 +101,7 @@ export default createComponent({
|
|
|
107
101
|
if (this.readonly) {
|
|
108
102
|
return;
|
|
109
103
|
}
|
|
110
|
-
|
|
111
104
|
this.touchStart(event);
|
|
112
|
-
|
|
113
105
|
if (this.moving) {
|
|
114
106
|
var translateY = getElementTranslateY(this.$refs.wrapper);
|
|
115
107
|
this.offset = Math.min(0, translateY - this.baseOffset);
|
|
@@ -117,7 +109,6 @@ export default createComponent({
|
|
|
117
109
|
} else {
|
|
118
110
|
this.startOffset = this.offset;
|
|
119
111
|
}
|
|
120
|
-
|
|
121
112
|
this.duration = 0;
|
|
122
113
|
this.transitionEndTrigger = null;
|
|
123
114
|
this.touchStartTime = Date.now();
|
|
@@ -127,17 +118,13 @@ export default createComponent({
|
|
|
127
118
|
if (this.readonly) {
|
|
128
119
|
return;
|
|
129
120
|
}
|
|
130
|
-
|
|
131
121
|
this.touchMove(event);
|
|
132
|
-
|
|
133
122
|
if (this.direction === 'vertical') {
|
|
134
123
|
this.moving = true;
|
|
135
124
|
preventDefault(event, true);
|
|
136
125
|
}
|
|
137
|
-
|
|
138
126
|
this.offset = range(this.startOffset + this.deltaY, -(this.count * this.itemHeight), this.itemHeight);
|
|
139
127
|
var now = Date.now();
|
|
140
|
-
|
|
141
128
|
if (now - this.touchStartTime > MOMENTUM_LIMIT_TIME) {
|
|
142
129
|
this.touchStartTime = now;
|
|
143
130
|
this.momentumOffset = this.offset;
|
|
@@ -145,63 +132,55 @@ export default createComponent({
|
|
|
145
132
|
},
|
|
146
133
|
onTouchEnd: function onTouchEnd() {
|
|
147
134
|
var _this = this;
|
|
148
|
-
|
|
149
135
|
if (this.readonly) {
|
|
150
136
|
return;
|
|
151
137
|
}
|
|
152
|
-
|
|
153
138
|
var distance = this.offset - this.momentumOffset;
|
|
154
139
|
var duration = Date.now() - this.touchStartTime;
|
|
155
140
|
var allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
|
|
156
|
-
|
|
157
141
|
if (allowMomentum) {
|
|
158
142
|
this.momentum(distance, duration);
|
|
159
143
|
return;
|
|
160
144
|
}
|
|
161
|
-
|
|
162
145
|
var index = this.getIndexByOffset(this.offset);
|
|
163
146
|
this.duration = DEFAULT_DURATION;
|
|
164
|
-
this.setIndex(index, true);
|
|
165
|
-
// use setTimeout to skip the click event Emitted after touchstart
|
|
147
|
+
this.setIndex(index, true);
|
|
166
148
|
|
|
149
|
+
// compatible with desktop scenario
|
|
150
|
+
// use setTimeout to skip the click event Emitted after touchstart
|
|
167
151
|
setTimeout(function () {
|
|
168
152
|
_this.moving = false;
|
|
169
153
|
}, 0);
|
|
170
154
|
},
|
|
171
155
|
onMouseWheel: function onMouseWheel(event) {
|
|
172
156
|
var _this2 = this;
|
|
173
|
-
|
|
174
157
|
if (this.readonly) {
|
|
175
158
|
return;
|
|
176
159
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
160
|
+
preventDefault(event, true);
|
|
161
|
+
// simply combine touchstart and touchmove
|
|
180
162
|
var translateY = getElementTranslateY(this.$refs.wrapper);
|
|
181
163
|
this.startOffset = Math.min(0, translateY - this.baseOffset);
|
|
182
164
|
this.momentumOffset = this.startOffset;
|
|
183
|
-
this.transitionEndTrigger = null;
|
|
165
|
+
this.transitionEndTrigger = null;
|
|
166
|
+
|
|
167
|
+
// directly use deltaY, see https://caniuse.com/?search=deltaY
|
|
184
168
|
// use deltaY to detect direction for not special setting device
|
|
185
169
|
// https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event
|
|
186
|
-
|
|
187
170
|
var deltaY = event.deltaY;
|
|
188
|
-
|
|
189
171
|
if (this.startOffset === 0 && deltaY < 0) {
|
|
190
172
|
return;
|
|
191
|
-
}
|
|
192
|
-
// if necessary, can adjust distance value to make scrolling smoother
|
|
193
|
-
|
|
173
|
+
}
|
|
194
174
|
|
|
175
|
+
// get offset
|
|
176
|
+
// if necessary, can adjust distance value to make scrolling smoother
|
|
195
177
|
var distance = -deltaY;
|
|
196
178
|
this.offset = range(this.startOffset + distance, -(this.count * this.itemHeight), this.itemHeight);
|
|
197
|
-
|
|
198
179
|
if (mousewheelTimer) {
|
|
199
180
|
clearTimeout(mousewheelTimer);
|
|
200
181
|
}
|
|
201
|
-
|
|
202
182
|
mousewheelTimer = setTimeout(function () {
|
|
203
183
|
_this2.onTouchEnd();
|
|
204
|
-
|
|
205
184
|
_this2.touchStartTime = 0;
|
|
206
185
|
}, MOMENTUM_LIMIT_TIME);
|
|
207
186
|
},
|
|
@@ -212,18 +191,15 @@ export default createComponent({
|
|
|
212
191
|
if (this.moving || this.readonly) {
|
|
213
192
|
return;
|
|
214
193
|
}
|
|
215
|
-
|
|
216
194
|
this.transitionEndTrigger = null;
|
|
217
195
|
this.duration = DEFAULT_DURATION;
|
|
218
196
|
this.setIndex(index, true);
|
|
219
197
|
},
|
|
220
198
|
adjustIndex: function adjustIndex(index) {
|
|
221
199
|
index = range(index, 0, this.count);
|
|
222
|
-
|
|
223
200
|
for (var i = index; i < this.count; i++) {
|
|
224
201
|
if (!isOptionDisabled(this.options[i])) return i;
|
|
225
202
|
}
|
|
226
|
-
|
|
227
203
|
for (var _i = index - 1; _i >= 0; _i--) {
|
|
228
204
|
if (!isOptionDisabled(this.options[_i])) return _i;
|
|
229
205
|
}
|
|
@@ -232,37 +208,31 @@ export default createComponent({
|
|
|
232
208
|
if (isObject(option) && this.valueKey in option) {
|
|
233
209
|
return option[this.valueKey];
|
|
234
210
|
}
|
|
235
|
-
|
|
236
211
|
return option;
|
|
237
212
|
},
|
|
238
213
|
setIndex: function setIndex(index, emitChange) {
|
|
239
214
|
var _this3 = this;
|
|
240
|
-
|
|
241
215
|
index = this.adjustIndex(index) || 0;
|
|
242
216
|
var offset = -index * this.itemHeight;
|
|
243
|
-
|
|
244
217
|
var trigger = function trigger() {
|
|
245
218
|
if (index !== _this3.currentIndex) {
|
|
246
219
|
_this3.currentIndex = index;
|
|
247
|
-
|
|
248
220
|
if (emitChange) {
|
|
249
221
|
_this3.$emit('change', index);
|
|
250
222
|
}
|
|
251
223
|
}
|
|
252
|
-
};
|
|
253
|
-
|
|
224
|
+
};
|
|
254
225
|
|
|
226
|
+
// trigger the change event after transitionend when moving
|
|
255
227
|
if (this.moving && offset !== this.offset) {
|
|
256
228
|
this.transitionEndTrigger = trigger;
|
|
257
229
|
} else {
|
|
258
230
|
trigger();
|
|
259
231
|
}
|
|
260
|
-
|
|
261
232
|
this.offset = offset;
|
|
262
233
|
},
|
|
263
234
|
setValue: function setValue(value) {
|
|
264
235
|
var options = this.options;
|
|
265
|
-
|
|
266
236
|
for (var i = 0; i < options.length; i++) {
|
|
267
237
|
if (this.getOptionText(options[i]) === value) {
|
|
268
238
|
return this.setIndex(i);
|
|
@@ -285,7 +255,6 @@ export default createComponent({
|
|
|
285
255
|
stopMomentum: function stopMomentum() {
|
|
286
256
|
this.moving = false;
|
|
287
257
|
this.duration = 0;
|
|
288
|
-
|
|
289
258
|
if (this.transitionEndTrigger) {
|
|
290
259
|
this.transitionEndTrigger();
|
|
291
260
|
this.transitionEndTrigger = null;
|
|
@@ -293,16 +262,13 @@ export default createComponent({
|
|
|
293
262
|
},
|
|
294
263
|
genOptions: function genOptions() {
|
|
295
264
|
var _this4 = this;
|
|
296
|
-
|
|
297
265
|
var h = this.$createElement;
|
|
298
266
|
var optionStyle = {
|
|
299
267
|
height: this.itemHeight + "px"
|
|
300
268
|
};
|
|
301
269
|
return this.options.map(function (option, index) {
|
|
302
270
|
var _domProps;
|
|
303
|
-
|
|
304
271
|
var text = _this4.getOptionText(option);
|
|
305
|
-
|
|
306
272
|
var disabled = isOptionDisabled(option);
|
|
307
273
|
var data = {
|
|
308
274
|
style: optionStyle,
|
package/es/picker/index.js
CHANGED
|
@@ -3,19 +3,18 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
import { createNamespace } from '../utils';
|
|
4
4
|
import { preventDefault } from '../utils/dom/event';
|
|
5
5
|
import { pickerProps, DEFAULT_ITEM_HEIGHT } from './shared';
|
|
6
|
-
import { unitToPx } from '../utils/format/unit';
|
|
6
|
+
import { unitToPx } from '../utils/format/unit';
|
|
7
7
|
|
|
8
|
+
// Components
|
|
8
9
|
import Loading from '../loading';
|
|
9
10
|
import PickerColumn from './PickerColumn';
|
|
10
11
|
import Popup from '../popup';
|
|
11
12
|
import Button from '../button';
|
|
12
13
|
import { PopupMixin } from '../mixins/popup';
|
|
13
|
-
|
|
14
14
|
var _createNamespace = createNamespace('picker'),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
createComponent = _createNamespace[0],
|
|
16
|
+
bem = _createNamespace[1],
|
|
17
|
+
t = _createNamespace[2];
|
|
19
18
|
export default createComponent({
|
|
20
19
|
mixins: [PopupMixin()],
|
|
21
20
|
props: _extends({}, pickerProps, {
|
|
@@ -64,15 +63,12 @@ export default createComponent({
|
|
|
64
63
|
dataType: function dataType() {
|
|
65
64
|
var columns = this.columns;
|
|
66
65
|
var firstColumn = columns[0] || {};
|
|
67
|
-
|
|
68
66
|
if (firstColumn.children && firstColumn.children.length) {
|
|
69
67
|
return 'cascade';
|
|
70
68
|
}
|
|
71
|
-
|
|
72
69
|
if (firstColumn.values) {
|
|
73
70
|
return 'object';
|
|
74
71
|
}
|
|
75
|
-
|
|
76
72
|
return 'text';
|
|
77
73
|
}
|
|
78
74
|
},
|
|
@@ -84,13 +80,11 @@ export default createComponent({
|
|
|
84
80
|
showPicker: {
|
|
85
81
|
handler: function handler(val) {
|
|
86
82
|
var _this = this;
|
|
87
|
-
|
|
88
83
|
if (val) {
|
|
89
84
|
this.$nextTick(function () {
|
|
90
85
|
_this.children.forEach(function (child) {
|
|
91
86
|
child.setConfirmIndex();
|
|
92
87
|
});
|
|
93
|
-
|
|
94
88
|
_this.children.forEach(function (child) {
|
|
95
89
|
child.recordConfirmIndex();
|
|
96
90
|
});
|
|
@@ -108,8 +102,7 @@ export default createComponent({
|
|
|
108
102
|
},
|
|
109
103
|
format: function format() {
|
|
110
104
|
var columns = this.columns,
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
dataType = this.dataType;
|
|
113
106
|
if (dataType === 'text') {
|
|
114
107
|
this.formattedColumns = [{
|
|
115
108
|
values: columns
|
|
@@ -125,14 +118,11 @@ export default createComponent({
|
|
|
125
118
|
var cursor = {
|
|
126
119
|
children: this.columns
|
|
127
120
|
};
|
|
128
|
-
|
|
129
121
|
while (cursor && cursor.children) {
|
|
130
122
|
var _cursor$defaultIndex;
|
|
131
|
-
|
|
132
123
|
var _cursor = cursor,
|
|
133
|
-
|
|
124
|
+
children = _cursor.children;
|
|
134
125
|
var defaultIndex = (_cursor$defaultIndex = cursor.defaultIndex) != null ? _cursor$defaultIndex : +this.defaultIndex;
|
|
135
|
-
|
|
136
126
|
while (children[defaultIndex] && children[defaultIndex].disabled) {
|
|
137
127
|
if (defaultIndex < children.length - 1) {
|
|
138
128
|
defaultIndex++;
|
|
@@ -141,7 +131,6 @@ export default createComponent({
|
|
|
141
131
|
break;
|
|
142
132
|
}
|
|
143
133
|
}
|
|
144
|
-
|
|
145
134
|
formatted.push({
|
|
146
135
|
values: cursor.children,
|
|
147
136
|
className: cursor.className,
|
|
@@ -149,25 +138,23 @@ export default createComponent({
|
|
|
149
138
|
});
|
|
150
139
|
cursor = children[defaultIndex];
|
|
151
140
|
}
|
|
152
|
-
|
|
153
141
|
this.formattedColumns = formatted;
|
|
154
142
|
},
|
|
155
143
|
emit: function emit(event) {
|
|
156
144
|
var _this2 = this;
|
|
157
|
-
|
|
158
145
|
if (this.dataType === 'text') {
|
|
159
146
|
this.$emit(event, this.getColumnValue(0), this.getColumnIndex(0));
|
|
160
147
|
} else {
|
|
161
|
-
var values = this.getValues();
|
|
148
|
+
var values = this.getValues();
|
|
149
|
+
|
|
150
|
+
// compatible with old version of wrong parameters
|
|
162
151
|
// should be removed in next major version
|
|
163
152
|
// see: https://github.com/vant-ui/vant/issues/5905
|
|
164
|
-
|
|
165
153
|
if (this.dataType === 'cascade') {
|
|
166
154
|
values = values.map(function (item) {
|
|
167
155
|
return item[_this2.valueKey];
|
|
168
156
|
});
|
|
169
157
|
}
|
|
170
|
-
|
|
171
158
|
this.$emit(event, values, this.getIndexes());
|
|
172
159
|
}
|
|
173
160
|
},
|
|
@@ -176,11 +163,9 @@ export default createComponent({
|
|
|
176
163
|
children: this.columns
|
|
177
164
|
};
|
|
178
165
|
var indexes = this.getIndexes();
|
|
179
|
-
|
|
180
166
|
for (var i = 0; i <= columnIndex; i++) {
|
|
181
167
|
cursor = cursor.children[indexes[i]];
|
|
182
168
|
}
|
|
183
|
-
|
|
184
169
|
while (cursor && cursor.children) {
|
|
185
170
|
columnIndex++;
|
|
186
171
|
this.setColumnValues(columnIndex, cursor.children);
|
|
@@ -189,24 +174,22 @@ export default createComponent({
|
|
|
189
174
|
},
|
|
190
175
|
onChange: function onChange(columnIndex) {
|
|
191
176
|
var _this3 = this;
|
|
192
|
-
|
|
193
177
|
if (this.dataType === 'cascade') {
|
|
194
178
|
this.onCascadeChange(columnIndex);
|
|
195
179
|
}
|
|
196
|
-
|
|
197
180
|
if (this.dataType === 'text') {
|
|
198
181
|
this.$emit('change', this, this.getColumnValue(0), this.getColumnIndex(0));
|
|
199
182
|
} else {
|
|
200
|
-
var values = this.getValues();
|
|
183
|
+
var values = this.getValues();
|
|
184
|
+
|
|
185
|
+
// compatible with old version of wrong parameters
|
|
201
186
|
// should be removed in next major version
|
|
202
187
|
// see: https://github.com/vant-ui/vant/issues/5905
|
|
203
|
-
|
|
204
188
|
if (this.dataType === 'cascade') {
|
|
205
189
|
values = values.map(function (item) {
|
|
206
190
|
return item[_this3.valueKey];
|
|
207
191
|
});
|
|
208
192
|
}
|
|
209
|
-
|
|
210
193
|
this.$emit('change', this, values, columnIndex);
|
|
211
194
|
}
|
|
212
195
|
},
|
|
@@ -227,10 +210,8 @@ export default createComponent({
|
|
|
227
210
|
// set column value by index
|
|
228
211
|
setColumnValue: function setColumnValue(index, value) {
|
|
229
212
|
var column = this.getColumn(index);
|
|
230
|
-
|
|
231
213
|
if (column) {
|
|
232
214
|
column.setValue(value);
|
|
233
|
-
|
|
234
215
|
if (this.dataType === 'cascade') {
|
|
235
216
|
this.onCascadeChange(index);
|
|
236
217
|
}
|
|
@@ -245,10 +226,8 @@ export default createComponent({
|
|
|
245
226
|
// set column option index by column index
|
|
246
227
|
setColumnIndex: function setColumnIndex(columnIndex, optionIndex) {
|
|
247
228
|
var column = this.getColumn(columnIndex);
|
|
248
|
-
|
|
249
229
|
if (column) {
|
|
250
230
|
column.setIndex(optionIndex);
|
|
251
|
-
|
|
252
231
|
if (this.dataType === 'cascade') {
|
|
253
232
|
this.onCascadeChange(columnIndex);
|
|
254
233
|
}
|
|
@@ -263,7 +242,6 @@ export default createComponent({
|
|
|
263
242
|
// set options of column by index
|
|
264
243
|
setColumnValues: function setColumnValues(index, options) {
|
|
265
244
|
var column = this.children[index];
|
|
266
|
-
|
|
267
245
|
if (column) {
|
|
268
246
|
column.setOptions(options);
|
|
269
247
|
}
|
|
@@ -279,7 +257,6 @@ export default createComponent({
|
|
|
279
257
|
// set values of all columns
|
|
280
258
|
setValues: function setValues(values) {
|
|
281
259
|
var _this4 = this;
|
|
282
|
-
|
|
283
260
|
values.forEach(function (value, index) {
|
|
284
261
|
_this4.setColumnValue(index, value);
|
|
285
262
|
});
|
|
@@ -295,7 +272,6 @@ export default createComponent({
|
|
|
295
272
|
// set indexes of all columns
|
|
296
273
|
setIndexes: function setIndexes(indexes) {
|
|
297
274
|
var _this5 = this;
|
|
298
|
-
|
|
299
275
|
indexes.forEach(function (optionIndex, columnIndex) {
|
|
300
276
|
_this5.setColumnIndex(columnIndex, optionIndex);
|
|
301
277
|
});
|
|
@@ -317,11 +293,9 @@ export default createComponent({
|
|
|
317
293
|
genTitle: function genTitle() {
|
|
318
294
|
var h = this.$createElement;
|
|
319
295
|
var titleSlot = this.slots('title');
|
|
320
|
-
|
|
321
296
|
if (titleSlot) {
|
|
322
297
|
return titleSlot;
|
|
323
298
|
}
|
|
324
|
-
|
|
325
299
|
if (this.title) {
|
|
326
300
|
return h("div", {
|
|
327
301
|
"class": ['zt2-ellipsis', bem('title')]
|
|
@@ -362,7 +336,6 @@ export default createComponent({
|
|
|
362
336
|
},
|
|
363
337
|
genToolbar: function genToolbar() {
|
|
364
338
|
var h = this.$createElement;
|
|
365
|
-
|
|
366
339
|
if (this.showToolbar) {
|
|
367
340
|
return h("div", {
|
|
368
341
|
"class": bem('toolbar')
|
|
@@ -412,11 +385,9 @@ export default createComponent({
|
|
|
412
385
|
},
|
|
413
386
|
genColumnItems: function genColumnItems() {
|
|
414
387
|
var _this6 = this;
|
|
415
|
-
|
|
416
388
|
var h = this.$createElement;
|
|
417
389
|
return this.formattedColumns.map(function (item, columnIndex) {
|
|
418
390
|
var _item$defaultIndex;
|
|
419
|
-
|
|
420
391
|
return h(PickerColumn, {
|
|
421
392
|
"attrs": {
|
|
422
393
|
"columnCollector": _this6.children,
|
package/es/popover/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { createPopper as _createPopper, offsetModifier } from '@vant/popperjs';
|
|
3
3
|
import { createNamespace } from '../utils';
|
|
4
|
-
import { BORDER_BOTTOM } from '../utils/constant';
|
|
4
|
+
import { BORDER_BOTTOM } from '../utils/constant';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Mixins
|
|
7
|
+
import { ClickOutsideMixin } from '../mixins/click-outside';
|
|
7
8
|
|
|
9
|
+
// Components
|
|
8
10
|
import Icon from '../icon';
|
|
9
11
|
import Popup from '../popup';
|
|
10
|
-
|
|
11
12
|
var _createNamespace = createNamespace('popover'),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
createComponent = _createNamespace[0],
|
|
14
|
+
bem = _createNamespace[1];
|
|
15
15
|
export default createComponent({
|
|
16
16
|
mixins: [ClickOutsideMixin({
|
|
17
17
|
event: 'touchstart',
|
|
@@ -82,12 +82,10 @@ export default createComponent({
|
|
|
82
82
|
},
|
|
83
83
|
updateLocation: function updateLocation() {
|
|
84
84
|
var _this = this;
|
|
85
|
-
|
|
86
85
|
this.$nextTick(function () {
|
|
87
86
|
if (!_this.value) {
|
|
88
87
|
return;
|
|
89
88
|
}
|
|
90
|
-
|
|
91
89
|
if (!_this.popper) {
|
|
92
90
|
_this.popper = _this.createPopper();
|
|
93
91
|
} else {
|
|
@@ -99,12 +97,11 @@ export default createComponent({
|
|
|
99
97
|
},
|
|
100
98
|
renderAction: function renderAction(action, index) {
|
|
101
99
|
var _this2 = this;
|
|
102
|
-
|
|
103
100
|
var h = this.$createElement;
|
|
104
101
|
var icon = action.icon,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
text = action.text,
|
|
103
|
+
disabled = action.disabled,
|
|
104
|
+
className = action.className;
|
|
108
105
|
return h("div", {
|
|
109
106
|
"attrs": {
|
|
110
107
|
"role": "menuitem"
|
|
@@ -143,9 +140,7 @@ export default createComponent({
|
|
|
143
140
|
if (action.disabled) {
|
|
144
141
|
return;
|
|
145
142
|
}
|
|
146
|
-
|
|
147
143
|
this.$emit('select', action, index);
|
|
148
|
-
|
|
149
144
|
if (this.closeOnClickAction) {
|
|
150
145
|
this.$emit('input', false);
|
|
151
146
|
}
|
|
@@ -156,17 +151,13 @@ export default createComponent({
|
|
|
156
151
|
onOpen: function onOpen() {
|
|
157
152
|
this.$emit('open');
|
|
158
153
|
},
|
|
159
|
-
|
|
160
|
-
/* istanbul ignore next */
|
|
161
|
-
onOpened: function onOpened() {
|
|
154
|
+
/* istanbul ignore next */onOpened: function onOpened() {
|
|
162
155
|
this.$emit('opened');
|
|
163
156
|
},
|
|
164
157
|
onClose: function onClose() {
|
|
165
158
|
this.$emit('close');
|
|
166
159
|
},
|
|
167
|
-
|
|
168
|
-
/* istanbul ignore next */
|
|
169
|
-
onClosed: function onClosed() {
|
|
160
|
+
/* istanbul ignore next */onClosed: function onClosed() {
|
|
170
161
|
this.$emit('closed');
|
|
171
162
|
}
|
|
172
163
|
},
|
package/es/popup/index.js
CHANGED
|
@@ -2,11 +2,9 @@ import { createNamespace, isDef } from '../utils';
|
|
|
2
2
|
import { PopupMixin } from '../mixins/popup';
|
|
3
3
|
import Icon from '../icon';
|
|
4
4
|
import { unitToPx } from "../utils/format/unit";
|
|
5
|
-
|
|
6
5
|
var _createNamespace = createNamespace('popup'),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
createComponent = _createNamespace[0],
|
|
7
|
+
bem = _createNamespace[1];
|
|
10
8
|
export default createComponent({
|
|
11
9
|
mixins: [PopupMixin()],
|
|
12
10
|
props: {
|
|
@@ -59,21 +57,17 @@ export default createComponent({
|
|
|
59
57
|
},
|
|
60
58
|
beforeCreate: function beforeCreate() {
|
|
61
59
|
var _this = this;
|
|
62
|
-
|
|
63
60
|
var createEmitter = function createEmitter(eventName) {
|
|
64
61
|
return function (event) {
|
|
65
62
|
return _this.$emit(eventName, event);
|
|
66
63
|
};
|
|
67
64
|
};
|
|
68
|
-
|
|
69
65
|
this.onClick = createEmitter('click');
|
|
70
66
|
this.onOpened = createEmitter('opened');
|
|
71
|
-
|
|
72
67
|
this.onClosed = function () {
|
|
73
68
|
if (_this.sliderShow) {
|
|
74
69
|
_this.contentStyle = "height:" + _this.sliderContentHeight + "px";
|
|
75
70
|
}
|
|
76
|
-
|
|
77
71
|
createEmitter('closed')();
|
|
78
72
|
};
|
|
79
73
|
},
|
|
@@ -99,11 +93,9 @@ export default createComponent({
|
|
|
99
93
|
},
|
|
100
94
|
move: function move(event) {
|
|
101
95
|
var _this2 = this;
|
|
102
|
-
|
|
103
96
|
if (this.timerId) {
|
|
104
97
|
event.preventDefault();
|
|
105
98
|
}
|
|
106
|
-
|
|
107
99
|
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
108
100
|
var touchAreaHeight = unitToPx(this.minDragHeight);
|
|
109
101
|
var positionY = event.touches[0].clientY;
|
|
@@ -111,7 +103,6 @@ export default createComponent({
|
|
|
111
103
|
if (positionY === 0 || positionY < h - unitToPx(_this2.maxDragHeight)) {
|
|
112
104
|
return;
|
|
113
105
|
}
|
|
114
|
-
|
|
115
106
|
_this2.touchHeight = positionY - touchAreaHeight > h - touchAreaHeight ? h - touchAreaHeight + _this2.touchPoint : positionY;
|
|
116
107
|
_this2.contentStyle = "height:" + (h - _this2.touchHeight - touchAreaHeight + _this2.touchPoint) + "px;";
|
|
117
108
|
}, 10);
|
|
@@ -124,22 +115,19 @@ export default createComponent({
|
|
|
124
115
|
if (this.timerId) {
|
|
125
116
|
clearInterval(this.timerId);
|
|
126
117
|
}
|
|
127
|
-
|
|
128
118
|
this.touchPoint = event.touches[0].clientY - this.$refs.popupRef.getBoundingClientRect().top;
|
|
129
119
|
},
|
|
130
120
|
allowSliderRender: function allowSliderRender() {
|
|
131
121
|
var h = this.$createElement;
|
|
132
122
|
var position = this.position,
|
|
133
|
-
|
|
123
|
+
duration = this.duration;
|
|
134
124
|
var isCenter = position === 'center';
|
|
135
125
|
var transitionName = this.transition || (isCenter ? 'zt2-fade' : "zt2-popup-slide-" + position);
|
|
136
126
|
var style = {};
|
|
137
|
-
|
|
138
127
|
if (isDef(duration)) {
|
|
139
128
|
var key = isCenter ? 'animationDuration' : 'transitionDuration';
|
|
140
129
|
style[key] = duration + "s";
|
|
141
130
|
}
|
|
142
|
-
|
|
143
131
|
return h("transition", {
|
|
144
132
|
"attrs": {
|
|
145
133
|
"appear": this.transitionAppear,
|
|
@@ -173,20 +161,17 @@ export default createComponent({
|
|
|
173
161
|
},
|
|
174
162
|
popupRender: function popupRender() {
|
|
175
163
|
var _bem;
|
|
176
|
-
|
|
177
164
|
var h = this.$createElement;
|
|
178
165
|
var round = this.round,
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
position = this.position,
|
|
167
|
+
duration = this.duration;
|
|
181
168
|
var isCenter = position === 'center';
|
|
182
169
|
var transitionName = this.transition || (isCenter ? 'zt2-fade' : "zt2-popup-slide-" + position);
|
|
183
170
|
var style = {};
|
|
184
|
-
|
|
185
171
|
if (isDef(duration)) {
|
|
186
172
|
var key = isCenter ? 'animationDuration' : 'transitionDuration';
|
|
187
173
|
style[key] = duration + "s";
|
|
188
174
|
}
|
|
189
|
-
|
|
190
175
|
return h("transition", {
|
|
191
176
|
"attrs": {
|
|
192
177
|
"appear": this.transitionAppear,
|
|
@@ -225,7 +210,6 @@ export default createComponent({
|
|
|
225
210
|
if (!this.shouldRender) {
|
|
226
211
|
return;
|
|
227
212
|
}
|
|
228
|
-
|
|
229
213
|
return this.sliderShow ? this.allowSliderRender() : this.popupRender();
|
|
230
214
|
}
|
|
231
215
|
});
|