vant 3.6.2 → 3.6.4

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/lib/index.d.ts CHANGED
@@ -91,4 +91,4 @@ declare namespace _default {
91
91
  }
92
92
  export default _default;
93
93
  export function install(app: any): void;
94
- export const version: "3.6.2";
94
+ export const version: "3.6.4";
package/lib/index.js CHANGED
@@ -196,7 +196,7 @@ __reExport(stdin_exports, require("./tag"), module.exports);
196
196
  __reExport(stdin_exports, require("./toast"), module.exports);
197
197
  __reExport(stdin_exports, require("./tree-select"), module.exports);
198
198
  __reExport(stdin_exports, require("./uploader"), module.exports);
199
- const version = "3.6.2";
199
+ const version = "3.6.4";
200
200
  function install(app) {
201
201
  const components = [
202
202
  import_action_bar.ActionBar,
package/lib/tab/Tab.js CHANGED
@@ -78,6 +78,16 @@ var stdin_default = (0, import_vue2.defineComponent)({
78
78
  }
79
79
  return isActive;
80
80
  });
81
+ const hasInactiveClass = (0, import_vue2.ref)(!active.value);
82
+ (0, import_vue2.watch)(active, (val) => {
83
+ if (val) {
84
+ hasInactiveClass.value = false;
85
+ } else {
86
+ (0, import_use.doubleRaf)(() => {
87
+ hasInactiveClass.value = true;
88
+ });
89
+ }
90
+ });
81
91
  (0, import_vue2.watch)(() => props.title, () => {
82
92
  parent.setLine();
83
93
  parent.scrollIntoView();
@@ -101,7 +111,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
101
111
  "id": id,
102
112
  "role": "tabpanel",
103
113
  "class": bem("panel-wrapper", {
104
- inactive: !active.value
114
+ inactive: hasInactiveClass.value
105
115
  }),
106
116
  "tabindex": active.value ? 0 : -1,
107
117
  "aria-hidden": !active.value,
package/lib/tabs/Tabs.js CHANGED
@@ -172,7 +172,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
172
172
  index += diff;
173
173
  }
174
174
  };
175
- const setCurrentIndex = (currentIndex) => {
175
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
176
176
  const newIndex = findAvailableTab(currentIndex);
177
177
  if (!(0, import_utils.isDef)(newIndex)) {
178
178
  return;
@@ -180,18 +180,27 @@ var stdin_default = (0, import_vue2.defineComponent)({
180
180
  const newTab = children[newIndex];
181
181
  const newName = getTabName(newTab, newIndex);
182
182
  const shouldEmitChange = state.currentIndex !== null;
183
- state.currentIndex = newIndex;
183
+ if (state.currentIndex !== newIndex) {
184
+ state.currentIndex = newIndex;
185
+ if (!skipScrollIntoView) {
186
+ scrollIntoView();
187
+ }
188
+ setLine();
189
+ }
184
190
  if (newName !== props.active) {
185
191
  emit("update:active", newName);
186
192
  if (shouldEmitChange) {
187
193
  emit("change", newName, newTab.title);
188
194
  }
189
195
  }
196
+ if (stickyFixed && !props.scrollspy) {
197
+ (0, import_utils.setRootScrollTop)(Math.ceil((0, import_utils.getElementTop)(root.value) - offsetTopPx.value));
198
+ }
190
199
  };
191
- const setCurrentIndexByName = (name2) => {
200
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
192
201
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
193
202
  const index = matched ? children.indexOf(matched) : 0;
194
- setCurrentIndex(index);
203
+ setCurrentIndex(index, skipScrollIntoView);
195
204
  };
196
205
  const scrollToCurrentContent = (immediate = false) => {
197
206
  if (props.scrollspy) {
@@ -285,13 +294,14 @@ var stdin_default = (0, import_vue2.defineComponent)({
285
294
  }
286
295
  };
287
296
  const renderHeader = () => {
288
- var _a2, _b2;
297
+ var _a2, _b2, _c;
289
298
  const {
290
299
  type,
291
- border
300
+ border,
301
+ sticky
292
302
  } = props;
293
- return (0, import_vue.createVNode)("div", {
294
- "ref": wrapRef,
303
+ const Header = [(0, import_vue.createVNode)("div", {
304
+ "ref": sticky ? void 0 : wrapRef,
295
305
  "class": [bem("wrap"), {
296
306
  [import_utils.BORDER_TOP_BOTTOM]: type === "line" && border
297
307
  }]
@@ -304,7 +314,13 @@ var stdin_default = (0, import_vue2.defineComponent)({
304
314
  }]),
305
315
  "style": navStyle.value,
306
316
  "aria-orientation": "horizontal"
307
- }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]);
317
+ }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
318
+ if (sticky) {
319
+ return (0, import_vue.createVNode)("div", {
320
+ "ref": wrapRef
321
+ }, [Header]);
322
+ }
323
+ return Header;
308
324
  };
309
325
  (0, import_vue2.watch)([() => props.color, import_utils.windowWidth], setLine);
310
326
  (0, import_vue2.watch)(() => props.active, (value) => {
@@ -321,15 +337,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
321
337
  });
322
338
  }
323
339
  });
324
- (0, import_vue2.watch)(() => state.currentIndex, () => {
325
- scrollIntoView();
326
- setLine();
327
- if (stickyFixed && !props.scrollspy) {
328
- (0, import_utils.setRootScrollTop)(Math.ceil((0, import_utils.getElementTop)(root.value) - offsetTopPx.value));
329
- }
330
- });
331
340
  const init = () => {
332
- setCurrentIndexByName(props.active);
341
+ setCurrentIndexByName(props.active, true);
333
342
  (0, import_vue2.nextTick)(() => {
334
343
  state.inited = true;
335
344
  if (wrapRef.value) {
@@ -365,36 +374,30 @@ var stdin_default = (0, import_vue2.defineComponent)({
365
374
  currentName,
366
375
  scrollIntoView
367
376
  });
368
- return () => {
369
- var _a2;
370
- return (0, import_vue.createVNode)("div", {
371
- "ref": root,
372
- "class": bem([props.type])
373
- }, [props.sticky ? (0, import_vue.createVNode)(import_sticky.Sticky, {
374
- "container": root.value,
375
- "offsetTop": offsetTopPx.value,
376
- "onScroll": onStickyScroll
377
- }, {
378
- default: () => {
379
- var _a3;
380
- return [renderHeader(), (_a3 = slots["nav-bottom"]) == null ? void 0 : _a3.call(slots)];
381
- }
382
- }) : [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)], (0, import_vue.createVNode)(import_TabsContent.default, {
383
- "ref": contentRef,
384
- "count": children.length,
385
- "inited": state.inited,
386
- "animated": props.animated,
387
- "duration": props.duration,
388
- "swipeable": props.swipeable,
389
- "lazyRender": props.lazyRender,
390
- "currentIndex": state.currentIndex,
391
- "onChange": setCurrentIndex
392
- }, {
393
- default: () => {
394
- var _a3;
395
- return [(_a3 = slots.default) == null ? void 0 : _a3.call(slots)];
396
- }
397
- })]);
398
- };
377
+ return () => (0, import_vue.createVNode)("div", {
378
+ "ref": root,
379
+ "class": bem([props.type])
380
+ }, [props.sticky ? (0, import_vue.createVNode)(import_sticky.Sticky, {
381
+ "container": root.value,
382
+ "offsetTop": offsetTopPx.value,
383
+ "onScroll": onStickyScroll
384
+ }, {
385
+ default: () => [renderHeader()]
386
+ }) : renderHeader(), (0, import_vue.createVNode)(import_TabsContent.default, {
387
+ "ref": contentRef,
388
+ "count": children.length,
389
+ "inited": state.inited,
390
+ "animated": props.animated,
391
+ "duration": props.duration,
392
+ "swipeable": props.swipeable,
393
+ "lazyRender": props.lazyRender,
394
+ "currentIndex": state.currentIndex,
395
+ "onChange": setCurrentIndex
396
+ }, {
397
+ default: () => {
398
+ var _a2;
399
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
400
+ }
401
+ })]);
399
402
  }
400
403
  });
@@ -25,6 +25,7 @@ __export(stdin_exports, {
25
25
  toArray: () => toArray
26
26
  });
27
27
  module.exports = __toCommonJS(stdin_exports);
28
+ var import_validate = require("./validate");
28
29
  function noop() {
29
30
  }
30
31
  const extend = Object.assign;
@@ -34,7 +35,7 @@ function get(object, path) {
34
35
  let result = object;
35
36
  keys.forEach((key) => {
36
37
  var _a;
37
- result = (_a = result[key]) != null ? _a : "";
38
+ result = (0, import_validate.isObject)(result) ? (_a = result[key]) != null ? _a : "" : "";
38
39
  });
39
40
  return result;
40
41
  }
package/lib/vant.cjs.js CHANGED
@@ -3,6 +3,17 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const use = require("@vant/use");
4
4
  const vue = require("vue");
5
5
  const popperjs = require("@vant/popperjs");
6
+ const isDef = (val) => val !== void 0 && val !== null;
7
+ const isFunction = (val) => typeof val === "function";
8
+ const isObject = (val) => val !== null && typeof val === "object";
9
+ const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
10
+ const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
11
+ function isMobile(value) {
12
+ value = value.replace(/[^-|\d]/g, "");
13
+ return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
14
+ }
15
+ const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
16
+ const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
6
17
  function noop() {
7
18
  }
8
19
  const extend = Object.assign;
@@ -12,7 +23,7 @@ function get(object, path) {
12
23
  let result = object;
13
24
  keys.forEach((key) => {
14
25
  var _a;
15
- result = (_a = result[key]) != null ? _a : "";
26
+ result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
16
27
  });
17
28
  return result;
18
29
  }
@@ -51,17 +62,6 @@ const makeStringProp = (defaultVal) => ({
51
62
  type: String,
52
63
  default: defaultVal
53
64
  });
54
- const isDef = (val) => val !== void 0 && val !== null;
55
- const isFunction = (val) => typeof val === "function";
56
- const isObject = (val) => val !== null && typeof val === "object";
57
- const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
58
- const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
59
- function isMobile(value) {
60
- value = value.replace(/[^-|\d]/g, "");
61
- return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
62
- }
63
- const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
64
- const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
65
65
  function getScrollTop(el) {
66
66
  const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
67
67
  return Math.max(top, 0);
@@ -5126,6 +5126,7 @@ const imageProps = {
5126
5126
  fit: String,
5127
5127
  position: String,
5128
5128
  round: Boolean,
5129
+ block: Boolean,
5129
5130
  width: numericProp,
5130
5131
  height: numericProp,
5131
5132
  radius: numericProp,
@@ -5254,7 +5255,8 @@ var stdin_default$17 = vue.defineComponent({
5254
5255
  var _a;
5255
5256
  return vue.createVNode("div", {
5256
5257
  "class": bem$10({
5257
- round: props.round
5258
+ round: props.round,
5259
+ block: props.block
5258
5260
  }),
5259
5261
  "style": style.value
5260
5262
  }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
@@ -6174,7 +6176,7 @@ var stdin_default$11 = vue.defineComponent({
6174
6176
  index += diff;
6175
6177
  }
6176
6178
  };
6177
- const setCurrentIndex = (currentIndex) => {
6179
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
6178
6180
  const newIndex = findAvailableTab(currentIndex);
6179
6181
  if (!isDef(newIndex)) {
6180
6182
  return;
@@ -6182,18 +6184,27 @@ var stdin_default$11 = vue.defineComponent({
6182
6184
  const newTab = children[newIndex];
6183
6185
  const newName = getTabName(newTab, newIndex);
6184
6186
  const shouldEmitChange = state.currentIndex !== null;
6185
- state.currentIndex = newIndex;
6187
+ if (state.currentIndex !== newIndex) {
6188
+ state.currentIndex = newIndex;
6189
+ if (!skipScrollIntoView) {
6190
+ scrollIntoView();
6191
+ }
6192
+ setLine();
6193
+ }
6186
6194
  if (newName !== props.active) {
6187
6195
  emit("update:active", newName);
6188
6196
  if (shouldEmitChange) {
6189
6197
  emit("change", newName, newTab.title);
6190
6198
  }
6191
6199
  }
6200
+ if (stickyFixed && !props.scrollspy) {
6201
+ setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6202
+ }
6192
6203
  };
6193
- const setCurrentIndexByName = (name2) => {
6204
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
6194
6205
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
6195
6206
  const index = matched ? children.indexOf(matched) : 0;
6196
- setCurrentIndex(index);
6207
+ setCurrentIndex(index, skipScrollIntoView);
6197
6208
  };
6198
6209
  const scrollToCurrentContent = (immediate = false) => {
6199
6210
  if (props.scrollspy) {
@@ -6287,13 +6298,14 @@ var stdin_default$11 = vue.defineComponent({
6287
6298
  }
6288
6299
  };
6289
6300
  const renderHeader = () => {
6290
- var _a2, _b2;
6301
+ var _a2, _b2, _c;
6291
6302
  const {
6292
6303
  type,
6293
- border
6304
+ border,
6305
+ sticky
6294
6306
  } = props;
6295
- return vue.createVNode("div", {
6296
- "ref": wrapRef,
6307
+ const Header = [vue.createVNode("div", {
6308
+ "ref": sticky ? void 0 : wrapRef,
6297
6309
  "class": [bem$W("wrap"), {
6298
6310
  [BORDER_TOP_BOTTOM]: type === "line" && border
6299
6311
  }]
@@ -6306,7 +6318,13 @@ var stdin_default$11 = vue.defineComponent({
6306
6318
  }]),
6307
6319
  "style": navStyle.value,
6308
6320
  "aria-orientation": "horizontal"
6309
- }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]);
6321
+ }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
6322
+ if (sticky) {
6323
+ return vue.createVNode("div", {
6324
+ "ref": wrapRef
6325
+ }, [Header]);
6326
+ }
6327
+ return Header;
6310
6328
  };
6311
6329
  vue.watch([() => props.color, windowWidth], setLine);
6312
6330
  vue.watch(() => props.active, (value) => {
@@ -6323,15 +6341,8 @@ var stdin_default$11 = vue.defineComponent({
6323
6341
  });
6324
6342
  }
6325
6343
  });
6326
- vue.watch(() => state.currentIndex, () => {
6327
- scrollIntoView();
6328
- setLine();
6329
- if (stickyFixed && !props.scrollspy) {
6330
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6331
- }
6332
- });
6333
6344
  const init = () => {
6334
- setCurrentIndexByName(props.active);
6345
+ setCurrentIndexByName(props.active, true);
6335
6346
  vue.nextTick(() => {
6336
6347
  state.inited = true;
6337
6348
  if (wrapRef.value) {
@@ -6367,37 +6378,31 @@ var stdin_default$11 = vue.defineComponent({
6367
6378
  currentName,
6368
6379
  scrollIntoView
6369
6380
  });
6370
- return () => {
6371
- var _a2;
6372
- return vue.createVNode("div", {
6373
- "ref": root,
6374
- "class": bem$W([props.type])
6375
- }, [props.sticky ? vue.createVNode(Sticky, {
6376
- "container": root.value,
6377
- "offsetTop": offsetTopPx.value,
6378
- "onScroll": onStickyScroll
6379
- }, {
6380
- default: () => {
6381
- var _a3;
6382
- return [renderHeader(), (_a3 = slots["nav-bottom"]) == null ? void 0 : _a3.call(slots)];
6383
- }
6384
- }) : [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)], vue.createVNode(stdin_default$12, {
6385
- "ref": contentRef,
6386
- "count": children.length,
6387
- "inited": state.inited,
6388
- "animated": props.animated,
6389
- "duration": props.duration,
6390
- "swipeable": props.swipeable,
6391
- "lazyRender": props.lazyRender,
6392
- "currentIndex": state.currentIndex,
6393
- "onChange": setCurrentIndex
6394
- }, {
6395
- default: () => {
6396
- var _a3;
6397
- return [(_a3 = slots.default) == null ? void 0 : _a3.call(slots)];
6398
- }
6399
- })]);
6400
- };
6381
+ return () => vue.createVNode("div", {
6382
+ "ref": root,
6383
+ "class": bem$W([props.type])
6384
+ }, [props.sticky ? vue.createVNode(Sticky, {
6385
+ "container": root.value,
6386
+ "offsetTop": offsetTopPx.value,
6387
+ "onScroll": onStickyScroll
6388
+ }, {
6389
+ default: () => [renderHeader()]
6390
+ }) : renderHeader(), vue.createVNode(stdin_default$12, {
6391
+ "ref": contentRef,
6392
+ "count": children.length,
6393
+ "inited": state.inited,
6394
+ "animated": props.animated,
6395
+ "duration": props.duration,
6396
+ "swipeable": props.swipeable,
6397
+ "lazyRender": props.lazyRender,
6398
+ "currentIndex": state.currentIndex,
6399
+ "onChange": setCurrentIndex
6400
+ }, {
6401
+ default: () => {
6402
+ var _a2;
6403
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
6404
+ }
6405
+ })]);
6401
6406
  }
6402
6407
  });
6403
6408
  const TAB_STATUS_KEY = Symbol();
@@ -6524,6 +6529,16 @@ var stdin_default$$ = vue.defineComponent({
6524
6529
  }
6525
6530
  return isActive;
6526
6531
  });
6532
+ const hasInactiveClass = vue.ref(!active.value);
6533
+ vue.watch(active, (val) => {
6534
+ if (val) {
6535
+ hasInactiveClass.value = false;
6536
+ } else {
6537
+ use.doubleRaf(() => {
6538
+ hasInactiveClass.value = true;
6539
+ });
6540
+ }
6541
+ });
6527
6542
  vue.watch(() => props.title, () => {
6528
6543
  parent.setLine();
6529
6544
  parent.scrollIntoView();
@@ -6547,7 +6562,7 @@ var stdin_default$$ = vue.defineComponent({
6547
6562
  "id": id,
6548
6563
  "role": "tabpanel",
6549
6564
  "class": bem$U("panel-wrapper", {
6550
- inactive: !active.value
6565
+ inactive: hasInactiveClass.value
6551
6566
  }),
6552
6567
  "tabindex": active.value ? 0 : -1,
6553
6568
  "aria-hidden": !active.value,
@@ -14933,7 +14948,7 @@ const Lazyload = {
14933
14948
  });
14934
14949
  }
14935
14950
  };
14936
- const version = "3.6.2";
14951
+ const version = "3.6.4";
14937
14952
  function install(app) {
14938
14953
  const components = [
14939
14954
  ActionBar,