vant 4.6.0 → 4.6.1

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.js CHANGED
@@ -502,7 +502,7 @@
502
502
  const parentHidden = el.offsetParent === null && style.position !== "fixed";
503
503
  return hidden || parentHidden;
504
504
  }
505
- const { width: windowWidth, height: windowHeight$1 } = useWindowSize();
505
+ const { width: windowWidth, height: windowHeight } = useWindowSize();
506
506
  function addUnit(value) {
507
507
  if (isDef(value)) {
508
508
  return isNumeric(value) ? `${value}px` : String(value);
@@ -550,7 +550,7 @@
550
550
  }
551
551
  function convertVh(value) {
552
552
  value = value.replace(/vh/g, "");
553
- return +value * windowHeight$1.value / 100;
553
+ return +value * windowHeight.value / 100;
554
554
  }
555
555
  function unitToPx(value) {
556
556
  if (typeof value === "number") {
@@ -826,7 +826,7 @@
826
826
  }
827
827
  });
828
828
  onPopupReopen(() => vue.nextTick(setHeight));
829
- vue.watch([windowWidth, windowHeight$1], setHeight);
829
+ vue.watch([windowWidth, windowHeight], setHeight);
830
830
  return height2;
831
831
  };
832
832
  function usePlaceholder(contentRef, bem2) {
@@ -2509,7 +2509,7 @@
2509
2509
  passive: true
2510
2510
  });
2511
2511
  useVisibilityChange(root, onScroll);
2512
- vue.watch([windowWidth, windowHeight$1], () => {
2512
+ vue.watch([windowWidth, windowHeight], () => {
2513
2513
  if (!root.value || isHidden(root) || !state.fixed) {
2514
2514
  return;
2515
2515
  }
@@ -2867,7 +2867,7 @@
2867
2867
  vue.watch(() => props2.initialSwipe, (value) => initialize(+value));
2868
2868
  vue.watch(count, () => initialize(state.active));
2869
2869
  vue.watch(() => props2.autoplay, autoplay);
2870
- vue.watch([windowWidth, windowHeight$1, () => props2.width, () => props2.height], resize);
2870
+ vue.watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
2871
2871
  vue.watch(usePageVisibility(), (visible) => {
2872
2872
  if (visible === "visible") {
2873
2873
  autoplay();
@@ -7930,7 +7930,7 @@
7930
7930
  const CheckboxGroup = withInstall(stdin_default$19);
7931
7931
  const [name$_, bem$Z] = createNamespace("circle");
7932
7932
  let uid = 0;
7933
- const format$1 = (rate) => Math.min(Math.max(+rate, 0), 100);
7933
+ const format = (rate) => Math.min(Math.max(+rate, 0), 100);
7934
7934
  function getPath(clockwise, viewBoxSize) {
7935
7935
  const sweepFlag = clockwise ? 1 : 0;
7936
7936
  return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
@@ -7978,13 +7978,13 @@
7978
7978
  let rafId;
7979
7979
  const startTime = Date.now();
7980
7980
  const startRate = props2.currentRate;
7981
- const endRate = format$1(rate);
7981
+ const endRate = format(rate);
7982
7982
  const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
7983
7983
  const animate = () => {
7984
7984
  const now = Date.now();
7985
7985
  const progress = Math.min((now - startTime) / duration, 1);
7986
7986
  const rate2 = progress * (endRate - startRate) + startRate;
7987
- emit("update:currentRate", format$1(parseFloat(rate2.toFixed(1))));
7987
+ emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
7988
7988
  if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
7989
7989
  rafId = raf(animate);
7990
7990
  }
@@ -9210,7 +9210,7 @@
9210
9210
  const TABS_HEIGHT = 44;
9211
9211
  const rootHeight = useRect(root).height;
9212
9212
  const headerHeight = useRect(barRef).height + TABS_HEIGHT;
9213
- listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight$1.value) - headerHeight;
9213
+ listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
9214
9214
  };
9215
9215
  const onExchange = () => {
9216
9216
  emit("exchange", currentCode.value);
@@ -9314,7 +9314,7 @@
9314
9314
  vue.watch(() => props2.code, (value) => {
9315
9315
  currentCode.value = value;
9316
9316
  });
9317
- vue.watch(windowHeight$1, updateListHeight);
9317
+ vue.watch(windowHeight, updateListHeight);
9318
9318
  vue.watch(currentCode, (value) => emit("update:code", value));
9319
9319
  vue.watch(() => props2.displayedCouponIndex, scrollToCoupon);
9320
9320
  vue.onMounted(() => {
@@ -9812,7 +9812,7 @@
9812
9812
  if (props2.direction === "down") {
9813
9813
  offset2.value = rect.bottom;
9814
9814
  } else {
9815
- offset2.value = windowHeight$1.value - rect.top;
9815
+ offset2.value = windowHeight.value - rect.top;
9816
9816
  }
9817
9817
  }
9818
9818
  };
@@ -10101,7 +10101,7 @@
10101
10101
  const boundary = vue.computed(() => ({
10102
10102
  top: props2.gap,
10103
10103
  right: windowWidth.value - state.value.height - props2.gap,
10104
- bottom: windowHeight$1.value - state.value.width - props2.gap,
10104
+ bottom: windowHeight.value - state.value.width - props2.gap,
10105
10105
  left: props2.gap
10106
10106
  }));
10107
10107
  const dragging = vue.ref(false);
@@ -10126,7 +10126,7 @@
10126
10126
  } = props2;
10127
10127
  state.value = {
10128
10128
  x: offset2.x > -1 ? offset2.x : windowWidth.value - width2 - props2.gap,
10129
- y: offset2.y > -1 ? offset2.y : windowHeight$1.value - height2 - props2.gap,
10129
+ y: offset2.y > -1 ? offset2.y : windowHeight.value - height2 - props2.gap,
10130
10130
  width: width2,
10131
10131
  height: height2
10132
10132
  };
@@ -10199,7 +10199,7 @@
10199
10199
  initialized = true;
10200
10200
  });
10201
10201
  });
10202
- vue.watch([windowWidth, windowHeight$1, () => props2.gap, () => props2.offset], () => updateState(), {
10202
+ vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], () => updateState(), {
10203
10203
  deep: true
10204
10204
  });
10205
10205
  const show = vue.ref(true);
@@ -10233,9 +10233,6 @@
10233
10233
  }
10234
10234
  });
