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,251 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.default = void 0;
|
5
|
+
|
6
|
+
var _use = require("@vant/use");
|
7
|
+
|
8
|
+
var _util = require("./util");
|
9
|
+
|
10
|
+
var _utils = require("../../utils");
|
11
|
+
|
12
|
+
class ReactiveListener {
|
13
|
+
constructor(_ref) {
|
14
|
+
var {
|
15
|
+
el,
|
16
|
+
src,
|
17
|
+
error,
|
18
|
+
loading,
|
19
|
+
bindType,
|
20
|
+
$parent,
|
21
|
+
options,
|
22
|
+
cors,
|
23
|
+
elRenderer,
|
24
|
+
imageCache
|
25
|
+
} = _ref;
|
26
|
+
this.el = el;
|
27
|
+
this.src = src;
|
28
|
+
this.error = error;
|
29
|
+
this.loading = loading;
|
30
|
+
this.bindType = bindType;
|
31
|
+
this.attempt = 0;
|
32
|
+
this.cors = cors;
|
33
|
+
this.naturalHeight = 0;
|
34
|
+
this.naturalWidth = 0;
|
35
|
+
this.options = options;
|
36
|
+
this.$parent = $parent;
|
37
|
+
this.elRenderer = elRenderer;
|
38
|
+
this.imageCache = imageCache;
|
39
|
+
this.performanceData = {
|
40
|
+
loadStart: 0,
|
41
|
+
loadEnd: 0
|
42
|
+
};
|
43
|
+
this.filter();
|
44
|
+
this.initState();
|
45
|
+
this.render('loading', false);
|
46
|
+
}
|
47
|
+
/*
|
48
|
+
* init listener state
|
49
|
+
* @return
|
50
|
+
*/
|
51
|
+
|
52
|
+
|
53
|
+
initState() {
|
54
|
+
if ('dataset' in this.el) {
|
55
|
+
this.el.dataset.src = this.src;
|
56
|
+
} else {
|
57
|
+
this.el.setAttribute('data-src', this.src);
|
58
|
+
}
|
59
|
+
|
60
|
+
this.state = {
|
61
|
+
loading: false,
|
62
|
+
error: false,
|
63
|
+
loaded: false,
|
64
|
+
rendered: false
|
65
|
+
};
|
66
|
+
}
|
67
|
+
/*
|
68
|
+
* record performance
|
69
|
+
* @return
|
70
|
+
*/
|
71
|
+
|
72
|
+
|
73
|
+
record(event) {
|
74
|
+
this.performanceData[event] = Date.now();
|
75
|
+
}
|
76
|
+
/*
|
77
|
+
* update image listener data
|
78
|
+
* @param {String} image uri
|
79
|
+
* @param {String} loading image uri
|
80
|
+
* @param {String} error image uri
|
81
|
+
* @return
|
82
|
+
*/
|
83
|
+
|
84
|
+
|
85
|
+
update(_ref2) {
|
86
|
+
var {
|
87
|
+
src,
|
88
|
+
loading,
|
89
|
+
error
|
90
|
+
} = _ref2;
|
91
|
+
var oldSrc = this.src;
|
92
|
+
this.src = src;
|
93
|
+
this.loading = loading;
|
94
|
+
this.error = error;
|
95
|
+
this.filter();
|
96
|
+
|
97
|
+
if (oldSrc !== this.src) {
|
98
|
+
this.attempt = 0;
|
99
|
+
this.initState();
|
100
|
+
}
|
101
|
+
}
|
102
|
+
/*
|
103
|
+
* check el is in view
|
104
|
+
* @return {Boolean} el is in view
|
105
|
+
*/
|
106
|
+
|
107
|
+
|
108
|
+
checkInView() {
|
109
|
+
var rect = (0, _use.useRect)(this.el);
|
110
|
+
return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
|
111
|
+
}
|
112
|
+
/*
|
113
|
+
* listener filter
|
114
|
+
*/
|
115
|
+
|
116
|
+
|
117
|
+
filter() {
|
118
|
+
Object.keys(this.options.filter).forEach(key => {
|
119
|
+
this.options.filter[key](this, this.options);
|
120
|
+
});
|
121
|
+
}
|
122
|
+
/*
|
123
|
+
* render loading first
|
124
|
+
* @params cb:Function
|
125
|
+
* @return
|
126
|
+
*/
|
127
|
+
|
128
|
+
|
129
|
+
renderLoading(cb) {
|
130
|
+
this.state.loading = true;
|
131
|
+
(0, _util.loadImageAsync)({
|
132
|
+
src: this.loading,
|
133
|
+
cors: this.cors
|
134
|
+
}, () => {
|
135
|
+
this.render('loading', false);
|
136
|
+
this.state.loading = false;
|
137
|
+
cb();
|
138
|
+
}, () => {
|
139
|
+
// handler `loading image` load failed
|
140
|
+
cb();
|
141
|
+
this.state.loading = false;
|
142
|
+
if (process.env.NODE_ENV !== 'production' && !this.options.silent) console.warn("[@vant/lazyload] load failed with loading image(" + this.loading + ")");
|
143
|
+
});
|
144
|
+
}
|
145
|
+
/*
|
146
|
+
* try load image and render it
|
147
|
+
* @return
|
148
|
+
*/
|
149
|
+
|
150
|
+
|
151
|
+
load(onFinish) {
|
152
|
+
if (onFinish === void 0) {
|
153
|
+
onFinish = _utils.noop;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (this.attempt > this.options.attempt - 1 && this.state.error) {
|
157
|
+
if (process.env.NODE_ENV !== 'production' && !this.options.silent) {
|
158
|
+
console.log("[@vant/lazyload] " + this.src + " tried too more than " + this.options.attempt + " times");
|
159
|
+
}
|
160
|
+
|
161
|
+
onFinish();
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
|
165
|
+
if (this.state.rendered && this.state.loaded) return;
|
166
|
+
|
167
|
+
if (this.imageCache.has(this.src)) {
|
168
|
+
this.state.loaded = true;
|
169
|
+
this.render('loaded', true);
|
170
|
+
this.state.rendered = true;
|
171
|
+
return onFinish();
|
172
|
+
}
|
173
|
+
|
174
|
+
this.renderLoading(() => {
|
175
|
+
var _this$options$adapter, _this$options$adapter2;
|
176
|
+
|
177
|
+
this.attempt++;
|
178
|
+
(_this$options$adapter = (_this$options$adapter2 = this.options.adapter).beforeLoad) == null ? void 0 : _this$options$adapter.call(_this$options$adapter2, this, this.options);
|
179
|
+
this.record('loadStart');
|
180
|
+
(0, _util.loadImageAsync)({
|
181
|
+
src: this.src,
|
182
|
+
cors: this.cors
|
183
|
+
}, data => {
|
184
|
+
this.naturalHeight = data.naturalHeight;
|
185
|
+
this.naturalWidth = data.naturalWidth;
|
186
|
+
this.state.loaded = true;
|
187
|
+
this.state.error = false;
|
188
|
+
this.record('loadEnd');
|
189
|
+
this.render('loaded', false);
|
190
|
+
this.state.rendered = true;
|
191
|
+
this.imageCache.add(this.src);
|
192
|
+
onFinish();
|
193
|
+
}, err => {
|
194
|
+
!this.options.silent && console.error(err);
|
195
|
+
this.state.error = true;
|
196
|
+
this.state.loaded = false;
|
197
|
+
this.render('error', false);
|
198
|
+
});
|
199
|
+
});
|
200
|
+
}
|
201
|
+
/*
|
202
|
+
* render image
|
203
|
+
* @param {String} state to render // ['loading', 'src', 'error']
|
204
|
+
* @param {String} is form cache
|
205
|
+
* @return
|
206
|
+
*/
|
207
|
+
|
208
|
+
|
209
|
+
render(state, cache) {
|
210
|
+
this.elRenderer(this, state, cache);
|
211
|
+
}
|
212
|
+
/*
|
213
|
+
* output performance data
|
214
|
+
* @return {Object} performance data
|
215
|
+
*/
|
216
|
+
|
217
|
+
|
218
|
+
performance() {
|
219
|
+
var state = 'loading';
|
220
|
+
var time = 0;
|
221
|
+
|
222
|
+
if (this.state.loaded) {
|
223
|
+
state = 'loaded';
|
224
|
+
time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1000;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (this.state.error) state = 'error';
|
228
|
+
return {
|
229
|
+
src: this.src,
|
230
|
+
state,
|
231
|
+
time
|
232
|
+
};
|
233
|
+
}
|
234
|
+
/*
|
235
|
+
* $destroy
|
236
|
+
* @return
|
237
|
+
*/
|
238
|
+
|
239
|
+
|
240
|
+
$destroy() {
|
241
|
+
this.el = null;
|
242
|
+
this.src = null;
|
243
|
+
this.error = null;
|
244
|
+
this.loading = null;
|
245
|
+
this.bindType = null;
|
246
|
+
this.attempt = 0;
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
exports.default = ReactiveListener;
|
@@ -0,0 +1,213 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.ImageCache = void 0;
|
5
|
+
exports.getBestSelectionFromSrcset = getBestSelectionFromSrcset;
|
6
|
+
exports.modeType = exports.loadImageAsync = exports.hasIntersectionObserver = exports.getDPR = void 0;
|
7
|
+
exports.off = off;
|
8
|
+
exports.on = on;
|
9
|
+
exports.remove = remove;
|
10
|
+
exports.supportWebp = supportWebp;
|
11
|
+
exports.throttle = throttle;
|
12
|
+
|
13
|
+
var _use = require("@vant/use");
|
14
|
+
|
15
|
+
var hasIntersectionObserver = _use.inBrowser && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype;
|
16
|
+
exports.hasIntersectionObserver = hasIntersectionObserver;
|
17
|
+
var modeType = {
|
18
|
+
event: 'event',
|
19
|
+
observer: 'observer'
|
20
|
+
};
|
21
|
+
exports.modeType = modeType;
|
22
|
+
|
23
|
+
function remove(arr, item) {
|
24
|
+
if (!arr.length) return;
|
25
|
+
var index = arr.indexOf(item);
|
26
|
+
if (index > -1) return arr.splice(index, 1);
|
27
|
+
}
|
28
|
+
|
29
|
+
function getBestSelectionFromSrcset(el, scale) {
|
30
|
+
if (el.tagName !== 'IMG' || !el.getAttribute('data-srcset')) return;
|
31
|
+
var options = el.getAttribute('data-srcset');
|
32
|
+
var container = el.parentNode;
|
33
|
+
var containerWidth = container.offsetWidth * scale;
|
34
|
+
var spaceIndex;
|
35
|
+
var tmpSrc;
|
36
|
+
var tmpWidth;
|
37
|
+
options = options.trim().split(',');
|
38
|
+
var result = options.map(item => {
|
39
|
+
item = item.trim();
|
40
|
+
spaceIndex = item.lastIndexOf(' ');
|
41
|
+
|
42
|
+
if (spaceIndex === -1) {
|
43
|
+
tmpSrc = item;
|
44
|
+
tmpWidth = 999998;
|
45
|
+
} else {
|
46
|
+
tmpSrc = item.substr(0, spaceIndex);
|
47
|
+
tmpWidth = parseInt(item.substr(spaceIndex + 1, item.length - spaceIndex - 2), 10);
|
48
|
+
}
|
49
|
+
|
50
|
+
return [tmpWidth, tmpSrc];
|
51
|
+
});
|
52
|
+
result.sort((a, b) => {
|
53
|
+
if (a[0] < b[0]) {
|
54
|
+
return 1;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (a[0] > b[0]) {
|
58
|
+
return -1;
|
59
|
+
}
|
60
|
+
|
61
|
+
if (a[0] === b[0]) {
|
62
|
+
if (b[1].indexOf('.webp', b[1].length - 5) !== -1) {
|
63
|
+
return 1;
|
64
|
+
}
|
65
|
+
|
66
|
+
if (a[1].indexOf('.webp', a[1].length - 5) !== -1) {
|
67
|
+
return -1;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
return 0;
|
72
|
+
});
|
73
|
+
var bestSelectedSrc = '';
|
74
|
+
var tmpOption;
|
75
|
+
|
76
|
+
for (var i = 0; i < result.length; i++) {
|
77
|
+
tmpOption = result[i];
|
78
|
+
bestSelectedSrc = tmpOption[1];
|
79
|
+
var next = result[i + 1];
|
80
|
+
|
81
|
+
if (next && next[0] < containerWidth) {
|
82
|
+
bestSelectedSrc = tmpOption[1];
|
83
|
+
break;
|
84
|
+
} else if (!next) {
|
85
|
+
bestSelectedSrc = tmpOption[1];
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
return bestSelectedSrc;
|
91
|
+
}
|
92
|
+
|
93
|
+
var getDPR = function (scale) {
|
94
|
+
if (scale === void 0) {
|
95
|
+
scale = 1;
|
96
|
+
}
|
97
|
+
|
98
|
+
return _use.inBrowser ? window.devicePixelRatio || scale : scale;
|
99
|
+
};
|
100
|
+
|
101
|
+
exports.getDPR = getDPR;
|
102
|
+
|
103
|
+
function supportWebp() {
|
104
|
+
if (!_use.inBrowser) return false;
|
105
|
+
var support = true;
|
106
|
+
|
107
|
+
try {
|
108
|
+
var elem = document.createElement('canvas');
|
109
|
+
|
110
|
+
if (elem.getContext && elem.getContext('2d')) {
|
111
|
+
support = elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
112
|
+
}
|
113
|
+
} catch (err) {
|
114
|
+
support = false;
|
115
|
+
}
|
116
|
+
|
117
|
+
return support;
|
118
|
+
}
|
119
|
+
|
120
|
+
function throttle(action, delay) {
|
121
|
+
var timeout = null;
|
122
|
+
var lastRun = 0;
|
123
|
+
return function () {
|
124
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
125
|
+
args[_key] = arguments[_key];
|
126
|
+
}
|
127
|
+
|
128
|
+
if (timeout) {
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
|
132
|
+
var elapsed = Date.now() - lastRun;
|
133
|
+
|
134
|
+
var runCallback = () => {
|
135
|
+
lastRun = Date.now();
|
136
|
+
timeout = false;
|
137
|
+
action.apply(this, args);
|
138
|
+
};
|
139
|
+
|
140
|
+
if (elapsed >= delay) {
|
141
|
+
runCallback();
|
142
|
+
} else {
|
143
|
+
timeout = setTimeout(runCallback, delay);
|
144
|
+
}
|
145
|
+
};
|
146
|
+
}
|
147
|
+
|
148
|
+
function on(el, type, func) {
|
149
|
+
el.addEventListener(type, func, {
|
150
|
+
capture: false,
|
151
|
+
passive: true
|
152
|
+
});
|
153
|
+
}
|
154
|
+
|
155
|
+
function off(el, type, func) {
|
156
|
+
el.removeEventListener(type, func, false);
|
157
|
+
}
|
158
|
+
|
159
|
+
var loadImageAsync = (item, resolve, reject) => {
|
160
|
+
var image = new Image();
|
161
|
+
|
162
|
+
if (!item || !item.src) {
|
163
|
+
return reject(new Error('image src is required'));
|
164
|
+
}
|
165
|
+
|
166
|
+
image.src = item.src;
|
167
|
+
|
168
|
+
if (item.cors) {
|
169
|
+
image.crossOrigin = item.cors;
|
170
|
+
}
|
171
|
+
|
172
|
+
image.onload = () => resolve({
|
173
|
+
naturalHeight: image.naturalHeight,
|
174
|
+
naturalWidth: image.naturalWidth,
|
175
|
+
src: image.src
|
176
|
+
});
|
177
|
+
|
178
|
+
image.onerror = e => reject(e);
|
179
|
+
};
|
180
|
+
|
181
|
+
exports.loadImageAsync = loadImageAsync;
|
182
|
+
|
183
|
+
class ImageCache {
|
184
|
+
constructor(_ref) {
|
185
|
+
var {
|
186
|
+
max
|
187
|
+
} = _ref;
|
188
|
+
this.options = {
|
189
|
+
max: max || 100
|
190
|
+
};
|
191
|
+
this.caches = [];
|
192
|
+
}
|
193
|
+
|
194
|
+
has(key) {
|
195
|
+
return this.caches.indexOf(key) > -1;
|
196
|
+
}
|
197
|
+
|
198
|
+
add(key) {
|
199
|
+
if (this.has(key)) return;
|
200
|
+
this.caches.push(key);
|
201
|
+
|
202
|
+
if (this.caches.length > this.options.max) {
|
203
|
+
this.free();
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
free() {
|
208
|
+
this.caches.shift();
|
209
|
+
}
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
exports.ImageCache = ImageCache;
|
package/lib/list/List.js
CHANGED
@@ -105,7 +105,9 @@ var _default = (0, _vue.defineComponent)({
|
|
105
105
|
|
106
106
|
if (text) {
|
107
107
|
return (0, _vue.createVNode)("div", {
|
108
|
+
"role": "button",
|
108
109
|
"class": bem('error-text'),
|
110
|
+
"tabindex": 0,
|
109
111
|
"onClick": clickErrorText
|
110
112
|
}, [text]);
|
111
113
|
}
|
@@ -124,7 +126,7 @@ var _default = (0, _vue.defineComponent)({
|
|
124
126
|
}
|
125
127
|
};
|
126
128
|
|
127
|
-
(0, _vue.watch)(
|
129
|
+
(0, _vue.watch)(() => [props.loading, props.finished, props.error], check);
|
128
130
|
|
129
131
|
if (tabStatus) {
|
130
132
|
(0, _vue.watch)(tabStatus, tabActive => {
|
package/lib/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/lib/nav-bar/index.d.ts
CHANGED
@@ -16,14 +16,14 @@ var CollapseIcon = (0, _vue.createVNode)("svg", {
|
|
16
16
|
"class": bem('collapse-icon'),
|
17
17
|
"viewBox": "0 0 30 24"
|
18
18
|
}, [(0, _vue.createVNode)("path", {
|
19
|
-
"d": "
|
19
|
+
"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",
|
20
20
|
"fill": "currentColor"
|
21
21
|
}, null)]);
|
22
22
|
var DeleteIcon = (0, _vue.createVNode)("svg", {
|
23
23
|
"class": bem('delete-icon'),
|
24
24
|
"viewBox": "0 0 32 22"
|
25
25
|
}, [(0, _vue.createVNode)("path", {
|
26
|
-
"d": "M28
|
26
|
+
"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",
|
27
27
|
"fill": "currentColor"
|
28
28
|
}, null)]);
|
29
29
|
|
@@ -65,7 +65,7 @@ var _default = (0, _vue.defineComponent)({
|
|
65
65
|
// eliminate tap delay on safari
|
66
66
|
// see: https://github.com/youzan/vant/issues/6836
|
67
67
|
if (!slots.default) {
|
68
|
-
|
68
|
+
(0, _utils.preventDefault)(event);
|
69
69
|
}
|
70
70
|
|
71
71
|
active.value = false;
|
@@ -53,12 +53,7 @@ var _default = (0, _vue.defineComponent)({
|
|
53
53
|
var {
|
54
54
|
modelValue,
|
55
55
|
forceEllipses
|
56
|
-
} = props;
|
57
|
-
|
58
|
-
if (props.mode !== 'multi') {
|
59
|
-
return items;
|
60
|
-
} // Default page limits
|
61
|
-
|
56
|
+
} = props; // Default page limits
|
62
57
|
|
63
58
|
var startPage = 1;
|
64
59
|
var endPage = pageCount;
|
@@ -97,59 +92,82 @@ var _default = (0, _vue.defineComponent)({
|
|
97
92
|
return items;
|
98
93
|
});
|
99
94
|
|
100
|
-
var
|
101
|
-
|
95
|
+
var updateModelValue = (value, emitChange) => {
|
96
|
+
value = (0, _utils.clamp)(value, 1, count.value);
|
102
97
|
|
103
|
-
if (props.modelValue !==
|
104
|
-
emit('update:modelValue',
|
98
|
+
if (props.modelValue !== value) {
|
99
|
+
emit('update:modelValue', value);
|
105
100
|
|
106
101
|
if (emitChange) {
|
107
|
-
emit('change',
|
102
|
+
emit('change', value);
|
108
103
|
}
|
109
104
|
}
|
110
|
-
};
|
105
|
+
}; // format modelValue
|
111
106
|
|
112
|
-
(0, _vue.watch)(() => props.modelValue, value => {
|
113
|
-
select(value);
|
114
|
-
}, {
|
115
|
-
immediate: true
|
116
|
-
});
|
117
|
-
|
118
|
-
var renderDesc = () => {
|
119
|
-
if (props.mode !== 'multi') {
|
120
|
-
return (0, _vue.createVNode)("li", {
|
121
|
-
"class": bem('page-desc')
|
122
|
-
}, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
|
123
|
-
}
|
124
|
-
};
|
125
107
|
|
126
|
-
|
127
|
-
var value = props.modelValue;
|
128
|
-
var simple = props.mode !== 'multi';
|
108
|
+
(0, _vue.watchEffect)(() => updateModelValue(props.modelValue));
|
129
109
|
|
130
|
-
|
110
|
+
var renderDesc = () => (0, _vue.createVNode)("li", {
|
111
|
+
"class": bem('page-desc')
|
112
|
+
}, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
|
131
113
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
}
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
"onClick": onSelect(value - 1)
|
141
|
-
}, [slots['prev-text'] ? slots['prev-text']() : props.prevText || t('prev')]), pages.value.map(page => (0, _vue.createVNode)("li", {
|
114
|
+
var renderPrevButton = () => {
|
115
|
+
var {
|
116
|
+
mode,
|
117
|
+
modelValue
|
118
|
+
} = props;
|
119
|
+
var slot = slots['prev-text'];
|
120
|
+
var disabled = modelValue === 1;
|
121
|
+
return (0, _vue.createVNode)("li", {
|
142
122
|
"class": [bem('item', {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
123
|
+
disabled,
|
124
|
+
border: mode === 'simple',
|
125
|
+
prev: true
|
126
|
+
}), _utils.BORDER_SURROUND]
|
127
|
+
}, [(0, _vue.createVNode)("button", {
|
128
|
+
"type": "button",
|
129
|
+
"disabled": disabled,
|
130
|
+
"onClick": () => updateModelValue(modelValue - 1)
|
131
|
+
}, [slot ? slot() : props.prevText || t('prev')])]);
|
132
|
+
};
|
133
|
+
|
134
|
+
var renderNextButton = () => {
|
135
|
+
var {
|
136
|
+
mode,
|
137
|
+
modelValue
|
138
|
+
} = props;
|
139
|
+
var slot = slots['next-text'];
|
140
|
+
var disabled = modelValue === count.value;
|
141
|
+
return (0, _vue.createVNode)("li", {
|
147
142
|
"class": [bem('item', {
|
148
|
-
disabled
|
149
|
-
|
150
|
-
|
151
|
-
|
143
|
+
disabled,
|
144
|
+
border: mode === 'simple',
|
145
|
+
next: true
|
146
|
+
}), _utils.BORDER_SURROUND]
|
147
|
+
}, [(0, _vue.createVNode)("button", {
|
148
|
+
"type": "button",
|
149
|
+
"disabled": disabled,
|
150
|
+
"onClick": () => updateModelValue(modelValue + 1)
|
151
|
+
}, [slot ? slot() : props.nextText || t('next')])]);
|
152
152
|
};
|
153
|
+
|
154
|
+
var renderPages = () => pages.value.map(page => (0, _vue.createVNode)("li", {
|
155
|
+
"class": [bem('item', {
|
156
|
+
active: page.active,
|
157
|
+
page: true
|
158
|
+
}), _utils.BORDER_SURROUND]
|
159
|
+
}, [(0, _vue.createVNode)("button", {
|
160
|
+
"type": "button",
|
161
|
+
"aria-current": page.active || undefined,
|
162
|
+
"onClick": () => updateModelValue(page.number)
|
163
|
+
}, [slots.page ? slots.page(page) : page.text])]));
|
164
|
+
|
165
|
+
return () => (0, _vue.createVNode)("nav", {
|
166
|
+
"role": "navigation",
|
167
|
+
"class": bem()
|
168
|
+
}, [(0, _vue.createVNode)("ul", {
|
169
|
+
"class": bem('items')
|
170
|
+
}, [renderPrevButton(), props.mode === 'simple' ? renderDesc() : renderPages(), renderNextButton()])]);
|
153
171
|
}
|
154
172
|
|
155
173
|
});
|
package/lib/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)}
|