react-vant-nova 1.1.7-test → 1.1.9-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.
- package/bundle/react-vant-nova.es.js +32 -44
- package/bundle/react-vant-nova.js +30 -42
- package/bundle/react-vant-nova.min.js +2 -2
- package/es/toast/method.js +50 -48
- package/lib/toast/method.js +49 -47
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useState, useMemo, useCallback, useContext, createContext, forwardRef, useImperativeHandle, memo, isValidElement,
|
|
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
|
|
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";
|
|
@@ -5665,11 +5665,6 @@ const Toast$1 = (p) => {
|
|
|
5665
5665
|
teleport: props.teleport
|
|
5666
5666
|
}, renderIcon(), renderMessage());
|
|
5667
5667
|
};
|
|
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
5668
|
const defaultOptions = {
|
|
5674
5669
|
message: "",
|
|
5675
5670
|
className: "",
|
|
@@ -5694,66 +5689,63 @@ function nextTickClear() {
|
|
|
5694
5689
|
setTimeout(syncClear);
|
|
5695
5690
|
}
|
|
5696
5691
|
const ToastObj = (p) => {
|
|
5697
|
-
|
|
5698
|
-
if (!canUseDom()) {
|
|
5699
|
-
console.log("canUseDom returned false");
|
|
5692
|
+
if (!canUseDom())
|
|
5700
5693
|
return null;
|
|
5701
|
-
}
|
|
5702
5694
|
const props = parseOptions(p);
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
config: () => {
|
|
5695
|
+
const componentRef = {
|
|
5696
|
+
clear: () => {
|
|
5706
5697
|
},
|
|
5707
|
-
|
|
5698
|
+
config: (nextState) => {
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
const update = {
|
|
5702
|
+
config: (nextState) => componentRef.config(nextState),
|
|
5703
|
+
clear: () => {
|
|
5704
|
+
componentRef.clear();
|
|
5705
|
+
}
|
|
5708
5706
|
};
|
|
5709
5707
|
let timer = 0;
|
|
5710
5708
|
const { onClose, teleport } = props;
|
|
5711
5709
|
const container = document.createElement("div");
|
|
5712
5710
|
const bodyContainer = resolveContainer(teleport);
|
|
5713
|
-
console.log("bodyContainer:", bodyContainer);
|
|
5714
5711
|
bodyContainer.appendChild(container);
|
|
5715
|
-
console.log("container added to bodyContainer");
|
|
5716
5712
|
const TempToast = () => {
|
|
5717
|
-
console.log("TempToast component rendered");
|
|
5718
5713
|
const options = {
|
|
5719
5714
|
duration: 2e3,
|
|
5720
5715
|
...props
|
|
5721
5716
|
};
|
|
5722
5717
|
const [visible, setVisible] = useState(false);
|
|
5723
5718
|
const [state, setState] = useState({ ...options });
|
|
5724
|
-
|
|
5719
|
+
useEffect(() => {
|
|
5720
|
+
setVisible(true);
|
|
5721
|
+
}, []);
|
|
5725
5722
|
const internalOnClosed = useCallback(() => {
|
|
5726
|
-
console.log("internalOnClosed called");
|
|
5727
5723
|
if (state.forbidClick) {
|
|
5728
5724
|
lockClick(false);
|
|
5729
5725
|
}
|
|
5730
5726
|
setVisible(false);
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5727
|
+
+state.duration || +defaultOptions.duration;
|
|
5728
|
+
}, [state.duration, state.forbidClick]);
|
|
5729
|
+
const handleAfterClose = useCallback(() => {
|
|
5730
|
+
const unmountResult = unmount(container);
|
|
5731
|
+
if (unmountResult && container.parentNode) {
|
|
5732
|
+
container.parentNode.removeChild(container);
|
|
5733
|
+
}
|
|
5734
|
+
}, []);
|
|
5738
5735
|
const destroy = useCallback(() => {
|
|
5739
|
-
console.log("destroy called");
|
|
5740
5736
|
setVisible(false);
|
|
5741
5737
|
if (onClose)
|
|
5742
5738
|
onClose();
|
|
5743
|
-
}, []);
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
(nextState) => {
|
|
5747
|
-
console.log("update.config called:", nextState);
|
|
5739
|
+
}, [onClose]);
|
|
5740
|
+
useIsomorphicLayoutEffect(() => {
|
|
5741
|
+
componentRef.clear = internalOnClosed;
|
|
5742
|
+
componentRef.config = (nextState) => {
|
|
5748
5743
|
setState(
|
|
5749
5744
|
(prev2) => typeof nextState === "function" ? { ...prev2, ...nextState(prev2) } : { ...prev2, ...nextState }
|
|
5750
5745
|
);
|
|
5751
|
-
}
|
|
5752
|
-
|
|
5753
|
-
);
|
|
5746
|
+
};
|
|
5747
|
+
}, [internalOnClosed]);
|
|
5754
5748
|
useIsomorphicLayoutEffect(() => {
|
|
5755
|
-
console.log("useIsomorphicLayoutEffect called");
|
|
5756
|
-
setVisible(true);
|
|
5757
5749
|
if (!allowMultiple)
|
|
5758
5750
|
syncClear();
|
|
5759
5751
|
toastArray.push(internalOnClosed);
|
|
@@ -5769,25 +5761,21 @@ const ToastObj = (p) => {
|
|
|
5769
5761
|
return /* @__PURE__ */ React.createElement(Toast$1, {
|
|
5770
5762
|
...state,
|
|
5771
5763
|
visible,
|
|
5772
|
-
teleport:
|
|
5764
|
+
teleport: null,
|
|
5773
5765
|
onClose: destroy,
|
|
5774
|
-
onClosed:
|
|
5766
|
+
onClosed: handleAfterClose
|
|
5775
5767
|
});
|
|
5776
5768
|
};
|
|
5777
|
-
console.log("Before render(<TempToast />)");
|
|
5778
5769
|
render(/* @__PURE__ */ React.createElement(TempToast, null), container);
|
|
5779
|
-
console.log("After render(<TempToast />)");
|
|
5780
5770
|
return update;
|
|
5781
5771
|
};
|
|
5782
5772
|
function parseOptions(message) {
|
|
5783
|
-
console.log("parseOptions called:", message);
|
|
5784
5773
|
if (isObject(message)) {
|
|
5785
5774
|
return message;
|
|
5786
5775
|
}
|
|
5787
5776
|
return { message };
|
|
5788
5777
|
}
|
|
5789
5778
|
const createMethod = (type) => (options) => {
|
|
5790
|
-
console.log("createMethod called:", type, options);
|
|
5791
5779
|
return ToastObj({
|
|
5792
5780
|
...currentOptions,
|
|
5793
5781
|
...defaultOptionsMap.get(type),
|
|
@@ -12224,11 +12224,6 @@
|
|
|
12224
12224
|
teleport: props.teleport
|
|
12225
12225
|
}, renderIcon(), renderMessage());
|
|
12226
12226
|
};
|
|
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
12227
|
const defaultOptions = {
|
|
12233
12228
|
message: "",
|
|
12234
12229
|
className: "",
|
|
@@ -12253,66 +12248,63 @@
|
|
|
12253
12248
|
setTimeout(syncClear);
|
|
12254
12249
|
}
|
|
12255
12250
|
const ToastObj = (p2) => {
|
|
12256
|
-
|
|
12257
|
-
if (!canUseDom()) {
|
|
12258
|
-
console.log("canUseDom returned false");
|
|
12251
|
+
if (!canUseDom())
|
|
12259
12252
|
return null;
|
|
12260
|
-
}
|
|
12261
12253
|
const props = parseOptions(p2);
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
config: () => {
|
|
12254
|
+
const componentRef = {
|
|
12255
|
+
clear: () => {
|
|
12265
12256
|
},
|
|
12266
|
-
|
|
12257
|
+
config: (nextState) => {
|
|
12258
|
+
}
|
|
12259
|
+
};
|
|
12260
|
+
const update2 = {
|
|
12261
|
+
config: (nextState) => componentRef.config(nextState),
|
|
12262
|
+
clear: () => {
|
|
12263
|
+
componentRef.clear();
|
|
12264
|
+
}
|
|
12267
12265
|
};
|
|
12268
12266
|
let timer = 0;
|
|
12269
12267
|
const { onClose, teleport } = props;
|
|
12270
12268
|
const container = document.createElement("div");
|
|
12271
12269
|
const bodyContainer = resolveContainer(teleport);
|
|
12272
|
-
console.log("bodyContainer:", bodyContainer);
|
|
12273
12270
|
bodyContainer.appendChild(container);
|
|
12274
|
-
console.log("container added to bodyContainer");
|
|
12275
12271
|
const TempToast = () => {
|
|
12276
|
-
console.log("TempToast component rendered");
|
|
12277
12272
|
const options = {
|
|
12278
12273
|
duration: 2e3,
|
|
12279
12274
|
...props
|
|
12280
12275
|
};
|
|
12281
12276
|
const [visible, setVisible] = React.useState(false);
|
|
12282
12277
|
const [state, setState] = React.useState({ ...options });
|
|
12283
|
-
|
|
12278
|
+
React.useEffect(() => {
|
|
12279
|
+
setVisible(true);
|
|
12280
|
+
}, []);
|
|
12284
12281
|
const internalOnClosed = React.useCallback(() => {
|
|
12285
|
-
console.log("internalOnClosed called");
|
|
12286
12282
|
if (state.forbidClick) {
|
|
12287
12283
|
lockClick(false);
|
|
12288
12284
|
}
|
|
12289
12285
|
setVisible(false);
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12286
|
+
+state.duration || +defaultOptions.duration;
|
|
12287
|
+
}, [state.duration, state.forbidClick]);
|
|
12288
|
+
const handleAfterClose = React.useCallback(() => {
|
|
12289
|
+
const unmountResult = unmount(container);
|
|
12290
|
+
if (unmountResult && container.parentNode) {
|
|
12291
|
+
container.parentNode.removeChild(container);
|
|
12292
|
+
}
|
|
12293
|
+
}, []);
|
|
12297
12294
|
const destroy = React.useCallback(() => {
|
|
12298
|
-
console.log("destroy called");
|
|
12299
12295
|
setVisible(false);
|
|
12300
12296
|
if (onClose)
|
|
12301
12297
|
onClose();
|
|
12302
|
-
}, []);
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
(nextState) => {
|
|
12306
|
-
console.log("update.config called:", nextState);
|
|
12298
|
+
}, [onClose]);
|
|
12299
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
12300
|
+
componentRef.clear = internalOnClosed;
|
|
12301
|
+
componentRef.config = (nextState) => {
|
|
12307
12302
|
setState(
|
|
12308
12303
|
(prev2) => typeof nextState === "function" ? { ...prev2, ...nextState(prev2) } : { ...prev2, ...nextState }
|
|
12309
12304
|
);
|
|
12310
|
-
}
|
|
12311
|
-
|
|
12312
|
-
);
|
|
12305
|
+
};
|
|
12306
|
+
}, [internalOnClosed]);
|
|
12313
12307
|
useIsomorphicLayoutEffect$1(() => {
|
|
12314
|
-
console.log("useIsomorphicLayoutEffect called");
|
|
12315
|
-
setVisible(true);
|
|
12316
12308
|
if (!allowMultiple)
|
|
12317
12309
|
syncClear();
|
|
12318
12310
|
toastArray.push(internalOnClosed);
|
|
@@ -12328,25 +12320,21 @@
|
|
|
12328
12320
|
return /* @__PURE__ */ React__default["default"].createElement(Toast$1, {
|
|
12329
12321
|
...state,
|
|
12330
12322
|
visible,
|
|
12331
|
-
teleport:
|
|
12323
|
+
teleport: null,
|
|
12332
12324
|
onClose: destroy,
|
|
12333
|
-
onClosed:
|
|
12325
|
+
onClosed: handleAfterClose
|
|
12334
12326
|
});
|
|
12335
12327
|
};
|
|
12336
|
-
console.log("Before render(<TempToast />)");
|
|
12337
12328
|
render(/* @__PURE__ */ React__default["default"].createElement(TempToast, null), container);
|
|
12338
|
-
console.log("After render(<TempToast />)");
|
|
12339
12329
|
return update2;
|
|
12340
12330
|
};
|
|
12341
12331
|
function parseOptions(message) {
|
|
12342
|
-
console.log("parseOptions called:", message);
|
|
12343
12332
|
if (isObject$1(message)) {
|
|
12344
12333
|
return message;
|
|
12345
12334
|
}
|
|
12346
12335
|
return { message };
|
|
12347
12336
|
}
|
|
12348
12337
|
const createMethod = (type2) => (options) => {
|
|
12349
|
-
console.log("createMethod called:", type2, options);
|
|
12350
12338
|
return ToastObj({
|
|
12351
12339
|
...currentOptions,
|
|
12352
12340
|
...defaultOptionsMap.get(type2),
|