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.
Files changed (191) hide show
  1. package/es/address-edit/AddressEdit.js +154 -180
  2. package/es/address-edit/AddressEditDetail.d.ts +10 -9
  3. package/es/address-edit/AddressEditDetail.js +6 -6
  4. package/es/button/Button.js +2 -2
  5. package/es/calendar/Calendar.js +8 -14
  6. package/es/calendar/CalendarHeader.js +1 -3
  7. package/es/calendar/CalendarMonth.js +11 -10
  8. package/es/calendar/types.d.ts +1 -1
  9. package/es/cascader/Cascader.js +17 -5
  10. package/es/checkbox/Checker.js +1 -1
  11. package/es/checkbox/types.d.ts +2 -6
  12. package/es/composables/use-id.d.ts +1 -0
  13. package/es/composables/use-id.js +14 -0
  14. package/es/composables/use-route.d.ts +1 -1
  15. package/es/composables/use-route.js +4 -4
  16. package/es/count-down/CountDown.js +1 -0
  17. package/es/coupon-list/CouponList.js +40 -24
  18. package/es/coupon-list/index.css +1 -1
  19. package/es/coupon-list/index.less +0 -5
  20. package/es/dropdown-item/DropdownItem.js +7 -2
  21. package/es/dropdown-item/types.d.ts +2 -6
  22. package/es/dropdown-menu/DropdownMenu.js +7 -3
  23. package/es/dropdown-menu/types.d.ts +1 -0
  24. package/es/empty/Network.js +22 -34
  25. package/es/field/Field.d.ts +1 -1
  26. package/es/field/Field.js +13 -5
  27. package/es/field/index.d.ts +2 -2
  28. package/es/field/types.d.ts +7 -6
  29. package/es/form/Form.js +2 -2
  30. package/es/image/Image.js +4 -9
  31. package/es/image-preview/ImagePreview.js +3 -4
  32. package/es/index.d.ts +1 -1
  33. package/es/index.js +1 -1
  34. package/es/lazyload/index.d.ts +1 -1
  35. package/es/lazyload/index.js +1 -1
  36. package/es/lazyload/vue-lazyload/index.d.ts +55 -0
  37. package/es/lazyload/vue-lazyload/index.js +46 -0
  38. package/es/lazyload/vue-lazyload/lazy-component.js +53 -0
  39. package/es/lazyload/vue-lazyload/lazy-container.js +98 -0
  40. package/es/lazyload/vue-lazyload/lazy-image.js +115 -0
  41. package/es/lazyload/vue-lazyload/lazy.js +507 -0
  42. package/es/lazyload/vue-lazyload/listener.js +241 -0
  43. package/es/lazyload/vue-lazyload/util.js +183 -0
  44. package/es/list/List.js +3 -1
  45. package/es/nav-bar/NavBar.d.ts +1 -1
  46. package/es/nav-bar/index.d.ts +1 -1
  47. package/es/number-keyboard/NumberKeyboardKey.js +4 -4
  48. package/es/pagination/Pagination.js +67 -49
  49. package/es/pagination/index.css +1 -1
  50. package/es/pagination/index.less +32 -31
  51. package/es/password-input/PasswordInput.d.ts +21 -1
  52. package/es/password-input/PasswordInput.js +10 -9
  53. package/es/password-input/index.d.ts +2 -1
  54. package/es/popover/Popover.js +2 -0
  55. package/es/popup/Popup.d.ts +1 -2
  56. package/es/popup/Popup.js +2 -5
  57. package/es/popup/index.d.ts +1 -2
  58. package/es/progress/Progress.js +2 -2
  59. package/es/rate/Rate.js +5 -3
  60. package/es/search/Search.js +8 -2
  61. package/es/sidebar/Sidebar.js +1 -0
  62. package/es/sidebar-item/SidebarItem.js +4 -1
  63. package/es/slider/Slider.js +5 -3
  64. package/es/stepper/Stepper.js +11 -8
  65. package/es/submit-bar/SubmitBar.d.ts +4 -3
  66. package/es/submit-bar/index.d.ts +3 -2
  67. package/es/swipe/Swipe.js +11 -6
  68. package/es/swipe/types.d.ts +1 -3
  69. package/es/switch/Switch.js +1 -0
  70. package/es/switch/index.css +1 -1
  71. package/es/switch/index.less +2 -0
  72. package/es/tab/Tab.js +18 -5
  73. package/es/tab/index.css +1 -1
  74. package/es/tab/index.less +1 -1
  75. package/es/tabbar/Tabbar.d.ts +1 -1
  76. package/es/tabbar/Tabbar.js +10 -10
  77. package/es/tabbar-item/TabbarItem.js +16 -7
  78. package/es/tabs/Tabs.js +17 -11
  79. package/es/tabs/TabsTitle.d.ts +6 -0
  80. package/es/tabs/TabsTitle.js +7 -1
  81. package/es/tabs/types.d.ts +1 -0
  82. package/es/uploader/UploaderPreviewItem.js +4 -1
  83. package/es/uploader/utils.d.ts +2 -2
  84. package/es/uploader/utils.js +2 -2
  85. package/es/utils/dom.d.ts +1 -0
  86. package/es/utils/dom.js +6 -2
  87. package/es/utils/format.js +6 -5
  88. package/es/vue-tsx-shim.d.ts +1 -0
  89. package/lib/address-edit/AddressEdit.js +155 -180
  90. package/lib/address-edit/AddressEditDetail.d.ts +10 -9
  91. package/lib/address-edit/AddressEditDetail.js +6 -6
  92. package/lib/button/Button.js +1 -1
  93. package/lib/calendar/Calendar.js +8 -14
  94. package/lib/calendar/CalendarHeader.js +1 -3
  95. package/lib/calendar/CalendarMonth.js +11 -10
  96. package/lib/calendar/types.d.ts +1 -1
  97. package/lib/cascader/Cascader.js +17 -5
  98. package/lib/checkbox/Checker.js +1 -1
  99. package/lib/checkbox/types.d.ts +2 -6
  100. package/lib/composables/use-id.d.ts +1 -0
  101. package/lib/composables/use-id.js +21 -0
  102. package/lib/composables/use-route.d.ts +1 -1
  103. package/lib/composables/use-route.js +4 -4
  104. package/lib/count-down/CountDown.js +1 -0
  105. package/lib/coupon-list/CouponList.js +39 -22
  106. package/lib/coupon-list/index.css +1 -1
  107. package/lib/coupon-list/index.less +0 -5
  108. package/lib/dropdown-item/DropdownItem.js +7 -2
  109. package/lib/dropdown-item/types.d.ts +2 -6
  110. package/lib/dropdown-menu/DropdownMenu.js +7 -2
  111. package/lib/dropdown-menu/types.d.ts +1 -0
  112. package/lib/empty/Network.js +22 -34
  113. package/lib/field/Field.d.ts +1 -1
  114. package/lib/field/Field.js +14 -5
  115. package/lib/field/index.d.ts +2 -2
  116. package/lib/field/types.d.ts +7 -6
  117. package/lib/form/Form.js +1 -1
  118. package/lib/image/Image.js +4 -9
  119. package/lib/image-preview/ImagePreview.js +1 -2
  120. package/lib/index.css +1 -1
  121. package/lib/index.d.ts +1 -1
  122. package/lib/index.js +1 -1
  123. package/lib/lazyload/index.d.ts +1 -1
  124. package/lib/lazyload/index.js +3 -3
  125. package/lib/lazyload/vue-lazyload/index.d.ts +55 -0
  126. package/lib/lazyload/vue-lazyload/index.js +58 -0
  127. package/lib/lazyload/vue-lazyload/lazy-component.js +62 -0
  128. package/lib/lazyload/vue-lazyload/lazy-container.js +106 -0
  129. package/lib/lazyload/vue-lazyload/lazy-image.js +125 -0
  130. package/lib/lazyload/vue-lazyload/lazy.js +520 -0
  131. package/lib/lazyload/vue-lazyload/listener.js +251 -0
  132. package/lib/lazyload/vue-lazyload/util.js +213 -0
  133. package/lib/list/List.js +3 -1
  134. package/lib/nav-bar/NavBar.d.ts +1 -1
  135. package/lib/nav-bar/index.d.ts +1 -1
  136. package/lib/number-keyboard/NumberKeyboardKey.js +3 -3
  137. package/lib/pagination/Pagination.js +65 -47
  138. package/lib/pagination/index.css +1 -1
  139. package/lib/pagination/index.less +32 -31
  140. package/lib/password-input/PasswordInput.d.ts +21 -1
  141. package/lib/password-input/PasswordInput.js +10 -9
  142. package/lib/password-input/index.d.ts +2 -1
  143. package/lib/popover/Popover.js +2 -0
  144. package/lib/popup/Popup.d.ts +1 -2
  145. package/lib/popup/Popup.js +2 -5
  146. package/lib/popup/index.d.ts +1 -2
  147. package/lib/progress/Progress.js +2 -2
  148. package/lib/rate/Rate.js +5 -3
  149. package/lib/search/Search.js +9 -2
  150. package/lib/sidebar/Sidebar.js +1 -0
  151. package/lib/sidebar-item/SidebarItem.js +4 -1
  152. package/lib/slider/Slider.js +5 -3
  153. package/lib/stepper/Stepper.js +11 -8
  154. package/lib/submit-bar/SubmitBar.d.ts +4 -3
  155. package/lib/submit-bar/index.d.ts +3 -2
  156. package/lib/swipe/Swipe.js +9 -4
  157. package/lib/swipe/types.d.ts +1 -3
  158. package/lib/switch/Switch.js +1 -0
  159. package/lib/switch/index.css +1 -1
  160. package/lib/switch/index.less +2 -0
  161. package/lib/tab/Tab.js +20 -5
  162. package/lib/tab/index.css +1 -1
  163. package/lib/tab/index.less +1 -1
  164. package/lib/tabbar/Tabbar.d.ts +1 -1
  165. package/lib/tabbar/Tabbar.js +10 -10
  166. package/lib/tabbar-item/TabbarItem.js +16 -7
  167. package/lib/tabs/Tabs.js +16 -9
  168. package/lib/tabs/TabsTitle.d.ts +6 -0
  169. package/lib/tabs/TabsTitle.js +7 -1
  170. package/lib/tabs/types.d.ts +1 -0
  171. package/lib/uploader/UploaderPreviewItem.js +3 -0
  172. package/lib/uploader/utils.d.ts +2 -2
  173. package/lib/uploader/utils.js +3 -2
  174. package/lib/utils/dom.d.ts +1 -0
  175. package/lib/utils/dom.js +9 -2
  176. package/lib/utils/format.js +7 -5
  177. package/lib/vant.cjs.js +14407 -0
  178. package/lib/vant.cjs.min.js +1 -0
  179. package/lib/vant.es.js +1217 -2203
  180. package/lib/vant.es.min.js +1217 -2203
  181. package/lib/vant.js +1349 -1254
  182. package/lib/vant.min.js +1 -1
  183. package/lib/vue-tsx-shim.d.ts +1 -0
  184. package/package.json +27 -13
  185. package/vetur/attributes.json +115 -115
  186. package/vetur/tags.json +35 -35
  187. package/vetur/web-types.json +370 -366
  188. package/es/composables/use-link-field.d.ts +0 -0
  189. package/es/composables/use-link-field.js +0 -0
  190. package/lib/composables/use-link-field.d.ts +0 -0
  191. 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)([() => props.loading, () => props.finished, () => props.error], check);
