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/vant.es.js CHANGED
@@ -1,6 +1,17 @@
1
1
  import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, useToggle, raf, useScrollParent, usePageVisibility, doubleRaf, cancelRaf, useCountDown, useClickAway, inBrowser as inBrowser$1 } from "@vant/use";
2
2
  import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, provide, watchEffect, mergeProps, onDeactivated, onBeforeUnmount, Transition, withDirectives, vShow, onActivated, Teleport, Fragment, createTextVNode, createApp, onUnmounted, onBeforeUpdate, resolveDirective, withKeys, onUpdated, h } from "vue";
3
3
  import { offsetModifier, createPopper } from "@vant/popperjs";
4
+ const isDef = (val) => val !== void 0 && val !== null;
5
+ const isFunction = (val) => typeof val === "function";
6
+ const isObject = (val) => val !== null && typeof val === "object";
7
+ const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
8
+ const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
9
+ function isMobile(value) {
10
+ value = value.replace(/[^-|\d]/g, "");
11
+ return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
12
+ }
13
+ const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
14
+ const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
4
15
  function noop() {
5
16
  }
6
17
  const extend = Object.assign;
@@ -10,7 +21,7 @@ function get(object, path) {
10
21
  let result = object;
11
22
  keys.forEach((key) => {
12
23
  var _a;
13
- result = (_a = result[key]) != null ? _a : "";
24
+ result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
14
25
  });
15
26
  return result;
16
27
  }
@@ -49,17 +60,6 @@ const makeStringProp = (defaultVal) => ({
49
60
  type: String,
50
61
  default: defaultVal
51
62
  });
