react-vant-nova 1.1.8-test → 1.2.0-test

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.
@@ -1,9 +1,9 @@
1
- import React, { useRef, useEffect, useState, useMemo, useCallback, useContext, createContext, forwardRef, useImperativeHandle, memo, isValidElement, version, Children, cloneElement } from "react";
1
+ import React, { useRef, useEffect, useState, useMemo, useCallback, useContext, createContext, forwardRef, useImperativeHandle, memo, isValidElement, Children, cloneElement } from "react";
2
2
  import clsx from "clsx";
3
3
  import { ArrowLeft, ArrowUp, ArrowDown, Arrow, Cross, Clear, QuestionO, PhotoFail, Photo, Checked, Success, Search as Search$1, Star, StarO, Close, Description, Photograph, ExpandO } from "@react-vant/icons";
4
4
  import { CSSTransition } from "react-transition-group";
5
5
  import * as ReactDOM from "react-dom";
6
- import { createPortal, version as version$1 } from "react-dom";
6
+ import { createPortal } from "react-dom";
7
7
  import { createUseGesture, dragAction, pinchAction, useDrag } from "@use-gesture/react";
8
8
  import { useSpring, animated } from "@react-spring/web";
9
9
  import { createPopper, offsetModifier } from "@vant/popperjs";