129
+ (0, _vue.watch)(() => [props.loading, props.finished, props.error], check);
128
130
 
129
131
  if (tabStatus) {
130
132
  (0, _vue.watch)(tabStatus, tabActive => {
@@ -13,7 +13,7 @@ declare const navBarProps: {
13
13
  placeholder: BooleanConstructor;
14
14
  safeAreaInsetTop: BooleanConstructor;
15
15
  };
16
- export declare type NavbarProps = ExtractPropTypes<typeof navBarProps>;
16
+ export declare type NavBarProps = ExtractPropTypes<typeof navBarProps>;
17
17
  declare const _default: import("vue").DefineComponent<{
18
18
  title: StringConstructor;
19
19
  fixed: BooleanConstructor;
@@ -43,4 +43,4 @@ export declare const NavBar: import("../utils").WithInstall<import("vue").Define
43
43
  safeAreaInsetTop: boolean;
44
44
  }>>;
45
45
  export default NavBar;
46
- export type { NavbarProps } from './NavBar';
46
+ export type { NavBarProps } from './NavBar';
@@ -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": "M25.877 12.843h-1.502c-.188 0-.188 0-.188.19v1.512c0 .188 0 .188.188.188h1.5c.187 0 .187 0 .187-.188v-1.511c0-.19 0-.191-.185-.191zM17.999 10.2c0 .188 0 .188.188.188h1.687c.188 0 .188 0 .188-.188V8.688c0-.187.004-.187-.186-.19h-1.69c-.187 0-.187 0-.187.19V10.2zm2.25-3.967h1.5c.188 0 .188 0 .188-.188v-1.7c0-.19 0-.19-.188-.19h-1.5c-.189 0-.189 0-.189.19v1.7c0 .188 0 .188.19.188zm2.063 4.157h3.563c.187 0 .187 0 .187-.189V4.346c0-.19.004-.19-.185-.19h-1.69c-.187 0-.187 0-.187.188v4.155h-1.688c-.187 0-.187 0-.187.189v1.514c0 .19 0 .19.187.19zM14.812 24l2.812-3.4H12l2.813 3.4zm-9-11.157H4.31c-.188 0-.188 0-.188.19v1.512c0 .188 0 .188.188.188h1.502c.187 0 .187 0 .187-.188v-1.511c0-.19.01-.191-.189-.191zm15.937 0H8.25c-.188 0-.188 0-.188.19v1.512c0 .188 0 .188.188.188h13.5c.188 0 .188 0 .188-.188v-1.511c0-.19 0-.191-.188-.191zm-11.438-2.454h1.5c.188 0 .188 0 .188-.188V8.688c0-.187 0-.187-.188-.189h-1.5c-.187 0-.187 0-.187.189V10.2c0 .188 0 .188.187.188zM27.94 0c.563 0 .917.21 1.313.567.518.466.748.757.748 1.51v14.92c0 .567-.188 1.134-.562 1.512-.376.378-.938.566-1.313.566H2.063c-.563 0-.938-.188-1.313-.566-.562-.378-.75-.945-.75-1.511V2.078C0 1.51.188.944.562.567.938.189 1.5 0 1.875 0zm-.062 2H2v14.92h25.877V2zM5.81 4.157c.19 0 .19 0 .19.189v1.762c-.003.126-.024.126-.188.126H4.249c-.126-.003-.126-.023-.126-.188v-1.7c-.187-.19 0-.19.188-.19zm10.5 2.077h1.503c.187 0 .187 0 .187-.188v-1.7c0-.19 0-.19-.187-.19h-1.502c-.188 0-.188.001-.188.19v1.7c0 .188 0 .188.188.188zM7.875 8.5c.187 0 .187.002.187.189V10.2c0 .188 0 .188-.187.188H4.249c-.126-.002-.126-.023-.126-.188V8.625c.003-.126.024-.126.188-.126zm7.875 0c.19.002.19.002.19.189v1.575c-.003.126-.024.126-.19.126h-1.563c-.126-.002-.126-.023-.126-.188V8.625c.002-.126.023-.126.189-.126zm-6-4.342c.187 0 .187 0 .187.189v1.7c0 .188 0 .188-.187.188H8.187c-.126-.003-.126-.023-.126-.188V4.283c.003-.126.024-.126.188-.126zm3.94 0c.185 0 .372 0 .372.189v1.762c-.002.126-.023.126-.187.126h-1.75C12 6.231 12 6.211 12 6.046v-1.7c0-.19.187-.19.187-.19z",
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.016 0A3.991 3.991 0 0132 3.987v14.026c0 2.2-1.787 3.987-3.98 3.987H10.382c-.509 0-.996-.206-1.374-.585L.89 13.09C.33 12.62 0 11.84 0 11.006c0-.86.325-1.62.887-2.08L9.01.585A1.936 1.936 0 0110.383 0zm0 1.947H10.368L2.24 10.28c-.224.226-.312.432-.312.73 0 .287.094.51.312.729l8.128 8.333h17.648a2.041 2.041 0 002.037-2.04V3.987c0-1.127-.915-2.04-2.037-2.04zM23.028 6a.96.96 0 01.678.292.95.95 0 01-.003 1.377l-3.342 3.348 3.326 3.333c.189.188.292.43.292.679 0 .248-.103.49-.292.679a.96.96 0 01-.678.292.959.959 0 01-.677-.292L18.99 12.36l-3.343 3.345a.96.96 0 01-.677.292.96.96 0 01-.678-.292.962.962 0 01-.292-.68c0-.248.104-.49.292-.679l3.342-3.348-3.342-3.348A.963.963 0 0114 6.971c0-.248.104-.49.292-.679A.96.96 0 0114.97 6a.96.96 0 01.677.292l3.358 3.348 3.345-3.348A.96.96 0 0123.028 6z",
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
- event.preventDefault();
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 select = (page, emitChange) => {
101
- page = Math.min(count.value, Math.max(1, page));
95
+ var updateModelValue = (value, emitChange) => {
96
+ value = (0, _utils.clamp)(value, 1, count.value);
102
97
 
103
- if (props.modelValue !== page) {
104
- emit('update:modelValue', page);
98
+ if (props.modelValue !== value) {
99
+ emit('update:modelValue', value);
105
100
 
106
101
  if (emitChange) {
107
- emit('change', page);
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
- return () => {
127
- var value = props.modelValue;
128
- var simple = props.mode !== 'multi';
108
+ (0, _vue.watchEffect)(() => updateModelValue(props.modelValue));
129
109
 
130
- var onSelect = value => () => select(value, true);
110
+ var renderDesc = () => (0, _vue.createVNode)("li", {
111
+ "class": bem('page-desc')
112
+ }, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
131
113
 
132
- return (0, _vue.createVNode)("ul", {
133
- "class": bem({
134
- simple
135
- })
136
- }, [(0, _vue.createVNode)("li", {
137
- "class": [bem('item', {
138
- disabled: value === 1
139
- }), bem('prev'), _utils.BORDER],
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
- active: page.active
144
- }), bem('page'), _utils.BORDER],
145
- "onClick": onSelect(page.number)
146
- }, [slots.page ? slots.page(page) : page.text])), renderDesc(), (0, _vue.createVNode)("li", {
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: value === count.value
149
- }), bem('next'), _utils.BORDER],
150
- "onClick": onSelect(value + 1)
151
- }, [slots['next-text'] ? slots['next-text']() : props.nextText || t('next')])]);
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
  });
@@ -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{display:flex;font-size:var(--van-pagination-font-size)}.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:active{color:var(--van-white);background-color:var(--van-pagination-item-default-color)}.van-pagination__item::after{border-width:var(--van-border-width-base) 0 var(--van-border-width-base) var(--van-border-width-base)}.van-pagination__item:last-child::after{border-right-width:var(--van-border-width-base)}.van-pagination__item--active{color:var(--van-white);background-color:var(--van-pagination-item-default-color)}.van-pagination__next,.van-pagination__prev{padding:0 var(--van-padding-base);cursor:pointer}.van-pagination__item--disabled,.van-pagination__item--disabled:active{color:var(--van-pagination-item-disabled-color);background-color:var(--van-pagination-item-disabled-background-color);cursor:not-allowed;opacity:var(--van-pagination-disabled-opacity)}.van-pagination__page{flex-grow:0}.van-pagination__page-desc{flex:1;height:var(--van-pagination-height);color:var(--van-pagination-desc-color)}.van-pagination--simple .van-pagination__next::after,.van-pagination--simple .van-pagination__prev::after{border-width:var(--van-border-width-base)}
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)}