pay-sdk-react 1.1.2 → 1.1.3
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/README.md +37 -19
- package/README.zh-CN.md +37 -19
- package/dist/css/index.css +703 -1
- package/dist/css/index.min.css +1 -0
- package/dist/es/Airwallex/airwallex-button.js +56 -36
- package/dist/es/Airwallex/airwallex-modal.js +41 -34
- package/dist/es/Airwallex/airwallex-popup.js +43 -38
- package/dist/es/Airwallex/airwallex.js +26 -28
- package/dist/es/Airwallex/index.js +1 -1
- package/dist/es/Airwallex/style/index.css +335 -1
- package/dist/es/Airwallex/style/index.min.css +1 -0
- package/dist/es/Alipay/alipay-button.js +39 -24
- package/dist/es/Alipay/alipay-modal.js +37 -31
- package/dist/es/Alipay/alipay.js +22 -15
- package/dist/es/Alipay/index.d.ts +4 -4
- package/dist/es/Alipay/index.js +5 -5
- package/dist/es/Alipay/style/index.css +18 -1
- package/dist/es/Alipay/style/index.min.css +1 -0
- package/dist/es/Button/button.js +62 -37
- package/dist/es/Button/index.d.ts +2 -2
- package/dist/es/Button/index.js +2 -2
- package/dist/es/Button/style/index.css +95 -1
- package/dist/es/Button/style/index.min.css +1 -0
- package/dist/es/FullScreenLoading/index.js +40 -40
- package/dist/es/FullScreenLoading/interface.d.ts +2 -2
- package/dist/es/FullScreenLoading/style/index.css +239 -1
- package/dist/es/FullScreenLoading/style/index.min.css +1 -0
- package/dist/es/MAlipay/index.js +1 -1
- package/dist/es/MAlipay/m-alipay-auto-submit.js +9 -11
- package/dist/es/MAlipay/m-alipay-button.js +71 -51
- package/dist/es/MAlipay/style/index.css +252 -1
- package/dist/es/MAlipay/style/index.min.css +1 -0
- package/dist/es/MWeChat/index.d.ts +2 -2
- package/dist/es/MWeChat/index.js +2 -2
- package/dist/es/MWeChat/m-wechat-button.js +70 -50
- package/dist/es/MWeChat/style/index.css +252 -1
- package/dist/es/MWeChat/style/index.min.css +1 -0
- package/dist/es/Mask/index.d.ts +2 -2
- package/dist/es/Mask/index.js +2 -2
- package/dist/es/Mask/mask.js +48 -45
- package/dist/es/Mask/style/index.css +11 -1
- package/dist/es/Mask/style/index.min.css +1 -0
- package/dist/es/PayButton/index.js +2 -2
- package/dist/es/PayButton/interface.d.ts +9 -9
- package/dist/es/PayButton/interface.js +1 -1
- package/dist/es/PayMask/index.d.ts +2 -2
- package/dist/es/PayMask/index.js +2 -2
- package/dist/es/PayMask/interface.d.ts +2 -2
- package/dist/es/PayMask/pay-mask.js +41 -40
- package/dist/es/PayMask/style/index.css +62 -1
- package/dist/es/PayMask/style/index.min.css +1 -0
- package/dist/es/Paypal/index.d.ts +2 -2
- package/dist/es/Paypal/index.js +2 -2
- package/dist/es/Paypal/paypal-button.js +55 -36
- package/dist/es/Paypal/style/index.css +207 -1
- package/dist/es/Paypal/style/index.min.css +1 -0
- package/dist/es/Payssion/index.d.ts +2 -2
- package/dist/es/Payssion/index.js +2 -2
- package/dist/es/Payssion/payssion-button.js +56 -37
- package/dist/es/Payssion/style/index.css +157 -1
- package/dist/es/Payssion/style/index.min.css +1 -0
- package/dist/es/Stripe/index.d.ts +5 -5
- package/dist/es/Stripe/index.js +6 -6
- package/dist/es/Stripe/stripe-button.js +47 -33
- package/dist/es/Stripe/stripe-modal.js +38 -32
- package/dist/es/Stripe/stripe-popup.js +42 -37
- package/dist/es/Stripe/stripe.js +15 -15
- package/dist/es/Stripe/style/index.css +365 -1
- package/dist/es/Stripe/style/index.min.css +1 -0
- package/dist/es/Wechat/index.d.ts +4 -4
- package/dist/es/Wechat/index.js +5 -5
- package/dist/es/Wechat/style/index.css +25 -1
- package/dist/es/Wechat/style/index.min.css +1 -0
- package/dist/es/Wechat/wechat-button.js +38 -23
- package/dist/es/Wechat/wechat-modal.js +37 -31
- package/dist/es/Wechat/wechat.js +16 -12
- package/dist/es/confirm-modal/index.js +38 -39
- package/dist/es/confirm-modal/interface.d.ts +2 -2
- package/dist/es/confirm-modal/style/index.css +95 -1
- package/dist/es/confirm-modal/style/index.min.css +1 -0
- package/dist/es/dot-loading/dot-loading.js +25 -23
- package/dist/es/dot-loading/index.d.ts +2 -2
- package/dist/es/dot-loading/index.js +2 -2
- package/dist/es/dot-loading/style/index.css +3 -1
- package/dist/es/dot-loading/style/index.min.css +1 -0
- package/dist/es/hooks/use-initialized.js +2 -2
- package/dist/es/hooks/use-inner-visible.js +8 -4
- package/dist/es/hooks/use-lock-scroll.d.ts +2 -2
- package/dist/es/hooks/use-lock-scroll.js +30 -34
- package/dist/es/hooks/use-touch.d.ts +1 -1
- package/dist/es/hooks/use-touch.js +35 -31
- package/dist/es/hooks/usePayWindowOpen.d.ts +1 -1
- package/dist/es/hooks/usePayWindowOpen.js +31 -27
- package/dist/es/icons/IconAlipay/index.js +18 -16
- package/dist/es/icons/IconClose/index.js +24 -22
- package/dist/es/icons/IconPaypalText/index.js +24 -22
- package/dist/es/icons/IconPaypalWhite/index.js +19 -17
- package/dist/es/icons/IconPayssionPay/index.js +47 -45
- package/dist/es/icons/IconStripe/index.js +19 -17
- package/dist/es/icons/IconStripeText/index.js +19 -17
- package/dist/es/icons/IconWechatPay/index.js +18 -16
- package/dist/es/icons/interface.d.ts +1 -1
- package/dist/es/icons/style/index.css +45 -1
- package/dist/es/icons/style/index.min.css +1 -0
- package/dist/es/pay-modal/index.d.ts +2 -2
- package/dist/es/pay-modal/index.js +2 -2
- package/dist/es/pay-modal/pay-modal.js +45 -48
- package/dist/es/pay-modal/style/index.css +95 -1
- package/dist/es/pay-modal/style/index.min.css +1 -0
- package/dist/es/pay-popup/index.js +51 -53
- package/dist/es/pay-popup/interface.d.ts +6 -6
- package/dist/es/pay-popup/style/index.css +145 -1
- package/dist/es/pay-popup/style/index.min.css +1 -0
- package/dist/es/shared/enums/index.js +1 -1
- package/dist/es/shared/index.d.ts +1 -1
- package/dist/es/shared/index.js +1 -1
- package/dist/es/utils/can-use-dom.js +1 -1
- package/dist/es/utils/classNames.js +15 -11
- package/dist/es/utils/dom.js +18 -18
- package/dist/es/utils/get-container.js +2 -2
- package/dist/es/utils/get-scroll-parent.js +8 -9
- package/dist/es/utils/is.js +54 -32
- package/dist/es/utils/native-props.d.ts +2 -2
- package/dist/es/utils/native-props.js +7 -9
- package/dist/es/utils/omit.js +3 -5
- package/dist/es/utils/qrcode.js +5 -5
- package/dist/es/utils/render-to-container.d.ts +1 -1
- package/dist/es/utils/render-to-container.js +4 -4
- package/dist/es/utils/should-render.d.ts +1 -1
- package/dist/es/utils/should-render.js +4 -4
- package/dist/es/utils/supports-passive.js +8 -7
- package/dist/es/utils/warning.js +0 -1
- package/dist/es/utils/with-default-props.js +6 -4
- package/dist/es/utils/with-stop-propagation.d.ts +3 -3
- package/dist/es/utils/with-stop-propagation.js +27 -14
- package/dist/lib/Airwallex/airwallex-button.js +12 -15
- package/dist/lib/Airwallex/airwallex-modal.js +11 -14
- package/dist/lib/Airwallex/airwallex-popup.js +16 -23
- package/dist/lib/Airwallex/airwallex.js +20 -25
- package/dist/lib/Airwallex/index.js +1 -1
- package/dist/lib/Airwallex/style/index.css +335 -1
- package/dist/lib/Airwallex/style/index.min.css +1 -0
- package/dist/lib/Alipay/alipay-button.js +12 -15
- package/dist/lib/Alipay/alipay-modal.js +9 -12
- package/dist/lib/Alipay/alipay.js +19 -23
- package/dist/lib/Alipay/index.js +1 -1
- package/dist/lib/Alipay/style/index.css +18 -1
- package/dist/lib/Alipay/style/index.min.css +1 -0
- package/dist/lib/Button/button.js +13 -13
- package/dist/lib/Button/index.js +1 -1
- package/dist/lib/Button/style/index.css +95 -1
- package/dist/lib/Button/style/index.min.css +1 -0
- package/dist/lib/FullScreenLoading/index.js +28 -29
- package/dist/lib/FullScreenLoading/style/index.css +239 -1
- package/dist/lib/FullScreenLoading/style/index.min.css +1 -0
- package/dist/lib/MAlipay/index.js +1 -1
- package/dist/lib/MAlipay/m-alipay-auto-submit.js +3 -4
- package/dist/lib/MAlipay/m-alipay-button.js +34 -44
- package/dist/lib/MAlipay/style/index.css +252 -1
- package/dist/lib/MAlipay/style/index.min.css +1 -0
- package/dist/lib/MWeChat/index.js +2 -2
- package/dist/lib/MWeChat/m-wechat-button.js +34 -44
- package/dist/lib/MWeChat/style/index.css +252 -1
- package/dist/lib/MWeChat/style/index.min.css +1 -0
- package/dist/lib/Mask/index.js +1 -1
- package/dist/lib/Mask/mask.js +6 -11
- package/dist/lib/Mask/style/index.css +11 -1
- package/dist/lib/Mask/style/index.min.css +1 -0
- package/dist/lib/PayButton/index.js +10 -10
- package/dist/lib/PayMask/index.js +1 -1
- package/dist/lib/PayMask/pay-mask.js +20 -23
- package/dist/lib/PayMask/style/index.css +62 -1
- package/dist/lib/PayMask/style/index.min.css +1 -0
- package/dist/lib/Paypal/index.js +2 -2
- package/dist/lib/Paypal/paypal-button.js +17 -22
- package/dist/lib/Paypal/style/index.css +207 -1
- package/dist/lib/Paypal/style/index.min.css +1 -0
- package/dist/lib/Payssion/index.js +2 -2
- package/dist/lib/Payssion/payssion-button.js +17 -22
- package/dist/lib/Payssion/style/index.css +157 -1
- package/dist/lib/Payssion/style/index.min.css +1 -0
- package/dist/lib/Stripe/index.js +1 -1
- package/dist/lib/Stripe/stripe-button.js +14 -17
- package/dist/lib/Stripe/stripe-modal.js +10 -13
- package/dist/lib/Stripe/stripe-popup.js +16 -23
- package/dist/lib/Stripe/stripe.js +8 -11
- package/dist/lib/Stripe/style/index.css +365 -1
- package/dist/lib/Stripe/style/index.min.css +1 -0
- package/dist/lib/Wechat/index.js +1 -1
- package/dist/lib/Wechat/style/index.css +25 -1
- package/dist/lib/Wechat/style/index.min.css +1 -0
- package/dist/lib/Wechat/wechat-button.js +12 -15
- package/dist/lib/Wechat/wechat-modal.js +9 -12
- package/dist/lib/Wechat/wechat.js +11 -12
- package/dist/lib/confirm-modal/index.js +17 -26
- package/dist/lib/confirm-modal/style/index.css +95 -1
- package/dist/lib/confirm-modal/style/index.min.css +1 -0
- package/dist/lib/dot-loading/dot-loading.js +3 -4
- package/dist/lib/dot-loading/index.js +1 -1
- package/dist/lib/dot-loading/style/index.css +3 -1
- package/dist/lib/dot-loading/style/index.min.css +1 -0
- package/dist/lib/hooks/use-lock-scroll.js +11 -12
- package/dist/lib/hooks/use-touch.js +10 -10
- package/dist/lib/hooks/usePayWindowOpen.js +14 -15
- package/dist/lib/icons/IconAlipay/index.js +6 -6
- package/dist/lib/icons/IconClose/index.js +8 -8
- package/dist/lib/icons/IconPaypalText/index.js +7 -7
- package/dist/lib/icons/IconPaypalWhite/index.js +6 -6
- package/dist/lib/icons/IconPayssionPay/index.js +13 -13
- package/dist/lib/icons/IconStripe/index.js +6 -6
- package/dist/lib/icons/IconStripeText/index.js +6 -6
- package/dist/lib/icons/IconWechatPay/index.js +6 -6
- package/dist/lib/icons/index.js +2 -2
- package/dist/lib/icons/style/index.css +45 -1
- package/dist/lib/icons/style/index.min.css +1 -0
- package/dist/lib/index.js +2 -2
- package/dist/lib/pay-modal/index.js +1 -1
- package/dist/lib/pay-modal/pay-modal.js +24 -30
- package/dist/lib/pay-modal/style/index.css +95 -1
- package/dist/lib/pay-modal/style/index.min.css +1 -0
- package/dist/lib/pay-popup/index.js +24 -28
- package/dist/lib/pay-popup/style/index.css +145 -1
- package/dist/lib/pay-popup/style/index.min.css +1 -0
- package/dist/lib/utils/can-use-dom.js +1 -1
- package/dist/lib/utils/classNames.js +6 -7
- package/dist/lib/utils/dom.js +9 -11
- package/dist/lib/utils/get-scroll-parent.js +2 -3
- package/dist/lib/utils/getPrefixCls.js +1 -1
- package/dist/lib/utils/is.js +16 -14
- package/dist/lib/utils/native-props.js +10 -10
- package/dist/lib/utils/omit.js +3 -6
- package/dist/lib/utils/qrcode.js +1 -1
- package/dist/lib/utils/supports-passive.js +4 -3
- package/dist/lib/utils/warning.js +2 -6
- package/dist/lib/utils/with-default-props.js +4 -8
- package/dist/lib/utils/with-stop-propagation.js +6 -9
- package/dist/umd/pay-sdk-react.umd.js +61 -63
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +5 -2
package/dist/es/Stripe/stripe.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["stripeKey", "clientSecret", "className"];
|
|
5
4
|
import React, { memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
6
5
|
import { EmbeddedCheckout, EmbeddedCheckoutProvider } from '@stripe/react-stripe-js';
|
|
7
6
|
import { loadStripe } from '@stripe/stripe-js';
|
|
8
7
|
import cs from '../utils/classNames';
|
|
9
8
|
import { getPrefixCls } from '../utils/getPrefixCls';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = props,
|
|
9
|
+
var Stripe = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
10
|
+
var stripeKey = props.stripeKey,
|
|
11
|
+
clientSecret = props.clientSecret,
|
|
12
|
+
_props$className = props.className,
|
|
13
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
16
14
|
others = _objectWithoutProperties(props, _excluded);
|
|
17
|
-
|
|
18
|
-
useImperativeHandle(ref, ()
|
|
19
|
-
|
|
15
|
+
var stripeRef = useRef(null);
|
|
16
|
+
useImperativeHandle(ref, function () {
|
|
17
|
+
return stripeRef.current;
|
|
18
|
+
});
|
|
19
|
+
var stripePromise = useMemo(function () {
|
|
20
20
|
if (!stripeKey) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
return loadStripe === null || loadStripe === void 0 ? void 0 : loadStripe(stripeKey);
|
|
24
24
|
}, [stripeKey]);
|
|
25
|
-
|
|
25
|
+
var classNames = cs(getPrefixCls('pay-stripe'), className);
|
|
26
26
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
27
27
|
ref: stripeRef
|
|
28
28
|
}, others, {
|
|
@@ -30,7 +30,7 @@ const Stripe = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
30
30
|
}), clientSecret && stripePromise && /*#__PURE__*/React.createElement(EmbeddedCheckoutProvider, {
|
|
31
31
|
stripe: stripePromise,
|
|
32
32
|
options: {
|
|
33
|
-
clientSecret
|
|
33
|
+
clientSecret: clientSecret
|
|
34
34
|
}
|
|
35
35
|
}, /*#__PURE__*/React.createElement(EmbeddedCheckout, null)));
|
|
36
36
|
});
|
|
@@ -1 +1,365 @@
|
|
|
1
|
-
.pay-dot-loading
|
|
1
|
+
.pay-dot-loading {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
.pay-button {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
padding: 7px 12px;
|
|
7
|
+
font-size: 16px;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
border: 1px solid #eee;
|
|
10
|
+
background: #fff;
|
|
11
|
+
color: #333;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
transition: all 0.2s;
|
|
14
|
+
user-select: none;
|
|
15
|
+
position: relative;
|
|
16
|
+
text-align: center;
|
|
17
|
+
}
|
|
18
|
+
.pay-button-content {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
gap: 6px;
|
|
23
|
+
}
|
|
24
|
+
.pay-button-block {
|
|
25
|
+
display: block;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
.pay-button-disabled {
|
|
29
|
+
opacity: 0.4;
|
|
30
|
+
cursor: not-allowed;
|
|
31
|
+
}
|
|
32
|
+
.pay-button-loading {
|
|
33
|
+
cursor: wait;
|
|
34
|
+
}
|
|
35
|
+
.pay-button-loading-wrapper {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
gap: 6px;
|
|
40
|
+
}
|
|
41
|
+
.pay-button-primary {
|
|
42
|
+
background: #1677ff;
|
|
43
|
+
border-color: #1677ff;
|
|
44
|
+
color: #fff;
|
|
45
|
+
}
|
|
46
|
+
.pay-button-primary:hover {
|
|
47
|
+
background: #409eff;
|
|
48
|
+
}
|
|
49
|
+
.pay-button-success {
|
|
50
|
+
background: #00b578;
|
|
51
|
+
border-color: #00b578;
|
|
52
|
+
color: #fff;
|
|
53
|
+
}
|
|
54
|
+
.pay-button-danger {
|
|
55
|
+
background: #ff3141;
|
|
56
|
+
border-color: #ff3141;
|
|
57
|
+
color: #fff;
|
|
58
|
+
}
|
|
59
|
+
.pay-button-warning {
|
|
60
|
+
background: #ff8f1f;
|
|
61
|
+
border-color: #ff8f1f;
|
|
62
|
+
color: #fff;
|
|
63
|
+
}
|
|
64
|
+
.pay-button-default {
|
|
65
|
+
background: #fff;
|
|
66
|
+
border-color: #eee;
|
|
67
|
+
color: #333;
|
|
68
|
+
}
|
|
69
|
+
.pay-button-fill-outline {
|
|
70
|
+
background: transparent;
|
|
71
|
+
color: inherit;
|
|
72
|
+
}
|
|
73
|
+
.pay-button-fill-none {
|
|
74
|
+
background: transparent;
|
|
75
|
+
border: none;
|
|
76
|
+
color: inherit;
|
|
77
|
+
}
|
|
78
|
+
.pay-button-mini {
|
|
79
|
+
font-size: 12px;
|
|
80
|
+
padding: 2px 8px;
|
|
81
|
+
}
|
|
82
|
+
.pay-button-small {
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
padding: 4px 10px;
|
|
85
|
+
}
|
|
86
|
+
.pay-button-large {
|
|
87
|
+
font-size: 18px;
|
|
88
|
+
padding: 10px 18px;
|
|
89
|
+
}
|
|
90
|
+
.pay-button-shape-rounded {
|
|
91
|
+
border-radius: 1000px;
|
|
92
|
+
}
|
|
93
|
+
.pay-button-shape-rectangular {
|
|
94
|
+
border-radius: 0;
|
|
95
|
+
}
|
|
96
|
+
.pay-modal {
|
|
97
|
+
position: fixed;
|
|
98
|
+
z-index: 9999;
|
|
99
|
+
left: 0;
|
|
100
|
+
top: 0;
|
|
101
|
+
right: 0;
|
|
102
|
+
bottom: 0;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
}
|
|
107
|
+
.pay-modal__mask {
|
|
108
|
+
position: absolute;
|
|
109
|
+
left: 0;
|
|
110
|
+
top: 0;
|
|
111
|
+
right: 0;
|
|
112
|
+
bottom: 0;
|
|
113
|
+
background: rgba(0, 0, 0, 0.55);
|
|
114
|
+
z-index: 0;
|
|
115
|
+
}
|
|
116
|
+
.pay-modal__content {
|
|
117
|
+
position: relative;
|
|
118
|
+
z-index: 1;
|
|
119
|
+
background: #fff;
|
|
120
|
+
border-radius: 16px;
|
|
121
|
+
padding: 42px 20px 20px 20px;
|
|
122
|
+
min-width: 280px;
|
|
123
|
+
max-width: 80vw;
|
|
124
|
+
box-shadow: 0 4px 24px #0001;
|
|
125
|
+
text-align: center;
|
|
126
|
+
max-height: 60vh;
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
}
|
|
130
|
+
.pay-modal__close {
|
|
131
|
+
position: absolute;
|
|
132
|
+
right: 12px;
|
|
133
|
+
top: 12px;
|
|
134
|
+
background: none;
|
|
135
|
+
border: none;
|
|
136
|
+
font-size: 28px;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
text-align: left;
|
|
139
|
+
}
|
|
140
|
+
.pay-modal__icon {
|
|
141
|
+
margin-bottom: 8px;
|
|
142
|
+
font-size: 40px;
|
|
143
|
+
}
|
|
144
|
+
.pay-modal__title {
|
|
145
|
+
font-size: 20px;
|
|
146
|
+
font-weight: 700;
|
|
147
|
+
color: #222;
|
|
148
|
+
margin-bottom: 12px;
|
|
149
|
+
}
|
|
150
|
+
.pay-modal__desc {
|
|
151
|
+
color: #222;
|
|
152
|
+
font-size: 15px;
|
|
153
|
+
margin-bottom: 24px;
|
|
154
|
+
line-height: 1.7;
|
|
155
|
+
text-align: left;
|
|
156
|
+
}
|
|
157
|
+
.pay-modal__content-wrapper {
|
|
158
|
+
position: relative;
|
|
159
|
+
z-index: 1;
|
|
160
|
+
text-align: center;
|
|
161
|
+
overflow-y: auto;
|
|
162
|
+
flex: 1;
|
|
163
|
+
min-height: 0;
|
|
164
|
+
}
|
|
165
|
+
.pay-modal__actions {
|
|
166
|
+
display: flex;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
gap: 16px;
|
|
169
|
+
margin-top: 16px;
|
|
170
|
+
}
|
|
171
|
+
.pay-modal__btn {
|
|
172
|
+
min-width: 96px;
|
|
173
|
+
padding: 8px 0;
|
|
174
|
+
border-radius: 24px;
|
|
175
|
+
border: none;
|
|
176
|
+
font-size: 15px;
|
|
177
|
+
font-weight: 600;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
transition: background 0.2s;
|
|
180
|
+
}
|
|
181
|
+
.pay-modal__btn--retry {
|
|
182
|
+
background: #fff;
|
|
183
|
+
color: #f25a5a;
|
|
184
|
+
border: 1.5px solid #f25a5a;
|
|
185
|
+
}
|
|
186
|
+
.pay-modal__btn--finish {
|
|
187
|
+
background: #f25a5a;
|
|
188
|
+
color: #fff;
|
|
189
|
+
border: none;
|
|
190
|
+
}
|
|
191
|
+
.pay-mask {
|
|
192
|
+
position: fixed;
|
|
193
|
+
z-index: 1000;
|
|
194
|
+
left: 0;
|
|
195
|
+
top: 0;
|
|
196
|
+
right: 0;
|
|
197
|
+
bottom: 0;
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
}
|
|
202
|
+
.pay-icon {
|
|
203
|
+
display: inline-block;
|
|
204
|
+
color: inherit;
|
|
205
|
+
width: 16px;
|
|
206
|
+
vertical-align: -2px;
|
|
207
|
+
stroke: currentColor;
|
|
208
|
+
}
|
|
209
|
+
.pay-icon[fill='currentColor'] {
|
|
210
|
+
fill: currentColor;
|
|
211
|
+
stroke: none;
|
|
212
|
+
}
|
|
213
|
+
.pay-icon[stroke='currentColor'] {
|
|
214
|
+
stroke: currentColor;
|
|
215
|
+
fill: none;
|
|
216
|
+
}
|
|
217
|
+
.pay-icon[fill='currentColor'][stroke='currentColor'] {
|
|
218
|
+
fill: currentColor;
|
|
219
|
+
stroke: currentColor;
|
|
220
|
+
}
|
|
221
|
+
.pay-icon-paypal-text {
|
|
222
|
+
width: 64px;
|
|
223
|
+
height: 26px;
|
|
224
|
+
max-width: 72px;
|
|
225
|
+
max-height: 32px;
|
|
226
|
+
}
|
|
227
|
+
.pay-icon-close {
|
|
228
|
+
width: 18px;
|
|
229
|
+
height: 18px;
|
|
230
|
+
}
|
|
231
|
+
.pay-icon-stripe-text {
|
|
232
|
+
width: 24px;
|
|
233
|
+
height: 24px;
|
|
234
|
+
}
|
|
235
|
+
.pay-icon-alipay {
|
|
236
|
+
width: 20px;
|
|
237
|
+
height: 20px;
|
|
238
|
+
}
|
|
239
|
+
.pay-icon-wechat-pay {
|
|
240
|
+
width: 20px;
|
|
241
|
+
height: 20px;
|
|
242
|
+
}
|
|
243
|
+
.pay-icon-payssion-pay {
|
|
244
|
+
width: 36px;
|
|
245
|
+
height: 20px;
|
|
246
|
+
}
|
|
247
|
+
.pay-popup {
|
|
248
|
+
position: fixed;
|
|
249
|
+
z-index: 1001;
|
|
250
|
+
}
|
|
251
|
+
/* Base container for the animated popup body */
|
|
252
|
+
.pay-popup-body {
|
|
253
|
+
position: fixed;
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
background-color: #ffffff;
|
|
257
|
+
z-index: 1010;
|
|
258
|
+
box-sizing: border-box;
|
|
259
|
+
}
|
|
260
|
+
/* --- Sizing and Positioning --- */
|
|
261
|
+
.pay-popup-body.pay-popup-body-position-bottom {
|
|
262
|
+
width: 100%;
|
|
263
|
+
left: 0;
|
|
264
|
+
bottom: 0;
|
|
265
|
+
}
|
|
266
|
+
.pay-popup-body.pay-popup-body-position-top {
|
|
267
|
+
width: 100%;
|
|
268
|
+
left: 0;
|
|
269
|
+
top: 0;
|
|
270
|
+
}
|
|
271
|
+
.pay-popup-body.pay-popup-body-position-left {
|
|
272
|
+
height: 100%;
|
|
273
|
+
width: 80vw;
|
|
274
|
+
left: 0;
|
|
275
|
+
top: 0;
|
|
276
|
+
}
|
|
277
|
+
.pay-popup-body.pay-popup-body-position-right {
|
|
278
|
+
height: 100%;
|
|
279
|
+
width: 80vw;
|
|
280
|
+
right: 0;
|
|
281
|
+
top: 0;
|
|
282
|
+
}
|
|
283
|
+
/* --- Round Corners Modifier --- */
|
|
284
|
+
.pay-popup-body.pay-popup-body-round.pay-popup-body-position-bottom {
|
|
285
|
+
border-radius: 16px 16px 0 0;
|
|
286
|
+
}
|
|
287
|
+
.pay-popup-body.pay-popup-body-round.pay-popup-body-position-top {
|
|
288
|
+
border-radius: 0 0 16px 16px;
|
|
289
|
+
}
|
|
290
|
+
.pay-popup-body.pay-popup-body-round.pay-popup-body-position-left {
|
|
291
|
+
border-radius: 0 16px 16px 0;
|
|
292
|
+
}
|
|
293
|
+
.pay-popup-body.pay-popup-body-round.pay-popup-body-position-right {
|
|
294
|
+
border-radius: 16px 0 0 16px;
|
|
295
|
+
}
|
|
296
|
+
/* --- Close Icon --- */
|
|
297
|
+
.pay-popup-close-icon {
|
|
298
|
+
position: absolute;
|
|
299
|
+
z-index: 1;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
padding: 4px;
|
|
302
|
+
font-size: 18px;
|
|
303
|
+
line-height: 1;
|
|
304
|
+
color: #999;
|
|
305
|
+
}
|
|
306
|
+
.pay-popup-body.pay-popup-body-position-bottom .pay-popup-close-icon,
|
|
307
|
+
.pay-popup-body.pay-popup-body-position-left .pay-popup-close-icon {
|
|
308
|
+
top: 8px;
|
|
309
|
+
right: 8px;
|
|
310
|
+
}
|
|
311
|
+
.pay-popup-body.pay-popup-body-position-top .pay-popup-close-icon {
|
|
312
|
+
bottom: 8px;
|
|
313
|
+
right: 8px;
|
|
314
|
+
}
|
|
315
|
+
.pay-popup-body.pay-popup-body-position-right .pay-popup-close-icon {
|
|
316
|
+
top: 8px;
|
|
317
|
+
left: 8px;
|
|
318
|
+
}
|
|
319
|
+
/* --- Content Area --- */
|
|
320
|
+
.pay-popup-content {
|
|
321
|
+
flex: 1;
|
|
322
|
+
overflow-y: auto;
|
|
323
|
+
-webkit-overflow-scrolling: touch;
|
|
324
|
+
}
|
|
325
|
+
/* --- Padding adjustment when close icon is visible --- */
|
|
326
|
+
.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-bottom .pay-popup-content,
|
|
327
|
+
.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-left .pay-popup-content {
|
|
328
|
+
padding-top: 40px;
|
|
329
|
+
}
|
|
330
|
+
.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-right .pay-popup-content {
|
|
331
|
+
padding-top: 40px;
|
|
332
|
+
}
|
|
333
|
+
.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-top .pay-popup-content {
|
|
334
|
+
padding-bottom: 40px;
|
|
335
|
+
}
|
|
336
|
+
@media (min-width: 576px) {
|
|
337
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
338
|
+
width: 72%;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
@media (min-width: 768px) {
|
|
342
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
343
|
+
width: 50%;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
@media (min-width: 992px) {
|
|
347
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
348
|
+
width: 40%;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
@media (min-width: 1200px) {
|
|
352
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
353
|
+
width: 27%;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
@media (min-width: 1600px) {
|
|
357
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
358
|
+
width: 26%;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
@media (min-width: 2000px) {
|
|
362
|
+
.pay-stripe-modal.pay-modal .pay-modal__content {
|
|
363
|
+
width: 20%;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pay-dot-loading{display:inline-block}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:.2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:28px;cursor:pointer;text-align:left}.pay-modal__icon{margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:1;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-icon{display:inline-block;color:inherit;width:16px;vertical-align:-2px;stroke:currentColor}.pay-icon[fill=currentColor]{fill:currentColor;stroke:none}.pay-icon[stroke=currentColor]{stroke:currentColor;fill:none}.pay-icon[fill=currentColor][stroke=currentColor]{fill:currentColor;stroke:currentColor}.pay-icon-paypal-text{width:64px;height:26px;max-width:72px;max-height:32px}.pay-icon-close{width:18px;height:18px}.pay-icon-stripe-text{width:24px;height:24px}.pay-icon-alipay{width:20px;height:20px}.pay-icon-wechat-pay{width:20px;height:20px}.pay-icon-payssion-pay{width:36px;height:20px}.pay-popup{position:fixed;z-index:1001}.pay-popup-body{position:fixed;display:flex;flex-direction:column;background-color:#fff;z-index:1010;box-sizing:border-box}.pay-popup-body.pay-popup-body-position-bottom{width:100%;left:0;bottom:0}.pay-popup-body.pay-popup-body-position-top{width:100%;left:0;top:0}.pay-popup-body.pay-popup-body-position-left{height:100%;width:80vw;left:0;top:0}.pay-popup-body.pay-popup-body-position-right{height:100%;width:80vw;right:0;top:0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-bottom{border-radius:16px 16px 0 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-top{border-radius:0 0 16px 16px}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-left{border-radius:0 16px 16px 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-right{border-radius:16px 0 0 16px}.pay-popup-close-icon{position:absolute;z-index:1;cursor:pointer;padding:4px;font-size:18px;line-height:1;color:#999}.pay-popup-body.pay-popup-body-position-bottom .pay-popup-close-icon,.pay-popup-body.pay-popup-body-position-left .pay-popup-close-icon{top:8px;right:8px}.pay-popup-body.pay-popup-body-position-top .pay-popup-close-icon{bottom:8px;right:8px}.pay-popup-body.pay-popup-body-position-right .pay-popup-close-icon{top:8px;left:8px}.pay-popup-content{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-bottom .pay-popup-content,.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-left .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-right .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-top .pay-popup-content{padding-bottom:40px}@media (min-width:576px){.pay-stripe-modal.pay-modal .pay-modal__content{width:72%}}@media (min-width:768px){.pay-stripe-modal.pay-modal .pay-modal__content{width:50%}}@media (min-width:992px){.pay-stripe-modal.pay-modal .pay-modal__content{width:40%}}@media (min-width:1200px){.pay-stripe-modal.pay-modal .pay-modal__content{width:27%}}@media (min-width:1600px){.pay-stripe-modal.pay-modal .pay-modal__content{width:26%}}@media (min-width:2000px){.pay-stripe-modal.pay-modal .pay-modal__content{width:20%}}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import Wechat from
|
|
2
|
-
import WechatButton from
|
|
3
|
-
import WechatModal from
|
|
1
|
+
import Wechat from './wechat';
|
|
2
|
+
import WechatButton from './wechat-button';
|
|
3
|
+
import WechatModal from './wechat-modal';
|
|
4
4
|
type WechatComponentType = typeof Wechat & {
|
|
5
5
|
Button: typeof WechatButton;
|
|
6
6
|
Modal: typeof WechatModal;
|
|
7
7
|
};
|
|
8
8
|
declare const WechatComponent: WechatComponentType;
|
|
9
|
-
export * from
|
|
9
|
+
export * from './interface';
|
|
10
10
|
export default WechatComponent;
|
package/dist/es/Wechat/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Wechat from
|
|
2
|
-
import WechatButton from
|
|
3
|
-
import WechatModal from
|
|
4
|
-
|
|
1
|
+
import Wechat from './wechat';
|
|
2
|
+
import WechatButton from './wechat-button';
|
|
3
|
+
import WechatModal from './wechat-modal';
|
|
4
|
+
var WechatComponent = Wechat;
|
|
5
5
|
WechatComponent.Button = WechatButton;
|
|
6
6
|
WechatComponent.Modal = WechatModal;
|
|
7
|
-
export * from
|
|
7
|
+
export * from './interface';
|
|
8
8
|
export default WechatComponent;
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
.pay-wechat-qrcode{
|
|
1
|
+
.pay-wechat-qrcode {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
.pay-wechat-qrcode__container {
|
|
7
|
+
background-color: #fff;
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
width: 210px;
|
|
13
|
+
height: 210px;
|
|
14
|
+
}
|
|
15
|
+
.pay-wechat-qrcode__image {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
object-fit: cover;
|
|
19
|
+
}
|
|
20
|
+
.pay-wechat-qrcode__tip {
|
|
21
|
+
text-align: center;
|
|
22
|
+
color: #333;
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
line-height: 20px;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pay-wechat-qrcode{display:flex;flex-direction:column;align-items:center}.pay-wechat-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:210px;height:210px}.pay-wechat-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-wechat-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px}
|
|
@@ -1,35 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["className", "children", "onClick", "createOrder", "modalProps"];
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
5
6
|
import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef } from 'react';
|
|
6
7
|
import cs from '../utils/classNames';
|
|
7
8
|
import WechatModal from './wechat-modal';
|
|
8
9
|
import Button from '../Button';
|
|
9
10
|
import { IconWechatPay } from '../icons';
|
|
10
11
|
import { getPrefixCls } from '../utils/getPrefixCls';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = props,
|
|
12
|
+
var WechatButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
13
|
+
var className = props.className,
|
|
14
|
+
_props$children = props.children,
|
|
15
|
+
children = _props$children === void 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconWechatPay, null), "\u5FAE\u4FE1\u652F\u4ED8") : _props$children,
|
|
16
|
+
onClick = props.onClick,
|
|
17
|
+
createOrder = props.createOrder,
|
|
18
|
+
modalProps = props.modalProps,
|
|
19
19
|
others = _objectWithoutProperties(props, _excluded);
|
|
20
|
-
|
|
20
|
+
var wechatButtonRef = useRef({
|
|
21
21
|
nativeElement: null
|
|
22
22
|
});
|
|
23
|
-
|
|
24
|
-
useImperativeHandle(ref, ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
var wechatModalRef = useRef(null);
|
|
24
|
+
useImperativeHandle(ref, function () {
|
|
25
|
+
return wechatButtonRef.current;
|
|
26
|
+
});
|
|
27
|
+
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
28
|
+
var _wechatModalRef$curre, options;
|
|
29
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
if (!createOrder) {
|
|
33
|
+
_context.next = 2;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
_context.next = 1;
|
|
37
|
+
return createOrder();
|
|
38
|
+
case 1:
|
|
39
|
+
options = _context.sent;
|
|
40
|
+
(_wechatModalRef$curre = wechatModalRef.current) === null || _wechatModalRef$curre === void 0 || _wechatModalRef$curre.open(options);
|
|
41
|
+
case 2:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
})), [createOrder]);
|
|
47
|
+
var handleClick = useCallback(function (e) {
|
|
33
48
|
if (createOrder) {
|
|
34
49
|
handlePayCreateOrder();
|
|
35
50
|
} else {
|
|
@@ -1,43 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["wechatProps", "visible", "onClose"];
|
|
5
5
|
import React, { memo, useImperativeHandle, useRef, useState } from 'react';
|
|
6
6
|
import PayModal from '../pay-modal';
|
|
7
7
|
import Wechat from './wechat';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
onClose
|
|
13
|
-
} = props,
|
|
8
|
+
var WechatModal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
|
+
var propsWechatProps = props.wechatProps,
|
|
10
|
+
visible = props.visible,
|
|
11
|
+
_onClose = props.onClose,
|
|
14
12
|
others = _objectWithoutProperties(props, _excluded);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
var wechatRef = useRef(null);
|
|
14
|
+
var _useState = useState(false),
|
|
15
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
16
|
+
uncontrolledVisible = _useState2[0],
|
|
17
|
+
setUncontrolledVisible = _useState2[1];
|
|
18
|
+
var _useState3 = useState(),
|
|
19
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20
|
+
wechatProps = _useState4[0],
|
|
21
|
+
setWechatProps = _useState4[1];
|
|
22
|
+
var isControlled = visible !== undefined;
|
|
23
|
+
var _visible = isControlled ? visible : uncontrolledVisible;
|
|
24
|
+
useImperativeHandle(ref, function () {
|
|
25
|
+
return {
|
|
26
|
+
open: function open(value) {
|
|
27
|
+
if (value) {
|
|
28
|
+
setWechatProps(value);
|
|
29
|
+
}
|
|
30
|
+
setUncontrolledVisible(true);
|
|
31
|
+
},
|
|
32
|
+
close: function close() {
|
|
33
|
+
setUncontrolledVisible(false);
|
|
34
|
+
_onClose === null || _onClose === void 0 || _onClose();
|
|
35
|
+
},
|
|
36
|
+
current: wechatRef.current
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
var _wechatProps = propsWechatProps !== null && propsWechatProps !== void 0 ? propsWechatProps : wechatProps;
|
|
34
40
|
return /*#__PURE__*/React.createElement(PayModal, _extends({
|
|
35
41
|
visible: _visible,
|
|
36
|
-
onClose: ()
|
|
42
|
+
onClose: function onClose() {
|
|
37
43
|
if (!isControlled) {
|
|
38
44
|
setUncontrolledVisible(false);
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
_onClose === null || _onClose === void 0 || _onClose();
|
|
41
47
|
}
|
|
42
48
|
}, others), (_wechatProps === null || _wechatProps === void 0 ? void 0 : _wechatProps.wechatUrl) && /*#__PURE__*/React.createElement(Wechat, _wechatProps));
|
|
43
49
|
});
|