pay-sdk-react 1.1.0
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 +1059 -0
- package/README.zh-CN.md +1061 -0
- package/dist/css/index.css +1 -0
- package/dist/es/Airwallex/airwallex-button.d.ts +4 -0
- package/dist/es/Airwallex/airwallex-button.js +86 -0
- package/dist/es/Airwallex/airwallex-modal.d.ts +6 -0
- package/dist/es/Airwallex/airwallex-modal.js +63 -0
- package/dist/es/Airwallex/airwallex-popup.d.ts +6 -0
- package/dist/es/Airwallex/airwallex-popup.js +74 -0
- package/dist/es/Airwallex/airwallex.d.ts +6 -0
- package/dist/es/Airwallex/airwallex.js +77 -0
- package/dist/es/Airwallex/index.d.ts +12 -0
- package/dist/es/Airwallex/index.js +10 -0
- package/dist/es/Airwallex/interface.d.ts +75 -0
- package/dist/es/Airwallex/interface.js +1 -0
- package/dist/es/Airwallex/style/index.css +1 -0
- package/dist/es/Airwallex/style/index.d.ts +1 -0
- package/dist/es/Airwallex/style/index.js +1 -0
- package/dist/es/Alipay/alipay-button.d.ts +6 -0
- package/dist/es/Alipay/alipay-button.js +52 -0
- package/dist/es/Alipay/alipay-modal.d.ts +6 -0
- package/dist/es/Alipay/alipay-modal.js +45 -0
- package/dist/es/Alipay/alipay.d.ts +4 -0
- package/dist/es/Alipay/alipay.js +44 -0
- package/dist/es/Alipay/index.d.ts +10 -0
- package/dist/es/Alipay/index.js +8 -0
- package/dist/es/Alipay/interface.d.ts +53 -0
- package/dist/es/Alipay/interface.js +1 -0
- package/dist/es/Alipay/style/index.css +1 -0
- package/dist/es/Alipay/style/index.d.ts +3 -0
- package/dist/es/Alipay/style/index.js +3 -0
- package/dist/es/Button/button.d.ts +21 -0
- package/dist/es/Button/button.js +74 -0
- package/dist/es/Button/index.d.ts +3 -0
- package/dist/es/Button/index.js +3 -0
- package/dist/es/Button/interface.d.ts +21 -0
- package/dist/es/Button/interface.js +1 -0
- package/dist/es/Button/style/index.css +1 -0
- package/dist/es/Button/style/index.d.ts +1 -0
- package/dist/es/Button/style/index.js +1 -0
- package/dist/es/FullScreenLoading/index.d.ts +4 -0
- package/dist/es/FullScreenLoading/index.js +116 -0
- package/dist/es/FullScreenLoading/interface.d.ts +43 -0
- package/dist/es/FullScreenLoading/interface.js +1 -0
- package/dist/es/FullScreenLoading/style/index.css +1 -0
- package/dist/es/FullScreenLoading/style/index.d.ts +1 -0
- package/dist/es/FullScreenLoading/style/index.js +1 -0
- package/dist/es/MAlipay/index.d.ts +8 -0
- package/dist/es/MAlipay/index.js +6 -0
- package/dist/es/MAlipay/interface.d.ts +44 -0
- package/dist/es/MAlipay/interface.js +1 -0
- package/dist/es/MAlipay/m-alipay-auto-submit.d.ts +6 -0
- package/dist/es/MAlipay/m-alipay-auto-submit.js +37 -0
- package/dist/es/MAlipay/m-alipay-button.d.ts +6 -0
- package/dist/es/MAlipay/m-alipay-button.js +127 -0
- package/dist/es/MAlipay/style/index.css +1 -0
- package/dist/es/MAlipay/style/index.d.ts +1 -0
- package/dist/es/MAlipay/style/index.js +1 -0
- package/dist/es/MWeChat/index.d.ts +2 -0
- package/dist/es/MWeChat/index.js +2 -0
- package/dist/es/MWeChat/interface.d.ts +50 -0
- package/dist/es/MWeChat/interface.js +1 -0
- package/dist/es/MWeChat/m-wechat-button.d.ts +6 -0
- package/dist/es/MWeChat/m-wechat-button.js +117 -0
- package/dist/es/MWeChat/style/index.css +1 -0
- package/dist/es/MWeChat/style/index.d.ts +1 -0
- package/dist/es/MWeChat/style/index.js +1 -0
- package/dist/es/Mask/index.d.ts +3 -0
- package/dist/es/Mask/index.js +3 -0
- package/dist/es/Mask/interface.d.ts +81 -0
- package/dist/es/Mask/interface.js +1 -0
- package/dist/es/Mask/mask.d.ts +5 -0
- package/dist/es/Mask/mask.js +97 -0
- package/dist/es/Mask/style/index.css +1 -0
- package/dist/es/Mask/style/index.d.ts +1 -0
- package/dist/es/Mask/style/index.js +1 -0
- package/dist/es/PayButton/index.d.ts +5 -0
- package/dist/es/PayButton/index.js +57 -0
- package/dist/es/PayButton/interface.d.ts +130 -0
- package/dist/es/PayButton/interface.js +93 -0
- package/dist/es/PayMask/index.d.ts +3 -0
- package/dist/es/PayMask/index.js +3 -0
- package/dist/es/PayMask/interface.d.ts +56 -0
- package/dist/es/PayMask/interface.js +1 -0
- package/dist/es/PayMask/pay-mask.d.ts +5 -0
- package/dist/es/PayMask/pay-mask.js +92 -0
- package/dist/es/PayMask/style/index.css +1 -0
- package/dist/es/PayMask/style/index.d.ts +1 -0
- package/dist/es/PayMask/style/index.js +1 -0
- package/dist/es/Paypal/index.d.ts +2 -0
- package/dist/es/Paypal/index.js +2 -0
- package/dist/es/Paypal/interface.d.ts +42 -0
- package/dist/es/Paypal/interface.js +1 -0
- package/dist/es/Paypal/paypal-button.d.ts +6 -0
- package/dist/es/Paypal/paypal-button.js +75 -0
- package/dist/es/Paypal/style/index.css +1 -0
- package/dist/es/Paypal/style/index.d.ts +1 -0
- package/dist/es/Paypal/style/index.js +1 -0
- package/dist/es/Payssion/index.d.ts +2 -0
- package/dist/es/Payssion/index.js +2 -0
- package/dist/es/Payssion/interface.d.ts +38 -0
- package/dist/es/Payssion/interface.js +1 -0
- package/dist/es/Payssion/payssion-button.d.ts +6 -0
- package/dist/es/Payssion/payssion-button.js +75 -0
- package/dist/es/Payssion/style/index.css +1 -0
- package/dist/es/Payssion/style/index.d.ts +1 -0
- package/dist/es/Payssion/style/index.js +1 -0
- package/dist/es/Stripe/index.d.ts +12 -0
- package/dist/es/Stripe/index.js +10 -0
- package/dist/es/Stripe/interface.d.ts +91 -0
- package/dist/es/Stripe/interface.js +1 -0
- package/dist/es/Stripe/stripe-button.d.ts +6 -0
- package/dist/es/Stripe/stripe-button.js +65 -0
- package/dist/es/Stripe/stripe-modal.d.ts +6 -0
- package/dist/es/Stripe/stripe-modal.js +50 -0
- package/dist/es/Stripe/stripe-popup.d.ts +6 -0
- package/dist/es/Stripe/stripe-popup.js +61 -0
- package/dist/es/Stripe/stripe.d.ts +5 -0
- package/dist/es/Stripe/stripe.js +38 -0
- package/dist/es/Stripe/style/index.css +1 -0
- package/dist/es/Stripe/style/index.d.ts +1 -0
- package/dist/es/Stripe/style/index.js +1 -0
- package/dist/es/Wechat/index.d.ts +10 -0
- package/dist/es/Wechat/index.js +8 -0
- package/dist/es/Wechat/interface.d.ts +69 -0
- package/dist/es/Wechat/interface.js +1 -0
- package/dist/es/Wechat/style/index.css +1 -0
- package/dist/es/Wechat/style/index.d.ts +1 -0
- package/dist/es/Wechat/style/index.js +1 -0
- package/dist/es/Wechat/wechat-button.d.ts +6 -0
- package/dist/es/Wechat/wechat-button.js +50 -0
- package/dist/es/Wechat/wechat-modal.d.ts +6 -0
- package/dist/es/Wechat/wechat-modal.js +45 -0
- package/dist/es/Wechat/wechat.d.ts +4 -0
- package/dist/es/Wechat/wechat.js +40 -0
- package/dist/es/confirm-modal/index.d.ts +5 -0
- package/dist/es/confirm-modal/index.js +52 -0
- package/dist/es/confirm-modal/interface.d.ts +21 -0
- package/dist/es/confirm-modal/interface.js +1 -0
- package/dist/es/confirm-modal/style/index.css +1 -0
- package/dist/es/confirm-modal/style/index.d.ts +1 -0
- package/dist/es/confirm-modal/style/index.js +1 -0
- package/dist/es/dot-loading/dot-loading.d.ts +4 -0
- package/dist/es/dot-loading/dot-loading.js +60 -0
- package/dist/es/dot-loading/index.d.ts +3 -0
- package/dist/es/dot-loading/index.js +3 -0
- package/dist/es/dot-loading/interface.d.ts +4 -0
- package/dist/es/dot-loading/interface.js +1 -0
- package/dist/es/dot-loading/style/index.css +1 -0
- package/dist/es/dot-loading/style/index.d.ts +1 -0
- package/dist/es/dot-loading/style/index.js +1 -0
- package/dist/es/hooks/use-initialized.d.ts +1 -0
- package/dist/es/hooks/use-initialized.js +8 -0
- package/dist/es/hooks/use-inner-visible.d.ts +1 -0
- package/dist/es/hooks/use-inner-visible.js +9 -0
- package/dist/es/hooks/use-lock-scroll.d.ts +2 -0
- package/dist/es/hooks/use-lock-scroll.js +82 -0
- package/dist/es/hooks/use-touch.d.ts +17 -0
- package/dist/es/hooks/use-touch.js +60 -0
- package/dist/es/hooks/usePayWindowOpen.d.ts +21 -0
- package/dist/es/hooks/usePayWindowOpen.js +87 -0
- package/dist/es/icons/IconAlipay/index.d.ts +4 -0
- package/dist/es/icons/IconAlipay/index.js +21 -0
- package/dist/es/icons/IconClose/index.d.ts +4 -0
- package/dist/es/icons/IconClose/index.js +27 -0
- package/dist/es/icons/IconPaypalText/index.d.ts +4 -0
- package/dist/es/icons/IconPaypalText/index.js +27 -0
- package/dist/es/icons/IconPaypalWhite/index.d.ts +4 -0
- package/dist/es/icons/IconPaypalWhite/index.js +22 -0
- package/dist/es/icons/IconPayssionPay/index.d.ts +4 -0
- package/dist/es/icons/IconPayssionPay/index.js +50 -0
- package/dist/es/icons/IconStripe/index.d.ts +4 -0
- package/dist/es/icons/IconStripe/index.js +22 -0
- package/dist/es/icons/IconStripeText/index.d.ts +4 -0
- package/dist/es/icons/IconStripeText/index.js +22 -0
- package/dist/es/icons/IconWechatPay/index.d.ts +4 -0
- package/dist/es/icons/IconWechatPay/index.js +21 -0
- package/dist/es/icons/index.d.ts +9 -0
- package/dist/es/icons/index.js +9 -0
- package/dist/es/icons/interface.d.ts +5 -0
- package/dist/es/icons/interface.js +1 -0
- package/dist/es/icons/style/index.css +1 -0
- package/dist/es/icons/style/index.d.ts +1 -0
- package/dist/es/icons/style/index.js +1 -0
- package/dist/es/index.d.ts +19 -0
- package/dist/es/index.js +10 -0
- package/dist/es/pay-modal/index.d.ts +3 -0
- package/dist/es/pay-modal/index.js +3 -0
- package/dist/es/pay-modal/interface.d.ts +94 -0
- package/dist/es/pay-modal/interface.js +1 -0
- package/dist/es/pay-modal/pay-modal.d.ts +5 -0
- package/dist/es/pay-modal/pay-modal.js +93 -0
- package/dist/es/pay-modal/style/index.css +1 -0
- package/dist/es/pay-modal/style/index.d.ts +1 -0
- package/dist/es/pay-modal/style/index.js +1 -0
- package/dist/es/pay-popup/index.d.ts +5 -0
- package/dist/es/pay-popup/index.js +156 -0
- package/dist/es/pay-popup/interface.d.ts +148 -0
- package/dist/es/pay-popup/interface.js +1 -0
- package/dist/es/pay-popup/style/index.css +1 -0
- package/dist/es/pay-popup/style/index.d.ts +1 -0
- package/dist/es/pay-popup/style/index.js +1 -0
- package/dist/es/shared/enums/index.d.ts +57 -0
- package/dist/es/shared/enums/index.js +58 -0
- package/dist/es/shared/index.d.ts +1 -0
- package/dist/es/shared/index.js +1 -0
- package/dist/es/utils/can-use-dom.d.ts +1 -0
- package/dist/es/utils/can-use-dom.js +1 -0
- package/dist/es/utils/classNames.d.ts +5 -0
- package/dist/es/utils/classNames.js +27 -0
- package/dist/es/utils/dom.d.ts +8 -0
- package/dist/es/utils/dom.js +80 -0
- package/dist/es/utils/get-container.d.ts +2 -0
- package/dist/es/utils/get-container.js +5 -0
- package/dist/es/utils/get-scroll-parent.d.ts +3 -0
- package/dist/es/utils/get-scroll-parent.js +24 -0
- package/dist/es/utils/getPrefixCls.d.ts +1 -0
- package/dist/es/utils/getPrefixCls.js +3 -0
- package/dist/es/utils/is.d.ts +35 -0
- package/dist/es/utils/is.js +122 -0
- package/dist/es/utils/native-props.d.ts +8 -0
- package/dist/es/utils/native-props.js +26 -0
- package/dist/es/utils/omit.d.ts +1 -0
- package/dist/es/utils/omit.js +15 -0
- package/dist/es/utils/qrcode.d.ts +7 -0
- package/dist/es/utils/qrcode.js +17 -0
- package/dist/es/utils/render-to-container.d.ts +3 -0
- package/dist/es/utils/render-to-container.js +10 -0
- package/dist/es/utils/should-render.d.ts +10 -0
- package/dist/es/utils/should-render.js +12 -0
- package/dist/es/utils/supports-passive.d.ts +1 -0
- package/dist/es/utils/supports-passive.js +14 -0
- package/dist/es/utils/warning.d.ts +1 -0
- package/dist/es/utils/warning.js +13 -0
- package/dist/es/utils/with-default-props.d.ts +9 -0
- package/dist/es/utils/with-default-props.js +33 -0
- package/dist/es/utils/with-stop-propagation.d.ts +4 -0
- package/dist/es/utils/with-stop-propagation.js +22 -0
- package/dist/lib/Airwallex/airwallex-button.js +94 -0
- package/dist/lib/Airwallex/airwallex-modal.js +70 -0
- package/dist/lib/Airwallex/airwallex-popup.js +81 -0
- package/dist/lib/Airwallex/airwallex.js +83 -0
- package/dist/lib/Airwallex/index.js +29 -0
- package/dist/lib/Airwallex/interface.js +5 -0
- package/dist/lib/Airwallex/style/index.css +1 -0
- package/dist/lib/Airwallex/style/index.js +3 -0
- package/dist/lib/Alipay/alipay-button.js +60 -0
- package/dist/lib/Alipay/alipay-modal.js +53 -0
- package/dist/lib/Alipay/alipay.js +52 -0
- package/dist/lib/Alipay/index.js +27 -0
- package/dist/lib/Alipay/interface.js +5 -0
- package/dist/lib/Alipay/style/index.css +1 -0
- package/dist/lib/Alipay/style/index.js +5 -0
- package/dist/lib/Button/button.js +82 -0
- package/dist/lib/Button/index.js +22 -0
- package/dist/lib/Button/interface.js +5 -0
- package/dist/lib/Button/style/index.css +1 -0
- package/dist/lib/Button/style/index.js +3 -0
- package/dist/lib/FullScreenLoading/index.js +124 -0
- package/dist/lib/FullScreenLoading/interface.js +5 -0
- package/dist/lib/FullScreenLoading/style/index.css +1 -0
- package/dist/lib/FullScreenLoading/style/index.js +3 -0
- package/dist/lib/MAlipay/index.js +25 -0
- package/dist/lib/MAlipay/interface.js +5 -0
- package/dist/lib/MAlipay/m-alipay-auto-submit.js +43 -0
- package/dist/lib/MAlipay/m-alipay-button.js +135 -0
- package/dist/lib/MAlipay/style/index.css +1 -0
- package/dist/lib/MAlipay/style/index.js +3 -0
- package/dist/lib/MWeChat/index.js +28 -0
- package/dist/lib/MWeChat/interface.js +5 -0
- package/dist/lib/MWeChat/m-wechat-button.js +125 -0
- package/dist/lib/MWeChat/style/index.css +1 -0
- package/dist/lib/MWeChat/style/index.js +3 -0
- package/dist/lib/Mask/index.js +22 -0
- package/dist/lib/Mask/interface.js +5 -0
- package/dist/lib/Mask/mask.js +117 -0
- package/dist/lib/Mask/style/index.css +1 -0
- package/dist/lib/Mask/style/index.js +3 -0
- package/dist/lib/PayButton/index.js +76 -0
- package/dist/lib/PayButton/interface.js +3 -0
- package/dist/lib/PayMask/index.js +22 -0
- package/dist/lib/PayMask/interface.js +5 -0
- package/dist/lib/PayMask/pay-mask.js +112 -0
- package/dist/lib/PayMask/style/index.css +1 -0
- package/dist/lib/PayMask/style/index.js +3 -0
- package/dist/lib/Paypal/index.js +28 -0
- package/dist/lib/Paypal/interface.js +5 -0
- package/dist/lib/Paypal/paypal-button.js +83 -0
- package/dist/lib/Paypal/style/index.css +1 -0
- package/dist/lib/Paypal/style/index.js +3 -0
- package/dist/lib/Payssion/index.js +28 -0
- package/dist/lib/Payssion/interface.js +5 -0
- package/dist/lib/Payssion/payssion-button.js +83 -0
- package/dist/lib/Payssion/style/index.css +1 -0
- package/dist/lib/Payssion/style/index.js +3 -0
- package/dist/lib/Stripe/index.js +29 -0
- package/dist/lib/Stripe/interface.js +5 -0
- package/dist/lib/Stripe/stripe-button.js +73 -0
- package/dist/lib/Stripe/stripe-modal.js +57 -0
- package/dist/lib/Stripe/stripe-popup.js +68 -0
- package/dist/lib/Stripe/stripe.js +46 -0
- package/dist/lib/Stripe/style/index.css +1 -0
- package/dist/lib/Stripe/style/index.js +3 -0
- package/dist/lib/Wechat/index.js +27 -0
- package/dist/lib/Wechat/interface.js +5 -0
- package/dist/lib/Wechat/style/index.css +1 -0
- package/dist/lib/Wechat/style/index.js +3 -0
- package/dist/lib/Wechat/wechat-button.js +58 -0
- package/dist/lib/Wechat/wechat-modal.js +52 -0
- package/dist/lib/Wechat/wechat.js +48 -0
- package/dist/lib/confirm-modal/index.js +72 -0
- package/dist/lib/confirm-modal/interface.js +5 -0
- package/dist/lib/confirm-modal/style/index.css +1 -0
- package/dist/lib/confirm-modal/style/index.js +3 -0
- package/dist/lib/dot-loading/dot-loading.js +67 -0
- package/dist/lib/dot-loading/index.js +22 -0
- package/dist/lib/dot-loading/interface.js +5 -0
- package/dist/lib/dot-loading/style/index.css +1 -0
- package/dist/lib/dot-loading/style/index.js +3 -0
- package/dist/lib/hooks/use-initialized.js +14 -0
- package/dist/lib/hooks/use-inner-visible.js +15 -0
- package/dist/lib/hooks/use-lock-scroll.js +88 -0
- package/dist/lib/hooks/use-touch.js +66 -0
- package/dist/lib/hooks/usePayWindowOpen.js +92 -0
- package/dist/lib/icons/IconAlipay/index.js +28 -0
- package/dist/lib/icons/IconClose/index.js +34 -0
- package/dist/lib/icons/IconPaypalText/index.js +34 -0
- package/dist/lib/icons/IconPaypalWhite/index.js +29 -0
- package/dist/lib/icons/IconPayssionPay/index.js +57 -0
- package/dist/lib/icons/IconStripe/index.js +29 -0
- package/dist/lib/icons/IconStripeText/index.js +29 -0
- package/dist/lib/icons/IconWechatPay/index.js +28 -0
- package/dist/lib/icons/index.js +84 -0
- package/dist/lib/icons/interface.js +5 -0
- package/dist/lib/icons/style/index.css +1 -0
- package/dist/lib/icons/style/index.js +3 -0
- package/dist/lib/index.js +92 -0
- package/dist/lib/pay-modal/index.js +22 -0
- package/dist/lib/pay-modal/interface.js +5 -0
- package/dist/lib/pay-modal/pay-modal.js +113 -0
- package/dist/lib/pay-modal/style/index.css +1 -0
- package/dist/lib/pay-modal/style/index.js +3 -0
- package/dist/lib/pay-popup/index.js +176 -0
- package/dist/lib/pay-popup/interface.js +5 -0
- package/dist/lib/pay-popup/style/index.css +1 -0
- package/dist/lib/pay-popup/style/index.js +3 -0
- package/dist/lib/shared/enums/index.js +64 -0
- package/dist/lib/shared/index.js +16 -0
- package/dist/lib/utils/can-use-dom.js +7 -0
- package/dist/lib/utils/classNames.js +34 -0
- package/dist/lib/utils/dom.js +86 -0
- package/dist/lib/utils/get-container.js +11 -0
- package/dist/lib/utils/get-scroll-parent.js +30 -0
- package/dist/lib/utils/getPrefixCls.js +9 -0
- package/dist/lib/utils/is.js +160 -0
- package/dist/lib/utils/native-props.js +33 -0
- package/dist/lib/utils/omit.js +21 -0
- package/dist/lib/utils/qrcode.js +23 -0
- package/dist/lib/utils/render-to-container.js +16 -0
- package/dist/lib/utils/should-render.js +20 -0
- package/dist/lib/utils/supports-passive.js +20 -0
- package/dist/lib/utils/warning.js +19 -0
- package/dist/lib/utils/with-default-props.js +40 -0
- package/dist/lib/utils/with-stop-propagation.js +29 -0
- package/dist/umd/pay-sdk-react.umd.js +16360 -0
- package/dist/umd/pay-sdk-react.umd.js.map +1 -0
- package/package.json +181 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
2
|
+
import { canUseDom } from "./can-use-dom";
|
|
3
|
+
import { clientWindow } from "./dom";
|
|
4
|
+
const opt = Object.prototype.toString;
|
|
5
|
+
export function isArray(obj) {
|
|
6
|
+
return opt.call(obj) === "[object Array]";
|
|
7
|
+
}
|
|
8
|
+
export function isObject(obj) {
|
|
9
|
+
return opt.call(obj) === "[object Object]";
|
|
10
|
+
}
|
|
11
|
+
export function isString(obj) {
|
|
12
|
+
return opt.call(obj) === "[object String]";
|
|
13
|
+
}
|
|
14
|
+
export function isNumber(obj) {
|
|
15
|
+
return opt.call(obj) === "[object Number]" && obj === obj;
|
|
16
|
+
}
|
|
17
|
+
export function isRegExp(obj) {
|
|
18
|
+
return opt.call(obj) === "[object RegExp]";
|
|
19
|
+
}
|
|
20
|
+
export function isFile(obj) {
|
|
21
|
+
return opt.call(obj) === "[object File]";
|
|
22
|
+
}
|
|
23
|
+
export function isBlob(obj) {
|
|
24
|
+
return opt.call(obj) === "[object Blob]";
|
|
25
|
+
}
|
|
26
|
+
function isHex(color) {
|
|
27
|
+
return /^#[a-fA-F0-9]{3}$|#[a-fA-F0-9]{6}$/.test(color);
|
|
28
|
+
}
|
|
29
|
+
function isRgb(color) {
|
|
30
|
+
return /^rgb\((\s*\d+\s*,?){3}\)$/.test(color);
|
|
31
|
+
}
|
|
32
|
+
function isRgba(color) {
|
|
33
|
+
return /^rgba\((\s*\d+\s*,\s*){3}\s*\d(\.\d+)?\s*\)$/.test(color);
|
|
34
|
+
}
|
|
35
|
+
export function isColor(color) {
|
|
36
|
+
return isHex(color) || isRgb(color) || isRgba(color);
|
|
37
|
+
}
|
|
38
|
+
export function isUndefined(obj) {
|
|
39
|
+
return obj === undefined;
|
|
40
|
+
}
|
|
41
|
+
export function isNull(obj) {
|
|
42
|
+
return obj === null;
|
|
43
|
+
}
|
|
44
|
+
export function isNullOrUndefined(obj) {
|
|
45
|
+
return obj === null || obj === undefined;
|
|
46
|
+
}
|
|
47
|
+
export function isFunction(obj) {
|
|
48
|
+
return typeof obj === "function";
|
|
49
|
+
}
|
|
50
|
+
export function isEmptyObject(obj) {
|
|
51
|
+
return isObject(obj) && Object.keys(obj).length === 0;
|
|
52
|
+
}
|
|
53
|
+
export function isEmptyReactNode(content, trim) {
|
|
54
|
+
if (content === null || content === undefined || content === false) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (typeof content === "string" && (trim ? content.trim() === "" : content === "")) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
export function isExist(obj) {
|
|
63
|
+
return obj || obj === 0;
|
|
64
|
+
}
|
|
65
|
+
export function isWindow(el) {
|
|
66
|
+
return el === window;
|
|
67
|
+
}
|
|
68
|
+
export function isBoolean(value) {
|
|
69
|
+
return typeof value === "boolean";
|
|
70
|
+
}
|
|
71
|
+
export const isReactComponent = element => {
|
|
72
|
+
return element && /*#__PURE__*/isValidElement(element) && typeof element.type === "function";
|
|
73
|
+
};
|
|
74
|
+
export const isClassComponent = element => {
|
|
75
|
+
var _element$type$prototy;
|
|
76
|
+
return isReactComponent(element) && !!((_element$type$prototy = element.type.prototype) !== null && _element$type$prototy !== void 0 && _element$type$prototy.isReactComponent);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// element 是合成的 dom 元素或者字符串,数字等
|
|
80
|
+
export const isDOMElement = element => {
|
|
81
|
+
return /*#__PURE__*/isValidElement(element) && typeof element.type === "string";
|
|
82
|
+
};
|
|
83
|
+
export const isLink = text => {
|
|
84
|
+
return isString(text) && (text.startsWith("http") || text.startsWith("https"));
|
|
85
|
+
};
|
|
86
|
+
export async function isImageLinkAvailable(url) {
|
|
87
|
+
return new Promise(resolve => {
|
|
88
|
+
const img = new Image();
|
|
89
|
+
img.onload = () => resolve(true);
|
|
90
|
+
img.onerror = () => resolve(false);
|
|
91
|
+
img.src = url;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function isMobile() {
|
|
95
|
+
return clientWindow && /Android|iPhone|iPad|iPod|Windows Phone|BlackBerry|Mobile/i.test(clientWindow === null || clientWindow === void 0 ? void 0 : clientWindow.navigator.userAgent);
|
|
96
|
+
}
|
|
97
|
+
export function isEmail(email) {
|
|
98
|
+
const emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
|
|
99
|
+
return emailReg.test(email);
|
|
100
|
+
}
|
|
101
|
+
export function isSmsCode(code) {
|
|
102
|
+
const codeReg = /\d{6}/;
|
|
103
|
+
return codeReg.test(code);
|
|
104
|
+
}
|
|
105
|
+
export function isUsPhoneNumber(phone) {
|
|
106
|
+
const phoneRegex = /^[2-9]\d{2}[2-9]\d{6}$/;
|
|
107
|
+
return phoneRegex.test(phone);
|
|
108
|
+
}
|
|
109
|
+
export function isPromise(obj) {
|
|
110
|
+
return !!obj && typeof obj === "object" && typeof obj.then === "function";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 判断是否为Android设备
|
|
115
|
+
* @returns 是否为Android设备
|
|
116
|
+
*/
|
|
117
|
+
export function isAndroid() {
|
|
118
|
+
return canUseDom ? /android/.test(navigator.userAgent.toLowerCase()) : false;
|
|
119
|
+
}
|
|
120
|
+
export function isIOS() {
|
|
121
|
+
return canUseDom ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
|
122
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { AriaAttributes } from "react";
|
|
2
|
+
import type { CSSProperties, ReactElement } from "react";
|
|
3
|
+
export type NativeProps<S extends string = never> = {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: CSSProperties & Partial<Record<S, string>>;
|
|
6
|
+
tabIndex?: number;
|
|
7
|
+
} & AriaAttributes;
|
|
8
|
+
export declare function withNativeProps<P extends NativeProps>(props: P, element: ReactElement): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import React from "react";
|
|
7
|
+
import cs from "./classNames";
|
|
8
|
+
export function withNativeProps(props, element) {
|
|
9
|
+
const p = _objectSpread({}, element.props);
|
|
10
|
+
if (props.className) {
|
|
11
|
+
p.className = cs(element.props.className, props.className);
|
|
12
|
+
}
|
|
13
|
+
if (props.style) {
|
|
14
|
+
p.style = _objectSpread(_objectSpread({}, p.style), props.style);
|
|
15
|
+
}
|
|
16
|
+
if (props.tabIndex !== undefined) {
|
|
17
|
+
p.tabIndex = props.tabIndex;
|
|
18
|
+
}
|
|
19
|
+
for (const key in props) {
|
|
20
|
+
if (!props.hasOwnProperty(key)) continue;
|
|
21
|
+
if (key.startsWith("data-") || key.startsWith("aria-")) {
|
|
22
|
+
p[key] = props[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return /*#__PURE__*/React.cloneElement(element, p);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function omit<T extends object, K extends keyof T>(obj: T, keys: Array<K | string>): Omit<T, K>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
// delete keys from object
|
|
7
|
+
export default function omit(obj, keys) {
|
|
8
|
+
const clone = _objectSpread({}, obj);
|
|
9
|
+
keys.forEach(key => {
|
|
10
|
+
if (key in clone) {
|
|
11
|
+
delete clone[key];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return clone;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import QRCode from "qrcode";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 根据入参生成一个二维码
|
|
5
|
+
* @param url 要生成二维码的url
|
|
6
|
+
* @returns Promise
|
|
7
|
+
*/
|
|
8
|
+
const makeQrcode = url => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
QRCode.toDataURL(url).then(qrcodeUrl => {
|
|
11
|
+
resolve(qrcodeUrl);
|
|
12
|
+
}).catch(err => {
|
|
13
|
+
reject(err);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default makeQrcode;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
export type GetContainer = HTMLElement | (() => HTMLElement) | null;
|
|
3
|
+
export declare function renderToContainer(getContainer: GetContainer, node: ReactElement): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createPortal } from "react-dom";
|
|
2
|
+
import { resolveContainer } from "./get-container";
|
|
3
|
+
import { canUseDom } from "./can-use-dom";
|
|
4
|
+
export function renderToContainer(getContainer, node) {
|
|
5
|
+
if (canUseDom && getContainer) {
|
|
6
|
+
const container = resolveContainer(getContainer);
|
|
7
|
+
return /*#__PURE__*/createPortal(node, container);
|
|
8
|
+
}
|
|
9
|
+
return node;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC, ReactElement } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
active: boolean;
|
|
4
|
+
forceRender?: boolean;
|
|
5
|
+
destroyOnClose?: boolean;
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
}
|
|
8
|
+
export declare const ShouldRender: FC<Props>;
|
|
9
|
+
export declare function useShouldRender(active: boolean, forceRender?: boolean, destroyOnClose?: boolean): boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useInitialized } from "../hooks/use-initialized";
|
|
2
|
+
export const ShouldRender = props => {
|
|
3
|
+
const shouldRender = useShouldRender(props.active, props.forceRender, props.destroyOnClose);
|
|
4
|
+
return shouldRender ? props.children : null;
|
|
5
|
+
};
|
|
6
|
+
export function useShouldRender(active, forceRender, destroyOnClose) {
|
|
7
|
+
const initialized = useInitialized(active);
|
|
8
|
+
if (forceRender) return true;
|
|
9
|
+
if (active) return true;
|
|
10
|
+
if (!initialized) return false;
|
|
11
|
+
return !destroyOnClose;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare let supportsPassive: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { canUseDom } from "./can-use-dom";
|
|
2
|
+
export let supportsPassive = false;
|
|
3
|
+
if (canUseDom) {
|
|
4
|
+
try {
|
|
5
|
+
const opts = {};
|
|
6
|
+
Object.defineProperty(opts, "passive", {
|
|
7
|
+
get() {
|
|
8
|
+
supportsPassive = true;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
window.addEventListener("test-passive", null, opts);
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
} catch (e) {}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function warning(condition: boolean, message: string, ...extra: any): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function warning(condition, message) {
|
|
2
|
+
if (process.env.NODE_ENV !== 'production' && console) {
|
|
3
|
+
if (condition) {
|
|
4
|
+
for (var _len = arguments.length, extra = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
5
|
+
extra[_key - 2] = arguments[_key];
|
|
6
|
+
}
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
return console.error("[pay-sdk-react]: ".concat(message), extra ? {
|
|
9
|
+
detail: extra
|
|
10
|
+
} : undefined);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function mergeProps<A, B>(a: A, b: B): B & A;
|
|
2
|
+
export declare function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A;
|
|
3
|
+
export declare function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A;
|
|
4
|
+
/**
|
|
5
|
+
* Merge props and return the first non-undefined value.
|
|
6
|
+
* The later has higher priority. e.g. (10, 1, 5) => 5 wins.
|
|
7
|
+
* This is useful with legacy props that have been deprecated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeProp<T, DefaultT extends T = T>(defaultProp: DefaultT, ...propList: T[]): T | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function mergeProps() {
|
|
2
|
+
const ret = {};
|
|
3
|
+
for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4
|
+
items[_key] = arguments[_key];
|
|
5
|
+
}
|
|
6
|
+
items.forEach(item => {
|
|
7
|
+
if (item) {
|
|
8
|
+
Object.keys(item).forEach(key => {
|
|
9
|
+
if (item[key] !== undefined) {
|
|
10
|
+
ret[key] = item[key];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return ret;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Merge props and return the first non-undefined value.
|
|
20
|
+
* The later has higher priority. e.g. (10, 1, 5) => 5 wins.
|
|
21
|
+
* This is useful with legacy props that have been deprecated.
|
|
22
|
+
*/
|
|
23
|
+
export function mergeProp(defaultProp) {
|
|
24
|
+
for (var _len2 = arguments.length, propList = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
25
|
+
propList[_key2 - 1] = arguments[_key2];
|
|
26
|
+
}
|
|
27
|
+
for (let i = propList.length - 1; i >= 0; i -= 1) {
|
|
28
|
+
if (propList[i] !== undefined) {
|
|
29
|
+
return propList[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return defaultProp;
|
|
33
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
export type PropagationEvent = "click" | "touchstart";
|
|
4
|
+
export declare function withStopPropagation(events: PropagationEvent[], element: ReactElement): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import React from "react";
|
|
7
|
+
const eventToPropRecord = {
|
|
8
|
+
click: "onClick",
|
|
9
|
+
touchstart: "onTouchStart"
|
|
10
|
+
};
|
|
11
|
+
export function withStopPropagation(events, element) {
|
|
12
|
+
const props = _objectSpread({}, element.props);
|
|
13
|
+
for (const key of events) {
|
|
14
|
+
const prop = eventToPropRecord[key];
|
|
15
|
+
props[prop] = function (e) {
|
|
16
|
+
var _element$props$prop, _element$props;
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
(_element$props$prop = (_element$props = element.props)[prop]) === null || _element$props$prop === void 0 || _element$props$prop.call(_element$props, e);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/React.cloneElement(element, props);
|
|
22
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _airwallexPopup = _interopRequireDefault(require("./airwallex-popup"));
|
|
9
|
+
var _airwallexModal = _interopRequireDefault(require("./airwallex-modal"));
|
|
10
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
11
|
+
var _PayMask = _interopRequireDefault(require("../PayMask"));
|
|
12
|
+
var _omit = _interopRequireDefault(require("../utils/omit"));
|
|
13
|
+
const _excluded = ["children", "onClick", "createOrder"];
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
18
|
+
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; }
|
|
19
|
+
const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
20
|
+
const {
|
|
21
|
+
children = 'Airwallex',
|
|
22
|
+
onClick,
|
|
23
|
+
createOrder
|
|
24
|
+
} = props,
|
|
25
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
26
|
+
const airwallexButtonRef = (0, _react.useRef)({
|
|
27
|
+
nativeElement: null
|
|
28
|
+
});
|
|
29
|
+
const airwallexPopupRef = (0, _react.useRef)(null);
|
|
30
|
+
const airwallexModalRef = (0, _react.useRef)(null);
|
|
31
|
+
const [showMask, setShowMask] = (0, _react.useState)(false);
|
|
32
|
+
const [airwallexUrl, setAirwallexUrl] = (0, _react.useState)();
|
|
33
|
+
(0, _react.useImperativeHandle)(ref, () => airwallexButtonRef.current);
|
|
34
|
+
const handlePayCreateOrder = (0, _react.useCallback)(async () => {
|
|
35
|
+
if (createOrder) {
|
|
36
|
+
// 1. 业务侧创建订单,获取参数
|
|
37
|
+
const options = await (createOrder === null || createOrder === void 0 ? void 0 : createOrder());
|
|
38
|
+
if (options) {
|
|
39
|
+
if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
|
|
40
|
+
if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
|
|
41
|
+
var _airwallexModalRef$cu;
|
|
42
|
+
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu = airwallexModalRef.current) === null || _airwallexModalRef$cu === void 0 || _airwallexModalRef$cu.open(options);
|
|
43
|
+
} else {
|
|
44
|
+
var _airwallexPopupRef$cu;
|
|
45
|
+
(_airwallexPopupRef$cu = airwallexPopupRef.current) === null || _airwallexPopupRef$cu === void 0 || _airwallexPopupRef$cu.open(options);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
setShowMask(true);
|
|
49
|
+
setAirwallexUrl(options.airwallexUrl);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, [createOrder, props]);
|
|
54
|
+
const handleClick = (0, _react.useCallback)(e => {
|
|
55
|
+
onClick === null || onClick === void 0 || onClick(e);
|
|
56
|
+
if (createOrder) {
|
|
57
|
+
handlePayCreateOrder();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
|
|
61
|
+
if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
|
|
62
|
+
var _airwallexModalRef$cu2;
|
|
63
|
+
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu2 = airwallexModalRef.current) === null || _airwallexModalRef$cu2 === void 0 || _airwallexModalRef$cu2.open();
|
|
64
|
+
} else {
|
|
65
|
+
var _airwallexPopupRef$cu2;
|
|
66
|
+
airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu2 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu2 === void 0 || _airwallexPopupRef$cu2.open();
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if ((props === null || props === void 0 ? void 0 : props.payMode) === 'redirect') {
|
|
71
|
+
setShowMask(true);
|
|
72
|
+
setAirwallexUrl(props === null || props === void 0 ? void 0 : props.airwallexUrl);
|
|
73
|
+
}
|
|
74
|
+
}, [onClick, createOrder, handlePayCreateOrder, props]);
|
|
75
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
|
|
76
|
+
ref: airwallexButtonRef,
|
|
77
|
+
onClick: handleClick
|
|
78
|
+
}, (0, _omit.default)(others, ['payMode', 'displayType', 'createOrder', 'airwallexUrl', 'maskProps', 'popupProps', 'modalProps'])), children), (props === null || props === void 0 ? void 0 : props.payMode) === 'embedded' && (props === null || props === void 0 ? void 0 : props.displayType) === 'popup' && /*#__PURE__*/_react.default.createElement(_airwallexPopup.default, _extends({
|
|
79
|
+
ref: airwallexPopupRef
|
|
80
|
+
}, props === null || props === void 0 ? void 0 : props.popupProps)), (props === null || props === void 0 ? void 0 : props.payMode) === 'embedded' && (props === null || props === void 0 ? void 0 : props.displayType) === 'modal' && /*#__PURE__*/_react.default.createElement(_airwallexModal.default, _extends({
|
|
81
|
+
ref: airwallexModalRef
|
|
82
|
+
}, props === null || props === void 0 ? void 0 : props.modalProps)), (props === null || props === void 0 ? void 0 : props.payMode) === 'redirect' && showMask && airwallexUrl && /*#__PURE__*/_react.default.createElement(_PayMask.default, _extends({
|
|
83
|
+
visible: showMask,
|
|
84
|
+
onClose: () => {
|
|
85
|
+
var _props$maskProps, _props$maskProps$onCl;
|
|
86
|
+
setShowMask(false);
|
|
87
|
+
props === null || props === void 0 || (_props$maskProps = props.maskProps) === null || _props$maskProps === void 0 || (_props$maskProps$onCl = _props$maskProps.onClose) === null || _props$maskProps$onCl === void 0 || _props$maskProps$onCl.call(_props$maskProps);
|
|
88
|
+
},
|
|
89
|
+
payUrl: airwallexUrl,
|
|
90
|
+
title: 'Airwallex'
|
|
91
|
+
}, (0, _omit.default)((props === null || props === void 0 ? void 0 : props.maskProps) || {}, ['onClose']))));
|
|
92
|
+
});
|
|
93
|
+
AirwallexButton.displayName = 'AirwallexButton';
|
|
94
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AirwallexButton);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _payModal = _interopRequireDefault(require("../pay-modal"));
|
|
9
|
+
var _airwallex = _interopRequireDefault(require("./airwallex"));
|
|
10
|
+
var _omit = _interopRequireDefault(require("../utils/omit"));
|
|
11
|
+
const _excluded = ["airwallexProps", "visible", "onClose", "footer"];
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
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; }
|
|
16
|
+
const AirwallexModal = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
17
|
+
const {
|
|
18
|
+
airwallexProps: propsAirwallexProps,
|
|
19
|
+
visible,
|
|
20
|
+
onClose,
|
|
21
|
+
footer = null
|
|
22
|
+
} = props,
|
|
23
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
24
|
+
const airwallexRef = (0, _react.useRef)(null);
|
|
25
|
+
const [uncontrolledVisible, setUncontrolledVisible] = (0, _react.useState)(false);
|
|
26
|
+
const [airwallexProps, setAirwallexProps] = (0, _react.useState)();
|
|
27
|
+
const isControlled = visible !== undefined;
|
|
28
|
+
const _visible = isControlled ? visible : uncontrolledVisible;
|
|
29
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
30
|
+
open: value => {
|
|
31
|
+
if (value) {
|
|
32
|
+
setAirwallexProps(value);
|
|
33
|
+
}
|
|
34
|
+
setUncontrolledVisible(true);
|
|
35
|
+
},
|
|
36
|
+
close: () => {
|
|
37
|
+
setUncontrolledVisible(false);
|
|
38
|
+
onClose === null || onClose === void 0 || onClose();
|
|
39
|
+
},
|
|
40
|
+
current: airwallexRef.current
|
|
41
|
+
}));
|
|
42
|
+
const _airwallexProps = propsAirwallexProps !== null && propsAirwallexProps !== void 0 ? propsAirwallexProps : airwallexProps;
|
|
43
|
+
return /*#__PURE__*/React.createElement(_payModal.default, _extends({
|
|
44
|
+
visible: _visible,
|
|
45
|
+
onClose: () => {
|
|
46
|
+
if (!isControlled) {
|
|
47
|
+
setUncontrolledVisible(false);
|
|
48
|
+
}
|
|
49
|
+
onClose === null || onClose === void 0 || onClose();
|
|
50
|
+
},
|
|
51
|
+
footer: footer
|
|
52
|
+
}, rest), _airwallexProps && /*#__PURE__*/React.createElement(_airwallex.default, _extends({
|
|
53
|
+
onSuccess: () => {
|
|
54
|
+
var _airwallexProps$onSuc;
|
|
55
|
+
if (!isControlled) {
|
|
56
|
+
setUncontrolledVisible(false);
|
|
57
|
+
}
|
|
58
|
+
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onSuc = _airwallexProps.onSuccess) === null || _airwallexProps$onSuc === void 0 || _airwallexProps$onSuc.call(_airwallexProps);
|
|
59
|
+
},
|
|
60
|
+
onError: () => {
|
|
61
|
+
var _airwallexProps$onErr;
|
|
62
|
+
if (!isControlled) {
|
|
63
|
+
setUncontrolledVisible(false);
|
|
64
|
+
}
|
|
65
|
+
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onErr = _airwallexProps.onError) === null || _airwallexProps$onErr === void 0 || _airwallexProps$onErr.call(_airwallexProps);
|
|
66
|
+
}
|
|
67
|
+
}, (0, _omit.default)(_airwallexProps, ['onSuccess', 'onError']))));
|
|
68
|
+
});
|
|
69
|
+
AirwallexModal.displayName = 'AirwallexModal';
|
|
70
|
+
var _default = exports.default = AirwallexModal;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _airwallex = _interopRequireDefault(require("./airwallex"));
|
|
9
|
+
var _payPopup = _interopRequireDefault(require("../pay-popup"));
|
|
10
|
+
var _omit = _interopRequireDefault(require("../utils/omit"));
|
|
11
|
+
const _excluded = ["visible", "onClose", "closeOnMaskClick", "bodyStyle", "airwallexProps"];
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
20
|
+
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; }
|
|
21
|
+
const AirwallexPopup = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
22
|
+
const {
|
|
23
|
+
visible: controlledVisible,
|
|
24
|
+
onClose,
|
|
25
|
+
closeOnMaskClick = true,
|
|
26
|
+
bodyStyle,
|
|
27
|
+
airwallexProps: propsAirwallexProps
|
|
28
|
+
} = props,
|
|
29
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
30
|
+
const airwallexRef = (0, _react.useRef)(null);
|
|
31
|
+
const [uncontrolledVisible, setUncontrolledVisible] = (0, _react.useState)(false);
|
|
32
|
+
const [airwallexProps, setAirwallexProps] = (0, _react.useState)();
|
|
33
|
+
const isControlled = controlledVisible !== undefined;
|
|
34
|
+
const visible = isControlled ? controlledVisible : uncontrolledVisible;
|
|
35
|
+
const _airwallexProps = propsAirwallexProps !== null && propsAirwallexProps !== void 0 ? propsAirwallexProps : airwallexProps;
|
|
36
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
37
|
+
open: value => {
|
|
38
|
+
if (value) {
|
|
39
|
+
setAirwallexProps(value);
|
|
40
|
+
}
|
|
41
|
+
setUncontrolledVisible(true);
|
|
42
|
+
},
|
|
43
|
+
close: () => {
|
|
44
|
+
setUncontrolledVisible(false);
|
|
45
|
+
onClose === null || onClose === void 0 || onClose();
|
|
46
|
+
},
|
|
47
|
+
current: airwallexRef.current
|
|
48
|
+
}));
|
|
49
|
+
return /*#__PURE__*/React.createElement(_payPopup.default, _extends({
|
|
50
|
+
visible: visible,
|
|
51
|
+
closeOnMaskClick: closeOnMaskClick,
|
|
52
|
+
onClose: () => {
|
|
53
|
+
if (!isControlled) {
|
|
54
|
+
setUncontrolledVisible(false);
|
|
55
|
+
}
|
|
56
|
+
onClose === null || onClose === void 0 || onClose();
|
|
57
|
+
},
|
|
58
|
+
bodyStyle: _objectSpread({
|
|
59
|
+
padding: 12,
|
|
60
|
+
height: "40vh",
|
|
61
|
+
overflowY: "scroll"
|
|
62
|
+
}, bodyStyle)
|
|
63
|
+
}, others), _airwallexProps && /*#__PURE__*/React.createElement(_airwallex.default, _extends({
|
|
64
|
+
onSuccess: () => {
|
|
65
|
+
var _airwallexProps$onSuc;
|
|
66
|
+
if (!isControlled) {
|
|
67
|
+
setUncontrolledVisible(false);
|
|
68
|
+
}
|
|
69
|
+
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onSuc = _airwallexProps.onSuccess) === null || _airwallexProps$onSuc === void 0 || _airwallexProps$onSuc.call(_airwallexProps);
|
|
70
|
+
},
|
|
71
|
+
onError: () => {
|
|
72
|
+
var _airwallexProps$onErr;
|
|
73
|
+
if (!isControlled) {
|
|
74
|
+
setUncontrolledVisible(false);
|
|
75
|
+
}
|
|
76
|
+
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onErr = _airwallexProps.onError) === null || _airwallexProps$onErr === void 0 || _airwallexProps$onErr.call(_airwallexProps);
|
|
77
|
+
}
|
|
78
|
+
}, (0, _omit.default)(_airwallexProps, ["onSuccess", "onError"]))));
|
|
79
|
+
});
|
|
80
|
+
AirwallexPopup.displayName = "AirwallexPopup";
|
|
81
|
+
var _default = exports.default = AirwallexPopup;
|