52
- const isDef = (val) => val !== void 0 && val !== null;
53
- const isFunction = (val) => typeof val === "function";
54
- const isObject = (val) => val !== null && typeof val === "object";
55
- const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
56
- const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
57
- function isMobile(value) {
58
- value = value.replace(/[^-|\d]/g, "");
59
- return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
60
- }
61
- const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
62
- const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
63
63
  function getScrollTop(el) {
64
64
  const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
65
65
  return Math.max(top, 0);
@@ -5124,6 +5124,7 @@ const imageProps = {
5124
5124
  fit: String,
5125
5125
  position: String,
5126
5126
  round: Boolean,
5127
+ block: Boolean,
5127
5128
  width: numericProp,
5128
5129
  height: numericProp,
5129
5130
  radius: numericProp,
@@ -5252,7 +5253,8 @@ var stdin_default$17 = defineComponent({
5252
5253
  var _a;
5253
5254
  return createVNode("div", {
5254
5255
  "class": bem$10({
5255
- round: props.round
5256
+ round: props.round,
5257
+ block: props.block
5256
5258
  }),
5257
5259
  "style": style.value
5258
5260
  }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
@@ -6172,7 +6174,7 @@ var stdin_default$11 = defineComponent({
6172
6174
  index += diff;
6173
6175
  }
6174
6176
  };
6175
- const setCurrentIndex = (currentIndex) => {
6177
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
6176
6178
  const newIndex = findAvailableTab(currentIndex);
6177
6179
  if (!isDef(newIndex)) {
6178
6180
  return;
@@ -6180,18 +6182,27 @@ var stdin_default$11 = defineComponent({
6180
6182
  const newTab = children[newIndex];
6181
6183
  const newName = getTabName(newTab, newIndex);
6182
6184
  const shouldEmitChange = state.currentIndex !== null;
6183
- state.currentIndex = newIndex;
6185
+ if (state.currentIndex !== newIndex) {
6186
+ state.currentIndex = newIndex;
6187
+ if (!skipScrollIntoView) {
6188
+ scrollIntoView();
6189
+ }
6190
+ setLine();
6191
+ }
6184
6192
  if (newName !== props.active) {
6185
6193
  emit("update:active", newName);
6186
6194
  if (shouldEmitChange) {
6187
6195
  emit("change", newName, newTab.title);
6188
6196
  }
6189
6197
  }
6198
+ if (stickyFixed && !props.scrollspy) {
6199
+ setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6200
+ }
6190
6201
  };
6191
- const setCurrentIndexByName = (name2) => {
6202
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
6192
6203
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
6193
6204
  const index = matched ? children.indexOf(matched) : 0;
6194
- setCurrentIndex(index);
6205
+ setCurrentIndex(index, skipScrollIntoView);
6195
6206
  };
6196
6207
  const scrollToCurrentContent = (immediate = false) => {
6197
6208
  if (props.scrollspy) {
@@ -6285,13 +6296,14 @@ var stdin_default$11 = defineComponent({
6285
6296
  }
6286
6297
  };
6287
6298
  const renderHeader = () => {
6288
- var _a2, _b2;
6299
+ var _a2, _b2, _c;
6289
6300
  const {
6290
6301
  type,
6291
- border
6302
+ border,
6303
+ sticky
6292
6304
  } = props;
6293
- return createVNode("div", {
6294
- "ref": wrapRef,
6305
+ const Header = [createVNode("div", {
6306
+ "ref": sticky ? void 0 : wrapRef,
6295
6307
  "class": [bem$W("wrap"), {
6296
6308
  [BORDER_TOP_BOTTOM]: type === "line" && border
6297
6309
  }]
@@ -6304,7 +6316,13 @@ var stdin_default$11 = defineComponent({
6304
6316
  }]),
6305
6317
  "style": navStyle.value,
6306
6318
  "aria-orientation": "horizontal"
6307
- }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]);
6319
+ }, [(_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)];
6320
+ if (sticky) {
6321
+ return createVNode("div", {
6322
+ "ref": wrapRef
6323
+ }, [Header]);
6324
+ }
6325
+ return Header;
6308
6326
  };
6309
6327
  watch([() => props.color, windowWidth], setLine);
6310
6328
  watch(() => props.active, (value) => {
@@ -6321,15 +6339,8 @@ var stdin_default$11 = defineComponent({
6321
6339
  });
6322
6340
  }
6323
6341
  });
6324
- watch(() => state.currentIndex, () => {
6325
- scrollIntoView();
6326
- setLine();
6327
- if (stickyFixed && !props.scrollspy) {
6328
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6329
- }
6330
- });
6331
6342
  const init = () => {
6332
- setCurrentIndexByName(props.active);
6343
+ setCurrentIndexByName(props.active, true);
6333
6344
  nextTick(() => {
6334
6345
  state.inited = true;
6335
6346
  if (wrapRef.value) {
@@ -6365,37 +6376,31 @@ var stdin_default$11 = defineComponent({
6365
6376
  currentName,
6366
6377
  scrollIntoView
6367
6378
  });
6368
- return () => {
6369
- var _a2;
6370
- return createVNode("div", {
6371
- "ref": root,
6372
- "class": bem$W([props.type])
6373
- }, [props.sticky ? createVNode(Sticky, {
6374
- "container": root.value,
6375
- "offsetTop": offsetTopPx.value,
6376
- "onScroll": onStickyScroll
6377
- }, {
6378
- default: () => {
6379
- var _a3;
6380
- return [renderHeader(), (_a3 = slots["nav-bottom"]) == null ? void 0 : _a3.call(slots)];
6381
- }
6382
- }) : [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)], createVNode(stdin_default$12, {
6383
- "ref": contentRef,
6384
- "count": children.length,
6385
- "inited": state.inited,
6386
- "animated": props.animated,
6387
- "duration": props.duration,
6388
- "swipeable": props.swipeable,
6389
- "lazyRender": props.lazyRender,
6390
- "currentIndex": state.currentIndex,
6391
- "onChange": setCurrentIndex
6392
- }, {
6393
- default: () => {
6394
- var _a3;
6395
- return [(_a3 = slots.default) == null ? void 0 : _a3.call(slots)];
6396
- }
6397
- })]);
6398
- };
6379
+ return () => createVNode("div", {
6380
+ "ref": root,
6381
+ "class": bem$W([props.type])
6382
+ }, [props.sticky ? createVNode(Sticky, {
6383
+ "container": root.value,
6384
+ "offsetTop": offsetTopPx.value,
6385
+ "onScroll": onStickyScroll
6386
+ }, {
6387
+ default: () => [renderHeader()]
6388
+ }) : renderHeader(), createVNode(stdin_default$12, {
6389
+ "ref": contentRef,
6390
+ "count": children.length,
6391
+ "inited": state.inited,
6392
+ "animated": props.animated,
6393
+ "duration": props.duration,
6394
+ "swipeable": props.swipeable,
6395
+ "lazyRender": props.lazyRender,
6396
+ "currentIndex": state.currentIndex,
6397
+ "onChange": setCurrentIndex
6398
+ }, {
6399
+ default: () => {
6400
+ var _a2;
6401
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
6402
+ }
6403
+ })]);
6399
6404
  }
6400
6405
  });
6401
6406
  const TAB_STATUS_KEY = Symbol();
@@ -6522,6 +6527,16 @@ var stdin_default$$ = defineComponent({
6522
6527
  }
6523
6528
  return isActive;
6524
6529
  });
6530
+ const hasInactiveClass = ref(!active.value);
6531
+ watch(active, (val) => {
6532
+ if (val) {
6533
+ hasInactiveClass.value = false;
6534
+ } else {
6535
+ doubleRaf(() => {
6536
+ hasInactiveClass.value = true;
6537
+ });
6538
+ }
6539
+ });
6525
6540
  watch(() => props.title, () => {
6526
6541
  parent.setLine();
6527
6542
  parent.scrollIntoView();
@@ -6545,7 +6560,7 @@ var stdin_default$$ = defineComponent({
6545
6560
  "id": id,
6546
6561
  "role": "tabpanel",
6547
6562
  "class": bem$U("panel-wrapper", {
6548
- inactive: !active.value
6563
+ inactive: hasInactiveClass.value
6549
6564
  }),
6550
6565
  "tabindex": active.value ? 0 : -1,
6551
6566
  "aria-hidden": !active.value,
@@ -14931,7 +14946,7 @@ const Lazyload = {
14931
14946
  });
14932
14947
  }
14933
14948
  };
14934
- const version = "3.6.2";
14949
+ const version = "3.6.4";
14935
14950
  function install(app) {
14936
14951
  const components = [
14937
14952
  ActionBar,
package/lib/vant.js CHANGED
@@ -2,6 +2,17 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.vant = {}, global.Vue));
3
3
  })(this, function(exports2, vue) {
4
4
  "use strict";
5
+ const isDef = (val) => val !== void 0 && val !== null;
6
+ const isFunction = (val) => typeof val === "function";
7
+ const isObject = (val) => val !== null && typeof val === "object";
8
+ const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
9
+ const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
10
+ function isMobile(value) {
11
+ value = value.replace(/[^-|\d]/g, "");
12
+ return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
13
+ }
14
+ const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
15
+ const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
5
16
  function noop() {
6
17
  }
7
18
  const extend = Object.assign;
@@ -11,7 +22,7 @@
11
22
  let result = object;
12
23
  keys.forEach((key) => {
13
24
  var _a;
14
- result = (_a = result[key]) != null ? _a : "";
25
+ result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
15
26
  });
16
27
  return result;
17
28
  }
@@ -418,17 +429,6 @@
418
429
  });
419
430
  }
420
431
  }
421
- const isDef = (val) => val !== void 0 && val !== null;
422
- const isFunction = (val) => typeof val === "function";
423
- const isObject = (val) => val !== null && typeof val === "object";
424
- const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
425
- const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
426
- function isMobile(value) {
427
- value = value.replace(/[^-|\d]/g, "");
428
- return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
429
- }
430
- const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
431
- const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
432
432
  function getScrollTop(el) {
433
433
  const top2 = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
434
434
  return Math.max(top2, 0);
@@ -5482,6 +5482,7 @@
5482
5482
  fit: String,
5483
5483
  position: String,
5484
5484
  round: Boolean,
5485
+ block: Boolean,
5485
5486
  width: numericProp,
5486
5487
  height: numericProp,
5487
5488
  radius: numericProp,
@@ -5610,7 +5611,8 @@
5610
5611
  var _a;
5611
5612
  return vue.createVNode("div", {
5612
5613
  "class": bem$10({
5613
- round: props.round
5614
+ round: props.round,
5615
+ block: props.block
5614
5616
  }),
5615
5617
  "style": style.value
5616
5618
  }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
@@ -6520,7 +6522,7 @@
6520
6522
  index += diff;
6521
6523
  }
6522
6524
  };
6523
- const setCurrentIndex = (currentIndex) => {
6525
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
6524
6526
  const newIndex = findAvailableTab(currentIndex);
6525
6527
  if (!isDef(newIndex)) {
6526
6528
  return;
@@ -6528,18 +6530,27 @@
6528
6530
  const newTab = children[newIndex];
6529
6531
  const newName = getTabName(newTab, newIndex);
6530
6532
  const shouldEmitChange = state.currentIndex !== null;
6531
- state.currentIndex = newIndex;
6533
+ if (state.currentIndex !== newIndex) {
6534
+ state.currentIndex = newIndex;
6535
+ if (!skipScrollIntoView) {
6536
+ scrollIntoView();
6537
+ }
6538
+ setLine();
6539
+ }
6532
6540
  if (newName !== props.active) {
6533
6541
  emit("update:active", newName);
6534
6542
  if (shouldEmitChange) {
6535
6543
  emit("change", newName, newTab.title);
6536
6544
  }
6537
6545
  }
6546
+ if (stickyFixed && !props.scrollspy) {
6547
+ setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6548
+ }
6538
6549
  };
6539
- const setCurrentIndexByName = (name2) => {
6550
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
6540
6551
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
6541
6552
  const index = matched ? children.indexOf(matched) : 0;
6542
- setCurrentIndex(index);
6553
+ setCurrentIndex(index, skipScrollIntoView);
6543
6554
  };
6544
6555
  const scrollToCurrentContent = (immediate = false) => {
6545
6556
  if (props.scrollspy) {
@@ -6633,13 +6644,14 @@
6633
6644
  }
6634
6645
  };
6635
6646
  const renderHeader = () => {
6636
- var _a2, _b2;
6647
+ var _a2, _b2, _c;
6637
6648
  const {
6638
6649
  type,
6639
- border
6650
+ border,
6651
+ sticky
6640
6652
  } = props;
6641
- return vue.createVNode("div", {
6642
- "ref": wrapRef,
6653
+ const Header = [vue.createVNode("div", {
6654
+ "ref": sticky ? void 0 : wrapRef,
6643
6655
  "class": [bem$W("wrap"), {
6644
6656
  [BORDER_TOP_BOTTOM]: type === "line" && border
6645
6657
  }]
@@ -6652,7 +6664,13 @@
6652
6664
  }]),
6653
6665
  "style": navStyle.value,
6654
6666
  "aria-orientation": "horizontal"
6655
- }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]);
6667
+ }, [(_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)];
6668
+ if (sticky) {
6669
+ return vue.createVNode("div", {
6670
+ "ref": wrapRef
6671
+ }, [Header]);
6672
+ }
6673
+ return Header;
6656
6674
  };
6657
6675
  vue.watch([() => props.color, windowWidth], setLine);
6658
6676
  vue.watch(() => props.active, (value) => {
@@ -6669,15 +6687,8 @@
6669
6687
  });
6670
6688
  }
6671
6689
  });
