vant 3.2.7 → 3.3.2
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/address-edit/AddressEdit.js +154 -180
- package/es/address-edit/AddressEditDetail.d.ts +10 -9
- package/es/address-edit/AddressEditDetail.js +6 -6
- package/es/button/Button.js +2 -2
- package/es/calendar/Calendar.js +8 -14
- package/es/calendar/CalendarHeader.js +1 -3
- package/es/calendar/CalendarMonth.js +11 -10
- package/es/calendar/types.d.ts +1 -1
- package/es/cascader/Cascader.js +17 -5
- package/es/checkbox/Checker.js +1 -1
- package/es/checkbox/types.d.ts +2 -6
- package/es/composables/use-id.d.ts +1 -0
- package/es/composables/use-id.js +14 -0
- package/es/composables/use-route.d.ts +1 -1
- package/es/composables/use-route.js +4 -4
- package/es/count-down/CountDown.js +1 -0
- package/es/coupon-list/CouponList.js +40 -24
- package/es/coupon-list/index.css +1 -1
- package/es/coupon-list/index.less +0 -5
- package/es/dropdown-item/DropdownItem.js +7 -2
- package/es/dropdown-item/types.d.ts +2 -6
- package/es/dropdown-menu/DropdownMenu.js +7 -3
- package/es/dropdown-menu/types.d.ts +1 -0
- package/es/empty/Network.js +22 -34
- package/es/field/Field.d.ts +1 -1
- package/es/field/Field.js +13 -5
- package/es/field/index.d.ts +2 -2
- package/es/field/types.d.ts +7 -6
- package/es/form/Form.js +2 -2
- package/es/image/Image.js +4 -9
- package/es/image-preview/ImagePreview.js +3 -4
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/lazyload/index.d.ts +1 -1
- package/es/lazyload/index.js +1 -1
- package/es/lazyload/vue-lazyload/index.d.ts +55 -0
- package/es/lazyload/vue-lazyload/index.js +46 -0
- package/es/lazyload/vue-lazyload/lazy-component.js +53 -0
- package/es/lazyload/vue-lazyload/lazy-container.js +98 -0
- package/es/lazyload/vue-lazyload/lazy-image.js +115 -0
- package/es/lazyload/vue-lazyload/lazy.js +507 -0
- package/es/lazyload/vue-lazyload/listener.js +241 -0
- package/es/lazyload/vue-lazyload/util.js +183 -0
- package/es/list/List.js +3 -1
- package/es/nav-bar/NavBar.d.ts +1 -1
- package/es/nav-bar/index.d.ts +1 -1
- package/es/number-keyboard/NumberKeyboardKey.js +4 -4
- package/es/pagination/Pagination.js +67 -49
- package/es/pagination/index.css +1 -1
- package/es/pagination/index.less +32 -31
- package/es/password-input/PasswordInput.d.ts +21 -1
- package/es/password-input/PasswordInput.js +10 -9
- package/es/password-input/index.d.ts +2 -1
- package/es/popover/Popover.js +2 -0
- package/es/popup/Popup.d.ts +1 -2
- package/es/popup/Popup.js +2 -5
- package/es/popup/index.d.ts +1 -2
- package/es/progress/Progress.js +2 -2
- package/es/rate/Rate.js +5 -3
- package/es/search/Search.js +8 -2
- package/es/sidebar/Sidebar.js +1 -0
- package/es/sidebar-item/SidebarItem.js +4 -1
- package/es/slider/Slider.js +5 -3
- package/es/stepper/Stepper.js +11 -8
- package/es/submit-bar/SubmitBar.d.ts +4 -3
- package/es/submit-bar/index.d.ts +3 -2
- package/es/swipe/Swipe.js +11 -6
- package/es/swipe/types.d.ts +1 -3
- package/es/switch/Switch.js +1 -0
- package/es/switch/index.css +1 -1
- package/es/switch/index.less +2 -0
- package/es/tab/Tab.js +18 -5
- package/es/tab/index.css +1 -1
- package/es/tab/index.less +1 -1
- package/es/tabbar/Tabbar.d.ts +1 -1
- package/es/tabbar/Tabbar.js +10 -10
- package/es/tabbar-item/TabbarItem.js +16 -7
- package/es/tabs/Tabs.js +17 -11
- package/es/tabs/TabsTitle.d.ts +6 -0
- package/es/tabs/TabsTitle.js +7 -1
- package/es/tabs/types.d.ts +1 -0
- package/es/uploader/UploaderPreviewItem.js +4 -1
- package/es/uploader/utils.d.ts +2 -2
- package/es/uploader/utils.js +2 -2
- package/es/utils/dom.d.ts +1 -0
- package/es/utils/dom.js +6 -2
- package/es/utils/format.js +6 -5
- package/es/vue-tsx-shim.d.ts +1 -0
- package/lib/address-edit/AddressEdit.js +155 -180
- package/lib/address-edit/AddressEditDetail.d.ts +10 -9
- package/lib/address-edit/AddressEditDetail.js +6 -6
- package/lib/button/Button.js +1 -1
- package/lib/calendar/Calendar.js +8 -14
- package/lib/calendar/CalendarHeader.js +1 -3
- package/lib/calendar/CalendarMonth.js +11 -10
- package/lib/calendar/types.d.ts +1 -1
- package/lib/cascader/Cascader.js +17 -5
- package/lib/checkbox/Checker.js +1 -1
- package/lib/checkbox/types.d.ts +2 -6
- package/lib/composables/use-id.d.ts +1 -0
- package/lib/composables/use-id.js +21 -0
- package/lib/composables/use-route.d.ts +1 -1
- package/lib/composables/use-route.js +4 -4
- package/lib/count-down/CountDown.js +1 -0
- package/lib/coupon-list/CouponList.js +39 -22
- package/lib/coupon-list/index.css +1 -1
- package/lib/coupon-list/index.less +0 -5
- package/lib/dropdown-item/DropdownItem.js +7 -2
- package/lib/dropdown-item/types.d.ts +2 -6
- package/lib/dropdown-menu/DropdownMenu.js +7 -2
- package/lib/dropdown-menu/types.d.ts +1 -0
- package/lib/empty/Network.js +22 -34
- package/lib/field/Field.d.ts +1 -1
- package/lib/field/Field.js +14 -5
- package/lib/field/index.d.ts +2 -2
- package/lib/field/types.d.ts +7 -6
- package/lib/form/Form.js +1 -1
- package/lib/image/Image.js +4 -9
- package/lib/image-preview/ImagePreview.js +1 -2
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/lazyload/index.d.ts +1 -1
- package/lib/lazyload/index.js +3 -3
- package/lib/lazyload/vue-lazyload/index.d.ts +55 -0
- package/lib/lazyload/vue-lazyload/index.js +58 -0
- package/lib/lazyload/vue-lazyload/lazy-component.js +62 -0
- package/lib/lazyload/vue-lazyload/lazy-container.js +106 -0
- package/lib/lazyload/vue-lazyload/lazy-image.js +125 -0
- package/lib/lazyload/vue-lazyload/lazy.js +520 -0
- package/lib/lazyload/vue-lazyload/listener.js +251 -0
- package/lib/lazyload/vue-lazyload/util.js +213 -0
- package/lib/list/List.js +3 -1
- package/lib/nav-bar/NavBar.d.ts +1 -1
- package/lib/nav-bar/index.d.ts +1 -1
- package/lib/number-keyboard/NumberKeyboardKey.js +3 -3
- package/lib/pagination/Pagination.js +65 -47
- package/lib/pagination/index.css +1 -1
- package/lib/pagination/index.less +32 -31
- package/lib/password-input/PasswordInput.d.ts +21 -1
- package/lib/password-input/PasswordInput.js +10 -9
- package/lib/password-input/index.d.ts +2 -1
- package/lib/popover/Popover.js +2 -0
- package/lib/popup/Popup.d.ts +1 -2
- package/lib/popup/Popup.js +2 -5
- package/lib/popup/index.d.ts +1 -2
- package/lib/progress/Progress.js +2 -2
- package/lib/rate/Rate.js +5 -3
- package/lib/search/Search.js +9 -2
- package/lib/sidebar/Sidebar.js +1 -0
- package/lib/sidebar-item/SidebarItem.js +4 -1
- package/lib/slider/Slider.js +5 -3
- package/lib/stepper/Stepper.js +11 -8
- package/lib/submit-bar/SubmitBar.d.ts +4 -3
- package/lib/submit-bar/index.d.ts +3 -2
- package/lib/swipe/Swipe.js +9 -4
- package/lib/swipe/types.d.ts +1 -3
- package/lib/switch/Switch.js +1 -0
- package/lib/switch/index.css +1 -1
- package/lib/switch/index.less +2 -0
- package/lib/tab/Tab.js +20 -5
- package/lib/tab/index.css +1 -1
- package/lib/tab/index.less +1 -1
- package/lib/tabbar/Tabbar.d.ts +1 -1
- package/lib/tabbar/Tabbar.js +10 -10
- package/lib/tabbar-item/TabbarItem.js +16 -7
- package/lib/tabs/Tabs.js +16 -9
- package/lib/tabs/TabsTitle.d.ts +6 -0
- package/lib/tabs/TabsTitle.js +7 -1
- package/lib/tabs/types.d.ts +1 -0
- package/lib/uploader/UploaderPreviewItem.js +3 -0
- package/lib/uploader/utils.d.ts +2 -2
- package/lib/uploader/utils.js +3 -2
- package/lib/utils/dom.d.ts +1 -0
- package/lib/utils/dom.js +9 -2
- package/lib/utils/format.js +7 -5
- package/lib/vant.cjs.js +14407 -0
- package/lib/vant.cjs.min.js +1 -0
- package/lib/vant.es.js +1217 -2203
- package/lib/vant.es.min.js +1217 -2203
- package/lib/vant.js +1349 -1254
- package/lib/vant.min.js +1 -1
- package/lib/vue-tsx-shim.d.ts +1 -0
- package/package.json +27 -13
- package/vetur/attributes.json +115 -115
- package/vetur/tags.json +35 -35
- package/vetur/web-types.json +370 -366
- package/es/composables/use-link-field.d.ts +0 -0
- package/es/composables/use-link-field.js +0 -0
- package/lib/composables/use-link-field.d.ts +0 -0
- package/lib/composables/use-link-field.js +0 -1
@@ -0,0 +1,241 @@
|
|
1
|
+
import { useRect } from '@vant/use';
|
2
|
+
import { loadImageAsync } from './util';
|
3
|
+
import { noop } from '../../utils';
|
4
|
+
export default class ReactiveListener {
|
5
|
+
constructor(_ref) {
|
6
|
+
var {
|
7
|
+
el,
|
8
|
+
src,
|
9
|
+
error,
|
10
|
+
loading,
|
11
|
+
bindType,
|
12
|
+
$parent,
|
13
|
+
options,
|
14
|
+
cors,
|
15
|
+
elRenderer,
|
16
|
+
imageCache
|
17
|
+
} = _ref;
|
18
|
+
this.el = el;
|
19
|
+
this.src = src;
|
20
|
+
this.error = error;
|
21
|
+
this.loading = loading;
|
22
|
+
this.bindType = bindType;
|
23
|
+
this.attempt = 0;
|
24
|
+
this.cors = cors;
|
25
|
+
this.naturalHeight = 0;
|
26
|
+
this.naturalWidth = 0;
|
27
|
+
this.options = options;
|
28
|
+
this.$parent = $parent;
|
29
|
+
this.elRenderer = elRenderer;
|
30
|
+
this.imageCache = imageCache;
|
31
|
+
this.performanceData = {
|
32
|
+
loadStart: 0,
|
33
|
+
loadEnd: 0
|
34
|
+
};
|
35
|
+
this.filter();
|
36
|
+
this.initState();
|
37
|
+
this.render('loading', false);
|
38
|
+
}
|
39
|
+
/*
|
40
|
+
* init listener state
|
41
|
+
* @return
|
42
|
+
*/
|
43
|
+
|
44
|
+
|
45
|
+
initState() {
|
46
|
+
if ('dataset' in this.el) {
|
47
|
+
this.el.dataset.src = this.src;
|
48
|
+
} else {
|
49
|
+
this.el.setAttribute('data-src', this.src);
|
50
|
+
}
|
51
|
+
|
52
|
+
this.state = {
|
53
|
+
loading: false,
|
54
|
+
error: false,
|
55
|
+
loaded: false,
|
56
|
+
rendered: false
|
57
|
+
};
|
58
|
+
}
|
59
|
+
/*
|
60
|
+
* record performance
|
61
|
+
* @return
|
62
|
+
*/
|
63
|
+
|
64
|
+
|
65
|
+
record(event) {
|
66
|
+
this.performanceData[event] = Date.now();
|
67
|
+
}
|
68
|
+
/*
|
69
|
+
* update image listener data
|
70
|
+
* @param {String} image uri
|
71
|
+
* @param {String} loading image uri
|
72
|
+
* @param {String} error image uri
|
73
|
+
* @return
|
74
|
+
*/
|
75
|
+
|
76
|
+
|
77
|
+
update(_ref2) {
|
78
|
+
var {
|
79
|
+
src,
|
80
|
+
loading,
|
81
|
+
error
|
82
|
+
} = _ref2;
|
83
|
+
var oldSrc = this.src;
|
84
|
+
this.src = src;
|
85
|
+
this.loading = loading;
|
86
|
+
this.error = error;
|
87
|
+
this.filter();
|
88
|
+
|
89
|
+
if (oldSrc !== this.src) {
|
90
|
+
this.attempt = 0;
|
91
|
+
this.initState();
|
92
|
+
}
|
93
|
+
}
|
94
|
+
/*
|
95
|
+
* check el is in view
|
96
|
+
* @return {Boolean} el is in view
|
97
|
+
*/
|
98
|
+
|
99
|
+
|
100
|
+
checkInView() {
|
101
|
+
var rect = useRect(this.el);
|
102
|
+
return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
|
103
|
+
}
|
104
|
+
/*
|
105
|
+
* listener filter
|
106
|
+
*/
|
107
|
+
|
108
|
+
|
109
|
+
filter() {
|
110
|
+
Object.keys(this.options.filter).forEach(key => {
|
111
|
+
this.options.filter[key](this, this.options);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
/*
|
115
|
+
* render loading first
|
116
|
+
* @params cb:Function
|
117
|
+
* @return
|
118
|
+
*/
|
119
|
+
|
120
|
+
|
121
|
+
renderLoading(cb) {
|
122
|
+
this.state.loading = true;
|
123
|
+
loadImageAsync({
|
124
|
+
src: this.loading,
|
125
|
+
cors: this.cors
|
126
|
+
}, () => {
|
127
|
+
this.render('loading', false);
|
128
|
+
this.state.loading = false;
|
129
|
+
cb();
|
130
|
+
}, () => {
|
131
|
+
// handler `loading image` load failed
|
132
|
+
cb();
|
133
|
+
this.state.loading = false;
|
134
|
+
if (process.env.NODE_ENV !== 'production' && !this.options.silent) console.warn("[@vant/lazyload] load failed with loading image(" + this.loading + ")");
|
135
|
+
});
|
136
|
+
}
|
137
|
+
/*
|
138
|
+
* try load image and render it
|
139
|
+
* @return
|
140
|
+
*/
|
141
|
+
|
142
|
+
|
143
|
+
load(onFinish) {
|
144
|
+
if (onFinish === void 0) {
|
145
|
+
onFinish = noop;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (this.attempt > this.options.attempt - 1 && this.state.error) {
|
149
|
+
if (process.env.NODE_ENV !== 'production' && !this.options.silent) {
|
150
|
+
console.log("[@vant/lazyload] " + this.src + " tried too more than " + this.options.attempt + " times");
|
151
|
+
}
|
152
|
+
|
153
|
+
onFinish();
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
|
157
|
+
if (this.state.rendered && this.state.loaded) return;
|
158
|
+
|
159
|
+
if (this.imageCache.has(this.src)) {
|
160
|
+
this.state.loaded = true;
|
161
|
+
this.render('loaded', true);
|
162
|
+
this.state.rendered = true;
|
163
|
+
return onFinish();
|
164
|
+
}
|
165
|
+
|
166
|
+
this.renderLoading(() => {
|
167
|
+
var _this$options$adapter, _this$options$adapter2;
|
168
|
+
|
169
|
+
this.attempt++;
|
170
|
+
(_this$options$adapter = (_this$options$adapter2 = this.options.adapter).beforeLoad) == null ? void 0 : _this$options$adapter.call(_this$options$adapter2, this, this.options);
|
171
|
+
this.record('loadStart');
|
172
|
+
loadImageAsync({
|
173
|
+
src: this.src,
|
174
|
+
cors: this.cors
|
175
|
+
}, data => {
|
176
|
+
this.naturalHeight = data.naturalHeight;
|
177
|
+
this.naturalWidth = data.naturalWidth;
|
178
|
+
this.state.loaded = true;
|
179
|
+
this.state.error = false;
|
180
|
+
this.record('loadEnd');
|
181
|
+
this.render('loaded', false);
|
182
|
+
this.state.rendered = true;
|
183
|
+
this.imageCache.add(this.src);
|
184
|
+
onFinish();
|
185
|
+
}, err => {
|
186
|
+
!this.options.silent && console.error(err);
|
187
|
+
this.state.error = true;
|
188
|
+
this.state.loaded = false;
|
189
|
+
this.render('error', false);
|
190
|
+
});
|
191
|
+
});
|
192
|
+
}
|
193
|
+
/*
|
194
|
+
* render image
|
195
|
+
* @param {String} state to render // ['loading', 'src', 'error']
|
196
|
+
* @param {String} is form cache
|
197
|
+
* @return
|
198
|
+
*/
|
199
|
+
|
200
|
+
|
201
|
+
render(state, cache) {
|
202
|
+
this.elRenderer(this, state, cache);
|
203
|
+
}
|
204
|
+
/*
|
205
|
+
* output performance data
|
206
|
+
* @return {Object} performance data
|
207
|
+
*/
|
208
|
+
|
209
|
+
|
210
|
+
performance() {
|
211
|
+
var state = 'loading';
|
212
|
+
var time = 0;
|
213
|
+
|
214
|
+
if (this.state.loaded) {
|
215
|
+
state = 'loaded';
|
216
|
+
time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1000;
|
217
|
+
}
|
218
|
+
|
219
|
+
if (this.state.error) state = 'error';
|
220
|
+
return {
|
221
|
+
src: this.src,
|
222
|
+
state,
|
223
|
+
time
|
224
|
+
};
|
225
|
+
}
|
226
|
+
/*
|
227
|
+
* $destroy
|
228
|
+
* @return
|
229
|
+
*/
|
230
|
+
|
231
|
+
|
232
|
+
$destroy() {
|
233
|
+
this.el = null;
|
234
|
+
this.src = null;
|
235
|
+
this.error = null;
|
236
|
+
this.loading = null;
|
237
|
+
this.bindType = null;
|
238
|
+
this.attempt = 0;
|
239
|
+
}
|
240
|
+
|
241
|
+
}
|
@@ -0,0 +1,183 @@
|
|
1
|
+
import { inBrowser } from '@vant/use';
|
2
|
+
export var hasIntersectionObserver = inBrowser && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
|
3
|
+
export var modeType = {
|
4
|
+
event: 'event',
|
5
|
+
observer: 'observer'
|
6
|
+
};
|
7
|
+
export function remove(arr, item) {
|
8
|
+
if (!arr.length) return;
|
9
|
+
var index = arr.indexOf(item);
|
10
|
+
if (index > -1) return arr.splice(index, 1);
|
11
|
+
}
|
12
|
+
export function getBestSelectionFromSrcset(el, scale) {
|
13
|
+
if (el.tagName !== 'IMG' || !el.getAttribute('data-srcset')) return;
|
14
|
+
var options = el.getAttribute('data-srcset');
|
15
|
+
var container = el.parentNode;
|
16
|
+
var containerWidth = container.offsetWidth * scale;
|
17
|
+
var spaceIndex;
|
18
|
+
var tmpSrc;
|
19
|
+
var tmpWidth;
|
20
|
+
options = options.trim().split(',');
|
21
|
+
var result = options.map(item => {
|
22
|
+
item = item.trim();
|
23
|
+
spaceIndex = item.lastIndexOf(' ');
|
24
|
+
|
25
|
+
if (spaceIndex === -1) {
|
26
|
+
tmpSrc = item;
|
27
|
+
tmpWidth = 999998;
|
28
|
+
} else {
|
29
|
+
tmpSrc = item.substr(0, spaceIndex);
|
30
|
+
tmpWidth = parseInt(item.substr(spaceIndex + 1, item.length - spaceIndex - 2), 10);
|
31
|
+
}
|
32
|
+
|
33
|
+
return [tmpWidth, tmpSrc];
|
34
|
+
});
|
35
|
+
result.sort((a, b) => {
|
36
|
+
if (a[0] < b[0]) {
|
37
|
+
return 1;
|
38
|
+
}
|
39
|
+
|
40
|
+
if (a[0] > b[0]) {
|
41
|
+
return -1;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (a[0] === b[0]) {
|
45
|
+
if (b[1].indexOf('.webp', b[1].length - 5) !== -1) {
|
46
|
+
return 1;
|
47
|
+
}
|
48
|
+
|
49
|
+
if (a[1].indexOf('.webp', a[1].length - 5) !== -1) {
|
50
|
+
return -1;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
return 0;
|
55
|
+
});
|
56
|
+
var bestSelectedSrc = '';
|
57
|
+
var tmpOption;
|
58
|
+
|
59
|
+
for (var i = 0; i < result.length; i++) {
|
60
|
+
tmpOption = result[i];
|
61
|
+
bestSelectedSrc = tmpOption[1];
|
62
|
+
var next = result[i + 1];
|
63
|
+
|
64
|
+
if (next && next[0] < containerWidth) {
|
65
|
+
bestSelectedSrc = tmpOption[1];
|
66
|
+
break;
|
67
|
+
} else if (!next) {
|
68
|
+
bestSelectedSrc = tmpOption[1];
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
return bestSelectedSrc;
|
74
|
+
}
|
75
|
+
export var getDPR = function (scale) {
|
76
|
+
if (scale === void 0) {
|
77
|
+
scale = 1;
|
78
|
+
}
|
79
|
+
|
80
|
+
return inBrowser ? window.devicePixelRatio || scale : scale;
|
81
|
+
};
|
82
|
+
export function supportWebp() {
|
83
|
+
if (!inBrowser) return false;
|
84
|
+
var support = true;
|
85
|
+
|
86
|
+
try {
|
87
|
+
var elem = document.createElement('canvas');
|
88
|
+
|
89
|
+
if (elem.getContext && elem.getContext('2d')) {
|
90
|
+
support = elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
91
|
+
}
|
92
|
+
} catch (err) {
|
93
|
+
support = false;
|
94
|
+
}
|
95
|
+
|
96
|
+
return support;
|
97
|
+
}
|
98
|
+
export function throttle(action, delay) {
|
99
|
+
var timeout = null;
|
100
|
+
var lastRun = 0;
|
101
|
+
return function () {
|
102
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
103
|
+
args[_key] = arguments[_key];
|
104
|
+
}
|
105
|
+
|
106
|
+
if (timeout) {
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
|
110
|
+
var elapsed = Date.now() - lastRun;
|
111
|
+
|
112
|
+
var runCallback = () => {
|
113
|
+
lastRun = Date.now();
|
114
|
+
timeout = false;
|
115
|
+
action.apply(this, args);
|
116
|
+
};
|
117
|
+
|
118
|
+
if (elapsed >= delay) {
|
119
|
+
runCallback();
|
120
|
+
} else {
|
121
|
+
timeout = setTimeout(runCallback, delay);
|
122
|
+
}
|
123
|
+
};
|
124
|
+
}
|
125
|
+
export function on(el, type, func) {
|
126
|
+
el.addEventListener(type, func, {
|
127
|
+
capture: false,
|
128
|
+
passive: true
|
129
|
+
});
|
130
|
+
}
|
131
|
+
export function off(el, type, func) {
|
132
|
+
el.removeEventListener(type, func, false);
|
133
|
+
}
|
134
|
+
export var loadImageAsync = (item, resolve, reject) => {
|
135
|
+
var image = new Image();
|
136
|
+
|
137
|
+
if (!item || !item.src) {
|
138
|
+
return reject(new Error('image src is required'));
|
139
|
+
}
|
140
|
+
|
141
|
+
image.src = item.src;
|
142
|
+
|
143
|
+
if (item.cors) {
|
144
|
+
image.crossOrigin = item.cors;
|
145
|
+
}
|
146
|
+
|
147
|
+
image.onload = () => resolve({
|
148
|
+
naturalHeight: image.naturalHeight,
|
149
|
+
naturalWidth: image.naturalWidth,
|
150
|
+
src: image.src
|
151
|
+
});
|
152
|
+
|
153
|
+
image.onerror = e => reject(e);
|
154
|
+
};
|
155
|
+
export class ImageCache {
|
156
|
+
constructor(_ref) {
|
157
|
+
var {
|
158
|
+
max
|
159
|
+
} = _ref;
|
160
|
+
this.options = {
|
161
|
+
max: max || 100
|
162
|
+
};
|
163
|
+
this.caches = [];
|
164
|
+
}
|
165
|
+
|
166
|
+
has(key) {
|
167
|
+
return this.caches.indexOf(key) > -1;
|
168
|
+
}
|
169
|
+
|
170
|
+
add(key) {
|
171
|
+
if (this.has(key)) return;
|
172
|
+
this.caches.push(key);
|
173
|
+
|
174
|
+
if (this.caches.length > this.options.max) {
|
175
|
+
this.free();
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
free() {
|
180
|
+
this.caches.shift();
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
package/es/list/List.js
CHANGED
@@ -95,7 +95,9 @@ export default defineComponent({
|
|
95
95
|
|
96
96
|
if (text) {
|
97
97
|
return _createVNode("div", {
|
98
|
+
"role": "button",
|
98
99
|
"class": bem('error-text'),
|
100
|
+
"tabindex": 0,
|
99
101
|
"onClick": clickErrorText
|
100
102
|
}, [text]);
|
101
103
|
}
|
@@ -114,7 +116,7 @@ export default defineComponent({
|
|
114
116
|
}
|
115
117
|
};
|
116
118
|
|
117
|
-
watch(
|
119
|
+
watch(() => [props.loading, props.finished, props.error], check);
|
118
120
|
|
119
121
|
if (tabStatus) {
|
120
122
|
watch(tabStatus, tabActive => {
|
package/es/nav-bar/NavBar.d.ts
CHANGED
@@ -13,7 +13,7 @@ declare const navBarProps: {
|
|
13
13
|
placeholder: BooleanConstructor;
|
14
14
|
safeAreaInsetTop: BooleanConstructor;
|
15
15
|
};
|
16
|
-
export declare type
|
16
|
+
export declare type NavBarProps = ExtractPropTypes<typeof navBarProps>;
|
17
17
|
declare const _default: import("vue").DefineComponent<{
|
18
18
|
title: StringConstructor;
|
19
19
|
fixed: BooleanConstructor;
|
package/es/nav-bar/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
2
|
import { ref, defineComponent } from 'vue';
|
3
|
-
import { numericProp, createNamespace } from '../utils';
|
3
|
+
import { numericProp, createNamespace, preventDefault } from '../utils';
|
4
4
|
import { useTouch } from '../composables/use-touch';
|
5
5
|
import { Loading } from '../loading';
|
6
6
|
var [name, bem] = createNamespace('key');
|
@@ -9,7 +9,7 @@ var CollapseIcon = _createVNode("svg", {
|
|
9
9
|
"class": bem('collapse-icon'),
|
10
10
|
"viewBox": "0 0 30 24"
|
11
11
|
}, [_createVNode("path", {
|
12
|
-
"d": "
|
12
|
+
"d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
|
13
13
|
"fill": "currentColor"
|
14
14
|
}, null)]);
|
15
15
|
|
@@ -17,7 +17,7 @@ var DeleteIcon = _createVNode("svg", {
|
|
17
17
|
"class": bem('delete-icon'),
|
18
18
|
"viewBox": "0 0 32 22"
|
19
19
|
}, [_createVNode("path", {
|
20
|
-
"d": "M28
|
20
|
+
"d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
|
21
21
|
"fill": "currentColor"
|
22
22
|
}, null)]);
|
23
23
|
|
@@ -59,7 +59,7 @@ export default defineComponent({
|
|
59
59
|
// eliminate tap delay on safari
|
60
60
|
// see: https://github.com/youzan/vant/issues/6836
|
61
61
|
if (!slots.default) {
|
62
|
-
|
62
|
+
preventDefault(event);
|
63
63
|
}
|
64
64
|
|
65
65
|
active.value = false;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
|
-
import { computed,
|
3
|
-
import {
|
2
|
+
import { computed, watchEffect, defineComponent } from 'vue';
|
3
|
+
import { clamp, makeStringProp, makeNumberProp, makeNumericProp, createNamespace, BORDER_SURROUND } from '../utils';
|
4
4
|
var [name, bem, t] = createNamespace('pagination');
|
5
5
|
|
6
6
|
var makePage = (number, text, active) => ({
|
@@ -46,12 +46,7 @@ export default defineComponent({
|
|
46
46
|
var {
|
47
47
|
modelValue,
|
48
48
|
forceEllipses
|
49
|
-
} = props;
|
50
|
-
|
51
|
-
if (props.mode !== 'multi') {
|
52
|
-
return items;
|
53
|
-
} // Default page limits
|
54
|
-
|
49
|
+
} = props; // Default page limits
|
55
50
|
|
56
51
|
var startPage = 1;
|
57
52
|
var endPage = pageCount;
|
@@ -90,59 +85,82 @@ export default defineComponent({
|
|
90
85
|
return items;
|
91
86
|
});
|
92
87
|
|
93
|
-
var
|
94
|
-
|
88
|
+
var updateModelValue = (value, emitChange) => {
|
89
|
+
value = clamp(value, 1, count.value);
|
95
90
|
|
96
|
-
if (props.modelValue !==
|
97
|
-
emit('update:modelValue',
|
91
|
+
if (props.modelValue !== value) {
|
92
|
+
emit('update:modelValue', value);
|
98
93
|
|
99
94
|
if (emitChange) {
|
100
|
-
emit('change',
|
95
|
+
emit('change', value);
|
101
96
|
}
|
102
97
|
}
|
103
|
-
};
|
98
|
+
}; // format modelValue
|
104
99
|
|
105
|
-
watch(() => props.modelValue, value => {
|
106
|
-
select(value);
|
107
|
-
}, {
|
108
|
-
immediate: true
|
109
|
-
});
|
110
|
-
|
111
|
-
var renderDesc = () => {
|
112
|
-
if (props.mode !== 'multi') {
|
113
|
-
return _createVNode("li", {
|
114
|
-
"class": bem('page-desc')
|
115
|
-
}, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
|
116
|
-
}
|
117
|
-
};
|
118
100
|
|
119
|
-
|
120
|
-
var value = props.modelValue;
|
121
|
-
var simple = props.mode !== 'multi';
|
101
|
+
watchEffect(() => updateModelValue(props.modelValue));
|
122
102
|
|
123
|
-
|
103
|
+
var renderDesc = () => _createVNode("li", {
|
104
|
+
"class": bem('page-desc')
|
105
|
+
}, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
|
124
106
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
"onClick": onSelect(value - 1)
|
134
|
-
}, [slots['prev-text'] ? slots['prev-text']() : props.prevText || t('prev')]), pages.value.map(page => _createVNode("li", {
|
107
|
+
var renderPrevButton = () => {
|
108
|
+
var {
|
109
|
+
mode,
|
110
|
+
modelValue
|
111
|
+
} = props;
|
112
|
+
var slot = slots['prev-text'];
|
113
|
+
var disabled = modelValue === 1;
|
114
|
+
return _createVNode("li", {
|
135
115
|
"class": [bem('item', {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
116
|
+
disabled,
|
117
|
+
border: mode === 'simple',
|
118
|
+
prev: true
|
119
|
+
}), BORDER_SURROUND]
|
120
|
+
}, [_createVNode("button", {
|
121
|
+
"type": "button",
|
122
|
+
"disabled": disabled,
|
123
|
+
"onClick": () => updateModelValue(modelValue - 1)
|
124
|
+
}, [slot ? slot() : props.prevText || t('prev')])]);
|
125
|
+
};
|
126
|
+
|
127
|
+
var renderNextButton = () => {
|
128
|
+
var {
|
129
|
+
mode,
|
130
|
+
modelValue
|
131
|
+
} = props;
|
132
|
+
var slot = slots['next-text'];
|
133
|
+
var disabled = modelValue === count.value;
|
134
|
+
return _createVNode("li", {
|
140
135
|
"class": [bem('item', {
|
141
|
-
disabled
|
142
|
-
|
143
|
-
|
144
|
-
|
136
|
+
disabled,
|
137
|
+
border: mode === 'simple',
|
138
|
+
next: true
|
139
|
+
}), BORDER_SURROUND]
|
140
|
+
}, [_createVNode("button", {
|
141
|
+
"type": "button",
|
142
|
+
"disabled": disabled,
|
143
|
+
"onClick": () => updateModelValue(modelValue + 1)
|
144
|
+
}, [slot ? slot() : props.nextText || t('next')])]);
|
145
145
|
};
|
146
|
+
|
147
|
+
var renderPages = () => pages.value.map(page => _createVNode("li", {
|
148
|
+
"class": [bem('item', {
|
149
|
+
active: page.active,
|
150
|
+
page: true
|
151
|
+
}), BORDER_SURROUND]
|
152
|
+
}, [_createVNode("button", {
|
153
|
+
"type": "button",
|
154
|
+
"aria-current": page.active || undefined,
|
155
|
+
"onClick": () => updateModelValue(page.number)
|
156
|
+
}, [slots.page ? slots.page(page) : page.text])]));
|
157
|
+
|
158
|
+
return () => _createVNode("nav", {
|
159
|
+
"role": "navigation",
|
160
|
+
"class": bem()
|
161
|
+
}, [_createVNode("ul", {
|
162
|
+
"class": bem('items')
|
163
|
+
}, [renderPrevButton(), props.mode === 'simple' ? renderDesc() : renderPages(), renderNextButton()])]);
|
146
164
|
}
|
147
165
|
|
148
166
|
});
|
package/es/pagination/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
:root{--van-pagination-height:40px;--van-pagination-font-size:var(--van-font-size-md);--van-pagination-item-width:36px;--van-pagination-item-default-color:var(--van-primary-color);--van-pagination-item-disabled-color:var(--van-gray-7);--van-pagination-item-disabled-background-color:var(--van-background-color);--van-pagination-background-color:var(--van-background-color-light);--van-pagination-desc-color:var(--van-gray-7);--van-pagination-disabled-opacity:var(--van-disabled-opacity)}.van-pagination{
|
1
|
+
:root{--van-pagination-height:40px;--van-pagination-font-size:var(--van-font-size-md);--van-pagination-item-width:36px;--van-pagination-item-default-color:var(--van-primary-color);--van-pagination-item-disabled-color:var(--van-gray-7);--van-pagination-item-disabled-background-color:var(--van-background-color);--van-pagination-background-color:var(--van-background-color-light);--van-pagination-desc-color:var(--van-gray-7);--van-pagination-disabled-opacity:var(--van-disabled-opacity)}.van-pagination{font-size:var(--van-pagination-font-size)}.van-pagination__items{display:flex}.van-pagination__item,.van-pagination__page-desc{display:flex;align-items:center;justify-content:center}.van-pagination__item{flex:1;box-sizing:border-box;min-width:var(--van-pagination-item-width);height:var(--van-pagination-height);color:var(--van-pagination-item-default-color);background:var(--van-pagination-background-color);cursor:pointer;-webkit-user-select:none;user-select:none}.van-pagination__item button{flex:1;height:100%;border:none;padding:0;background:0 0}.van-pagination__item button[disabled]{cursor:not-allowed}.van-pagination__item:active{color:var(--van-white);background-color:var(--van-pagination-item-default-color)}.van-pagination__item:not(:last-child)::after{border-right-width:0}.van-pagination__item--active{color:var(--van-white);background-color:var(--van-pagination-item-default-color)}.van-pagination__item--page{flex-grow:0}.van-pagination__item--next,.van-pagination__item--prev{padding:0 var(--van-padding-base);cursor:pointer}.van-pagination__item--border::after{border-width:var(--van-border-width-base)}.van-pagination__item--disabled{color:var(--van-pagination-item-disabled-color);background-color:var(--van-pagination-item-disabled-background-color);opacity:var(--van-pagination-disabled-opacity)}.van-pagination__page-desc{flex:1;height:var(--van-pagination-height);color:var(--van-pagination-desc-color)}
|