10235
10235
  const FloatingBubble = withInstall(stdin_default$R);
10236
- const {
10237
- height: windowHeight
10238
- } = useWindowSize();
10239
10236
  const floatingPanelProps = {
10240
10237
  height: makeNumericProp(0),
10241
10238
  anchors: makeArrayProp(),
@@ -10960,7 +10957,7 @@
10960
10957
  swipeTo
10961
10958
  });
10962
10959
  vue.onMounted(resize);
10963
- vue.watch([windowWidth, windowHeight$1], resize);
10960
+ vue.watch([windowWidth, windowHeight], resize);
10964
10961
  vue.watch(() => props2.startPosition, (value) => setActive(+value));
10965
10962
  vue.watch(() => props2.show, (value) => {
10966
10963
  const {
@@ -12370,7 +12367,7 @@
12370
12367
  var round = Math.round;
12371
12368
  function getUAString() {
12372
12369
  var uaData = navigator.userAgentData;
12373
- if (uaData != null && uaData.brands) {
12370
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
12374
12371
  return uaData.brands.map(function(item) {
12375
12372
  return item.brand + "/" + item.version;
12376
12373
  }).join(" ");
@@ -12664,89 +12661,6 @@
12664
12661
  return pending;
12665
12662
  };
12666
12663
  }
12667
- function format(str) {
12668
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12669
- args[_key - 1] = arguments[_key];
12670
- }
12671
- return [].concat(args).reduce(function(p, c) {
12672
- return p.replace(/%s/, c);
12673
- }, str);
12674
- }
12675
- var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
12676
- var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
12677
- var VALID_PROPERTIES = ["name", "enabled", "phase", "fn", "effect", "requires", "options"];
12678
- function validateModifiers(modifiers) {
12679
- modifiers.forEach(function(modifier) {
12680
- [].concat(Object.keys(modifier), VALID_PROPERTIES).filter(function(value, index, self2) {
12681
- return self2.indexOf(value) === index;
12682
- }).forEach(function(key) {
12683
- switch (key) {
12684
- case "name":
12685
- if (typeof modifier.name !== "string") {
12686
- console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', '"' + String(modifier.name) + '"'));
12687
- }
12688
- break;
12689
- case "enabled":
12690
- if (typeof modifier.enabled !== "boolean") {
12691
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', '"' + String(modifier.enabled) + '"'));
12692
- }
12693
- break;
12694
- case "phase":
12695
- if (modifierPhases.indexOf(modifier.phase) < 0) {
12696
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(", "), '"' + String(modifier.phase) + '"'));
12697
- }
12698
- break;
12699
- case "fn":
12700
- if (typeof modifier.fn !== "function") {
12701
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', '"' + String(modifier.fn) + '"'));
12702
- }
12703
- break;
12704
- case "effect":
12705
- if (modifier.effect != null && typeof modifier.effect !== "function") {
12706
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', '"' + String(modifier.fn) + '"'));
12707
- }
12708
- break;
12709
- case "requires":
12710
- if (modifier.requires != null && !Array.isArray(modifier.requires)) {
12711
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', '"' + String(modifier.requires) + '"'));
12712
- }
12713
- break;
12714
- case "requiresIfExists":
12715
- if (!Array.isArray(modifier.requiresIfExists)) {
12716
- console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', '"' + String(modifier.requiresIfExists) + '"'));
12717
- }
12718
- break;
12719
- case "options":
12720
- case "data":
12721
- break;
12722
- default:
12723
- console.error('PopperJS: an invalid property has been provided to the "' + modifier.name + '" modifier, valid properties are ' + VALID_PROPERTIES.map(function(s) {
12724
- return '"' + s + '"';
12725
- }).join(", ") + '; but "' + key + '" was provided.');
12726
- }
12727
- modifier.requires && modifier.requires.forEach(function(requirement) {
12728
- if (modifiers.find(function(mod) {
12729
- return mod.name === requirement;
12730
- }) == null) {
12731
- console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
12732
- }
12733
- });
12734
- });
12735
- });
12736
- }
12737
- function uniqueBy(arr, fn2) {
12738
- var identifiers = /* @__PURE__ */ new Set();
12739
- return arr.filter(function(item) {
12740
- var identifier = fn2(item);
12741
- if (!identifiers.has(identifier)) {
12742
- identifiers.add(identifier);
12743
- return true;
12744
- }
12745
- });
12746
- }
12747
- function getBasePlacement(placement) {
12748
- return placement.split("-")[0];
12749
- }
12750
12664
  function mergeByName(modifiers) {
12751
12665
  var merged = modifiers.reduce(function(merged2, current2) {
12752
12666
  var existing = merged2[current2.name];
@@ -12760,6 +12674,9 @@
12760
12674
  return merged[key];
12761
12675
  });
12762
12676
  }