6672
- vue.watch(() => state.currentIndex, () => {
6673
- scrollIntoView();
6674
- setLine();
6675
- if (stickyFixed && !props.scrollspy) {
6676
- setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
6677
- }
6678
- });
6679
6690
  const init = () => {
6680
- setCurrentIndexByName(props.active);
6691
+ setCurrentIndexByName(props.active, true);
6681
6692
  vue.nextTick(() => {
6682
6693
  state.inited = true;
6683
6694
  if (wrapRef.value) {
@@ -6713,37 +6724,31 @@
6713
6724
  currentName,
6714
6725
  scrollIntoView
6715
6726
  });
6716
- return () => {
6717
- var _a2;
6718
- return vue.createVNode("div", {
6719
- "ref": root,
6720
- "class": bem$W([props.type])
6721
- }, [props.sticky ? vue.createVNode(Sticky, {
6722
- "container": root.value,
6723
- "offsetTop": offsetTopPx.value,
6724
- "onScroll": onStickyScroll
6725
- }, {
6726
- default: () => {
6727
- var _a3;
6728
- return [renderHeader(), (_a3 = slots["nav-bottom"]) == null ? void 0 : _a3.call(slots)];
6729
- }
6730
- }) : [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)], vue.createVNode(stdin_default$12, {
6731
- "ref": contentRef,
6732
- "count": children.length,
6733
- "inited": state.inited,
6734
- "animated": props.animated,
6735
- "duration": props.duration,
6736
- "swipeable": props.swipeable,
6737
- "lazyRender": props.lazyRender,
6738
- "currentIndex": state.currentIndex,
6739
- "onChange": setCurrentIndex
6740
- }, {
6741
- default: () => {
6742
- var _a3;
6743
- return [(_a3 = slots.default) == null ? void 0 : _a3.call(slots)];
6744
- }
6745
- })]);
6746
- };
6727
+ return () => vue.createVNode("div", {
6728
+ "ref": root,
6729
+ "class": bem$W([props.type])
6730
+ }, [props.sticky ? vue.createVNode(Sticky, {
6731
+ "container": root.value,
6732
+ "offsetTop": offsetTopPx.value,
6733
+ "onScroll": onStickyScroll
6734
+ }, {
6735
+ default: () => [renderHeader()]
6736
+ }) : renderHeader(), vue.createVNode(stdin_default$12, {
6737
+ "ref": contentRef,
6738
+ "count": children.length,
6739
+ "inited": state.inited,
6740
+ "animated": props.animated,
6741
+ "duration": props.duration,
6742
+ "swipeable": props.swipeable,
6743
+ "lazyRender": props.lazyRender,
6744
+ "currentIndex": state.currentIndex,
6745
+ "onChange": setCurrentIndex
6746
+ }, {
6747
+ default: () => {
6748
+ var _a2;
6749
+ return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
6750
+ }
6751
+ })]);
6747
6752
  }