@@ -2090,12 +2090,11 @@ function render(node, container) {
2090
2090
  function legacyUnmount(container) {
2091
2091
  return unmountComponentAtNode(container);
2092
2092
  }
2093
- async function concurrentUnmount(container) {
2094
- return Promise.resolve().then(() => {
2095
- var _a;
2096
- (_a = container[MARK]) == null ? void 0 : _a.unmount();
2097
- delete container[MARK];
2098
- });
2093
+ function concurrentUnmount(container) {
2094
+ var _a;
2095
+ (_a = container[MARK]) == null ? void 0 : _a.unmount();
2096
+ delete container[MARK];
2097
+ return true;
2099
2098
  }
2100
2099
  function unmount(container) {
2101
2100
  if (createRoot) {
@@ -5665,11 +5664,6 @@ const Toast$1 = (p) => {
5665
5664
  teleport: props.teleport
5666
5665
  }, renderIcon(), renderMessage());
5667
5666
  };
5668
- const reactVersion = Number((version || "").split(".")[0]);
5669
- Number((version$1 || "").split(".")[0]);
5670
- console.log("method.tsx loaded");
5671
- console.log("React version:", reactVersion);
5672
- console.log("canUseDom:", canUseDom());
5673
5667
  const defaultOptions = {
5674
5668
  message: "",
5675
5669
  className: "",
@@ -5694,65 +5688,63 @@ function nextTickClear() {
5694
5688
  setTimeout(syncClear);
5695
5689
  }
5696
5690
  const ToastObj = (p) => {
5697
- console.log("ToastObj called");
5698
- if (!canUseDom()) {
5699
- console.log("canUseDom returned false");
5691
+ if (!canUseDom())
5700
5692
  return null;
5701
- }
5702
5693
  const props = parseOptions(p);
5703
- console.log("props:", props);
5704
- const update = {
5705
- config: () => {
5694
+ const componentRef = {
5695
+ clear: () => {
5706
5696
  },
5707
- clear: () => null
5697
+ config: (nextState) => {
5698
+ }
5699
+ };
5700
+ const update = {
5701
+ config: (nextState) => componentRef.config(nextState),
5702
+ clear: () => {
5703
+ componentRef.clear();
5704
+ }
5708
5705
  };
5709
5706
  let timer = 0;
5710
5707
  const { onClose, teleport } = props;
5711
5708
  const container = document.createElement("div");
5712
5709
  const bodyContainer = resolveContainer(teleport);
5713
- console.log("bodyContainer:", bodyContainer);
5714
5710
  bodyContainer.appendChild(container);
5715
- console.log("container added to bodyContainer");
5716
5711
  const TempToast = () => {
5717
- console.log("TempToast component rendered");
5718
5712
  const options = {
5719
5713
  duration: 2e3,
5720
5714
  ...props
5721
5715
  };
5722
- const [visible, setVisible] = useState(true);
5716
+ const [visible, setVisible] = useState(false);
5723
5717
  const [state, setState] = useState({ ...options });
5724
- console.log("TempToast useState initialized, visible:", visible);
5718
+ useEffect(() => {
5719
+ setVisible(true);
5720
+ }, []);
5725
5721
  const internalOnClosed = useCallback(() => {
5726
- console.log("internalOnClosed called");
5727
5722
  if (state.forbidClick) {
5728
5723
  lockClick(false);
5729
5724
  }
5730
5725
  setVisible(false);
5731
- window.setTimeout(() => {
5732
- const unmountResult = unmount(container);
5733
- if (unmountResult && container.parentNode) {
5734
- container.parentNode.removeChild(container);
5735
- }
5736
- }, +state.duration || +defaultOptions.duration);
5737
- }, [container]);
5726
+ +state.duration || +defaultOptions.duration;
5727
+ }, [state.duration, state.forbidClick]);
5728
+ const handleAfterClose = useCallback(() => {
5729
+ const unmountResult = unmount(container);
5730
+ if (unmountResult && container.parentNode) {
5731
+ container.parentNode.removeChild(container);
5732
+ }
5733
+ }, []);
5738
5734
  const destroy = useCallback(() => {
5739
- console.log("destroy called");
5740
5735
  setVisible(false);
5741
5736
  if (onClose)
5742
5737
  onClose();
5743
- }, []);
5744
- update.clear = internalOnClosed;
5745
- update.config = useCallback(
5746
- (nextState) => {
5747
- console.log("update.config called:", nextState);
5738
+ }, [onClose]);
5739
+ useIsomorphicLayoutEffect(() => {
5740
+ componentRef.clear = internalOnClosed;
5741
+ componentRef.config = (nextState) => {
5748
5742
  setState(
5749
5743
  (prev2) => typeof nextState === "function" ? { ...prev2, ...nextState(prev2) } : { ...prev2, ...nextState }
5750
5744
  );
5751
- },
5752
- [setState]
5753
- );
5745
+ };
5746
+ }, [internalOnClosed]);
5754
5747
  useIsomorphicLayoutEffect(() => {
5755
- console.log("useIsomorphicLayoutEffect called");
5756
5748
  if (!allowMultiple)
5757
5749
  syncClear();
5758
5750
  toastArray.push(internalOnClosed);
@@ -5768,24 +5760,21 @@ const ToastObj = (p) => {
5768
5760
  return /* @__PURE__ */ React.createElement(Toast$1, {
5769
5761
  ...state,
5770
5762
  visible,
5763
+ teleport: null,
5771
5764
  onClose: destroy,
5772
- onClosed: internalOnClosed
5765
+ onClosed: handleAfterClose
5773
5766
  });
5774
5767
  };
5775
- console.log("Before render(<TempToast />)");
5776
5768
  render(/* @__PURE__ */ React.createElement(TempToast, null), container);
5777
- console.log("After render(<TempToast />)");
5778
5769
  return update;
5779
5770
  };
5780
5771
  function parseOptions(message) {
5781
- console.log("parseOptions called:", message);
5782
5772
  if (isObject(message)) {
5783
5773
  return message;
5784
5774
  }
5785
5775
  return { message };
5786
5776
  }
5787
5777
  const createMethod = (type) => (options) => {
5788
- console.log("createMethod called:", type, options);
5789
5778
  return ToastObj({
5790
5779
  ...currentOptions,
5791
5780
  ...defaultOptionsMap.get(type),
@@ -2871,12 +2871,11 @@
2871
2871
  function legacyUnmount(container) {
2872
2872
  return unmountComponentAtNode(container);
2873
2873
  }
2874
- async function concurrentUnmount(container) {
2875
- return Promise.resolve().then(() => {
2876
- var _a;
2877
- (_a = container[MARK]) == null ? void 0 : _a.unmount();
2878
- delete container[MARK];
2879
- });
2874
+ function concurrentUnmount(container) {
2875
+ var _a;
2876
+ (_a = container[MARK]) == null ? void 0 : _a.unmount();
2877
+ delete container[MARK];
2878
+ return true;
2880
2879
  }
2881
2880
  function unmount(container) {
2882
2881
  if (createRoot) {
@@ -12224,11 +12223,6 @@
12224
12223
  teleport: props.teleport
12225
12224
  }, renderIcon(), renderMessage());
12226
12225
  };
12227
- const reactVersion = Number((React.version || "").split(".")[0]);
12228
- Number((ReactDOM.version || "").split(".")[0]);
12229
- console.log("method.tsx loaded");
12230
- console.log("React version:", reactVersion);
12231
- console.log("canUseDom:", canUseDom());
12232
12226
  const defaultOptions = {
12233
12227
  message: "",
12234
12228
  className: "",
@@ -12253,65 +12247,63 @@
12253
12247
  setTimeout(syncClear);
12254
12248
  }
12255
12249
  const ToastObj = (p2) => {
12256
- console.log("ToastObj called");
12257
- if (!canUseDom()) {
12258
- console.log("canUseDom returned false");
12250
+ if (!canUseDom())
12259
12251
  return null;
12260
- }
12261
12252
  const props = parseOptions(p2);
12262
- console.log("props:", props);
12263
- const update2 = {
12264
- config: () => {
12253
+ const componentRef = {
12254
+ clear: () => {
12265
12255
  },
12266
- clear: () => null
12256
+ config: (nextState) => {
12257
+ }
12258
+ };
12259
+ const update2 = {
12260
+ config: (nextState) => componentRef.config(nextState),
12261
+ clear: () => {
12262
+ componentRef.clear();
12263
+ }
12267
12264
  };
12268
12265
  let timer = 0;
12269
12266
  const { onClose, teleport } = props;
12270
12267
  const container = document.createElement("div");
12271
12268
  const bodyContainer = resolveContainer(teleport);
12272
- console.log("bodyContainer:", bodyContainer);
12273
12269
  bodyContainer.appendChild(container);
12274
- console.log("container added to bodyContainer");
12275
12270
  const TempToast = () => {
12276
- console.log("TempToast component rendered");
12277
12271
  const options = {
12278
12272
  duration: 2e3,
12279
12273
  ...props
12280
12274
  };
12281
- const [visible, setVisible] = React.useState(true);
12275
+ const [visible, setVisible] = React.useState(false);
12282
12276
  const [state, setState] = React.useState({ ...options });
12283
- console.log("TempToast useState initialized, visible:", visible);
12277
+ React.useEffect(() => {
12278
+ setVisible(true);
12279
+ }, []);
12284
12280
  const internalOnClosed = React.useCallback(() => {
12285
- console.log("internalOnClosed called");
12286
12281
  if (state.forbidClick) {
12287
12282
  lockClick(false);
12288
12283
  }
12289
12284
  setVisible(false);
12290
- window.setTimeout(() => {
12291
- const unmountResult = unmount(container);
12292
- if (unmountResult && container.parentNode) {
12293
- container.parentNode.removeChild(container);
12294
- }
12295
- }, +state.duration || +defaultOptions.duration);
12296
- }, [container]);
12285
+ +state.duration || +defaultOptions.duration;
12286
+ }, [state.duration, state.forbidClick]);
12287
+ const handleAfterClose = React.useCallback(() => {
12288
+ const unmountResult = unmount(container);
12289
+ if (unmountResult && container.parentNode) {
12290
+ container.parentNode.removeChild(container);
12291
+ }
12292
+ }, []);
12297
12293
  const destroy = React.useCallback(() => {
12298
- console.log("destroy called");
12299
12294
  setVisible(false);
12300
12295
  if (onClose)
12301
12296
  onClose();
12302
- }, []);
12303
- update2.clear = internalOnClosed;
12304
- update2.config = React.useCallback(
12305
- (nextState) => {
12306
- console.log("update.config called:", nextState);
12297
+ }, [onClose]);
12298
+ useIsomorphicLayoutEffect$1(() => {
12299
+ componentRef.clear = internalOnClosed;
12300
+ componentRef.config = (nextState) => {
12307
12301
  setState(
12308
12302
  (prev2) => typeof nextState === "function" ? { ...prev2, ...nextState(prev2) } : { ...prev2, ...nextState }
12309
12303
  );
12310
- },
12311
- [setState]
12312
- );
12304
+ };
12305
+ }, [internalOnClosed]);
12313
12306
  useIsomorphicLayoutEffect$1(() => {
12314
- console.log("useIsomorphicLayoutEffect called");
12315
12307
  if (!allowMultiple)
12316
12308
  syncClear();
12317
12309
  toastArray.push(internalOnClosed);
@@ -12327,24 +12319,21 @@
12327
12319
  return /* @__PURE__ */ React__default["default"].createElement(Toast$1, {
12328
12320
  ...state,
12329
12321
  visible,
12322
+ teleport: null,
12330
12323
  onClose: destroy,
12331
- onClosed: internalOnClosed
12324
+ onClosed: handleAfterClose
12332
12325
  });
12333
12326
  };
12334
- console.log("Before render(<TempToast />)");
12335
12327
  render(/* @__PURE__ */ React__default["default"].createElement(TempToast, null), container);
12336
- console.log("After render(<TempToast />)");
12337
12328
  return update2;
12338
12329
  };
12339
12330
  function parseOptions(message) {
12340
- console.log("parseOptions called:", message);
12341
12331
  if (isObject$1(message)) {
12342
12332
  return message;
12343
12333
  }
12344
12334
  return { message };
12345
12335
  }
12346
12336
  const createMethod = (type2) => (options) => {
12347
- console.log("createMethod called:", type2, options);
12348
12337
  return ToastObj({
12349
12338
  ...currentOptions,
12350
12339
  ...defaultOptionsMap.get(type2),