12677
+ function getBasePlacement(placement) {
12678
+ return placement.split("-")[0];
12679
+ }
12763
12680
  function getVariation(placement) {
12764
12681
  return placement.split("-")[1];
12765
12682
  }
@@ -12818,8 +12735,6 @@
12818
12735
  }
12819
12736
  return offsets;
12820
12737
  }
12821
- var INVALID_ELEMENT_ERROR = "Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.";
12822
- var INFINITE_LOOP_ERROR = "Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.";
12823
12738
  var DEFAULT_OPTIONS = {
12824
12739
  placement: "bottom",
12825
12740
  modifiers: [],
@@ -12870,28 +12785,6 @@
12870
12785
  state.orderedModifiers = orderedModifiers.filter(function(m) {
12871
12786
  return m.enabled;
12872
12787
  });
12873
- {
12874
- var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function(_ref) {
12875
- var name2 = _ref.name;
12876
- return name2;
12877
- });
12878
- validateModifiers(modifiers);
12879
- if (getBasePlacement(state.options.placement) === auto) {
12880
- var flipModifier = state.orderedModifiers.find(function(_ref2) {
12881
- var name2 = _ref2.name;
12882
- return name2 === "flip";
12883
- });
12884
- if (!flipModifier) {
12885
- console.error(['Popper: "auto" placements require the "flip" modifier be', "present and enabled to work."].join(" "));
12886
- }
12887
- }
12888
- var _getComputedStyle = getComputedStyle(popper), marginTop = _getComputedStyle.marginTop, marginRight = _getComputedStyle.marginRight, marginBottom = _getComputedStyle.marginBottom, marginLeft = _getComputedStyle.marginLeft;
12889
- if ([marginTop, marginRight, marginBottom, marginLeft].some(function(margin) {
12890
- return parseFloat(margin);
12891
- })) {
12892
- console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', "between the popper and its reference element or boundary.", "To replicate margin, use the `offset` modifier, as well as", "the `padding` option in the `preventOverflow` and `flip`", "modifiers."].join(" "));
12893
- }
12894
- }
12895
12788
  runModifierEffects();
12896
12789
  return instance2.update();
12897
12790
  },
@@ -12906,9 +12799,6 @@
12906
12799
  }
12907
12800
  var _state$elements = state.elements, reference2 = _state$elements.reference, popper2 = _state$elements.popper;
12908
12801
  if (!areValidElements(reference2, popper2)) {
12909
- {
12910
- console.error(INVALID_ELEMENT_ERROR);
12911
- }
12912
12802
  return;
12913
12803
  }