6748
6753
  });
6749
6754
  const TAB_STATUS_KEY = Symbol();
@@ -6864,6 +6869,16 @@
6864
6869
  }
6865
6870
  return isActive;
6866
6871
  });
6872
+ const hasInactiveClass = vue.ref(!active.value);
6873
+ vue.watch(active, (val) => {
6874
+ if (val) {
6875
+ hasInactiveClass.value = false;
6876
+ } else {
6877
+ doubleRaf(() => {
6878
+ hasInactiveClass.value = true;
6879
+ });
6880
+ }
6881
+ });
6867
6882
  vue.watch(() => props.title, () => {
6868
6883
  parent.setLine();
6869
6884
  parent.scrollIntoView();
@@ -6887,7 +6902,7 @@
6887
6902
  "id": id,
6888
6903
  "role": "tabpanel",
6889
6904
  "class": bem$U("panel-wrapper", {
6890
- inactive: !active.value
6905
+ inactive: hasInactiveClass.value
6891
6906
  }),
6892
6907
  "tabindex": active.value ? 0 : -1,
6893
6908
  "aria-hidden": !active.value,
@@ -16130,7 +16145,7 @@
16130
16145
  });
16131
16146
  }
16132
16147
  };
16133
- const version = "3.6.2";
16148
+ const version = "3.6.4";
16134
16149
  function install(app) {
16135
16150
  const components = [
16136
16151
  ActionBar,