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,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([() => props.loading, () => props.finished, () => props.error], check);
119
+ watch(() => [props.loading, props.finished, props.error], check);
118
120
 
119
121
  if (tabStatus) {
120
122
  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';
@@ -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": "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",
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.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",
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
- event.preventDefault();
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, watch, defineComponent } from 'vue';
3
- import { BORDER, makeStringProp, makeNumberProp, makeNumericProp, createNamespace } from '../utils';
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 select = (page, emitChange) => {
94
- page = Math.min(count.value, Math.max(1, page));
88
+ var updateModelValue = (value, emitChange) => {
89
+ value = clamp(value, 1, count.value);
95
90
 
96
- if (props.modelValue !== page) {
97
- emit('update:modelValue', page);
91
+ if (props.modelValue !== value) {
92
+ emit('update:modelValue', value);
98
93
 
99
94
  if (emitChange) {
100
- emit('change', page);
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
- return () => {
120
- var value = props.modelValue;
121
- var simple = props.mode !== 'multi';
101
+ watchEffect(() => updateModelValue(props.modelValue));
122
102
 
123
- var onSelect = value => () => select(value, true);
103
+ var renderDesc = () => _createVNode("li", {
104
+ "class": bem('page-desc')
105
+ }, [slots.pageDesc ? slots.pageDesc() : props.modelValue + "/" + count.value]);
124
106
 
125
- return _createVNode("ul", {
126
- "class": bem({
127
- simple
128
- })
129
- }, [_createVNode("li", {
130
- "class": [bem('item', {
131
- disabled: value === 1
132
- }), bem('prev'), BORDER],
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
- active: page.active
137
- }), bem('page'), BORDER],
138
- "onClick": onSelect(page.number)
139
- }, [slots.page ? slots.page(page) : page.text])), renderDesc(), _createVNode("li", {
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: value === count.value
142
- }), bem('next'), BORDER],
143
- "onClick": onSelect(value + 1)
144
- }, [slots['next-text'] ? slots['next-text']() : props.nextText || t('next')])]);
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
  });
@@ -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)}