12914
12804
  state.rects = {
@@ -12920,15 +12810,7 @@
12920
12810
  state.orderedModifiers.forEach(function(modifier) {
12921
12811
  return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
12922
12812
  });
12923
- var __debug_loops__ = 0;
12924
12813
  for (var index = 0; index < state.orderedModifiers.length; index++) {
12925
- {
12926
- __debug_loops__ += 1;
12927
- if (__debug_loops__ > 100) {
12928
- console.error(INFINITE_LOOP_ERROR);
12929
- break;
12930
- }
12931
- }
12932
12814
  if (state.reset === true) {
12933
12815
  state.reset = false;
12934
12816
  index = -1;
@@ -12959,9 +12841,6 @@
12959
12841
  }
12960
12842
  };
12961
12843
  if (!areValidElements(reference, popper)) {
12962
- {
12963
- console.error(INVALID_ELEMENT_ERROR);
12964
- }
12965
12844
  return instance2;
12966
12845
  }
12967
12846
  instance2.setOptions(options).then(function(state2) {
@@ -12970,8 +12849,8 @@
12970
12849
  }
12971
12850
  });
12972
12851
  function runModifierEffects() {
12973
- state.orderedModifiers.forEach(function(_ref3) {
12974
- var name2 = _ref3.name, _ref3$options = _ref3.options, options2 = _ref3$options === void 0 ? {} : _ref3$options, effect3 = _ref3.effect;
12852
+ state.orderedModifiers.forEach(function(_ref) {
12853
+ var name2 = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect3 = _ref.effect;
12975
12854
  if (typeof effect3 === "function") {
12976
12855
  var cleanupFn = effect3({
12977
12856
  state,
@@ -13052,9 +12931,8 @@
13052
12931
  bottom: "auto",
13053
12932
  left: "auto"
13054
12933
  };
13055
- function roundOffsetsByDPR(_ref) {
12934
+ function roundOffsetsByDPR(_ref, win) {
13056
12935
  var x = _ref.x, y = _ref.y;
13057
- var win = window;
13058
12936
  var dpr = win.devicePixelRatio || 1;
13059
12937
  return {
13060
12938
  x: round(x * dpr) / dpr || 0,
@@ -13116,7 +12994,7 @@
13116
12994
  var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
13117
12995
  x,
13118
12996
  y
13119
- }) : {
12997
+ }, getWindow(popper)) : {
13120
12998
  x,
13121
12999
  y
13122
13000
  };
@@ -13131,14 +13009,6 @@
13131
13009
  function computeStyles(_ref5) {
13132
13010
  var state = _ref5.state, options = _ref5.options;
13133
13011
  var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
13134
- {
13135
- var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || "";
13136
- if (adaptive && ["transform", "top", "right", "bottom", "left"].some(function(property) {
13137
- return transitionProperty.indexOf(property) >= 0;
13138
- })) {
13139
- console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', "\n\n", 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", "\n\n", "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" "));
13140
- }
13141
- }
13142
13012
  var commonStyles = {
13143
13013
  placement: getBasePlacement(state.placement),
13144
13014
  variation: getVariation(state.placement),
@@ -16350,7 +16220,7 @@
16350
16220
  if (isImageFile(item)) {
16351
16221
  return vue.createVNode(Image$1, {
16352
16222
  "fit": imageFit,
16353
- "src": item.content || item.url,
16223
+ "src": item.objectUrl || item.content || item.url,
16354
16224
  "class": bem$1("preview-image"),
16355
16225
  "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
16356
16226
  "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
@@ -16468,7 +16338,8 @@
16468
16338
  const result = {
16469
16339
  file,
16470
16340
  status: "",
16471
- message: ""
16341
+ message: "",
16342
+ objectUrl: URL.createObjectURL(file)
16472
16343
  };
16473
16344
  if (contents[index]) {
16474
16345
  result.content = contents[index];
@@ -16482,7 +16353,8 @@
16482
16353
  const result = {
16483
16354
  file: files,
16484
16355
  status: "",
16485
- message: ""
16356
+ message: "",
16357
+ objectUrl: URL.createObjectURL(files)
16486
16358
  };
16487
16359
  if (content) {
16488
16360
  result.content = content;
@@ -16524,8 +16396,8 @@
16524
16396
  if (props2.previewFullImage) {
16525
16397
  const imageFiles = props2.modelValue.filter(isImageFile);
16526
16398
  const images = imageFiles.map((item2) => {
16527
- if (item2.file && !item2.url && item2.status !== "failed") {
16528
- item2.url = URL.createObjectURL(item2.file);
16399
+ if (item2.objectUrl && !item2.url && item2.status !== "failed") {
16400
+ item2.url = item2.objectUrl;
16529
16401
  urls.push(item2.url);
16530
16402
  }
16531
16403
  return item2.url;
@@ -17612,7 +17484,7 @@
17612
17484
  });
17613
17485
  }
17614
17486
  };
17615
- const version = "4.6.0";
17487
+ const version = "4.6.1";
17616
17488
  function install(app) {
17617
17489
  const components = [
17618
17490
  ActionBar,