@depay/widgets 6.0.1 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/esm/index.bundle.js +1463 -4354
- package/dist/esm/index.js +223 -5
- package/dist/umd/index.bundle.js +1463 -4354
- package/dist/umd/index.js +223 -5
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -996,12 +996,25 @@ var Dialog$1 = (function (props) {
|
|
|
996
996
|
});
|
|
997
997
|
|
|
998
998
|
var ConnectingWalletDialog = (function (props) {
|
|
999
|
+
var _useState = useState(false),
|
|
1000
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1001
|
+
showConnectButton = _useState2[0],
|
|
1002
|
+
setShowConnectButton = _useState2[1];
|
|
1003
|
+
|
|
999
1004
|
var _useContext = useContext(NavigateStackContext),
|
|
1000
1005
|
navigate = _useContext.navigate;
|
|
1001
1006
|
|
|
1002
1007
|
var wallet = props.wallet;
|
|
1003
1008
|
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
1004
1009
|
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
1010
|
+
useEffect(function () {
|
|
1011
|
+
var timeout = setTimeout(function () {
|
|
1012
|
+
return setShowConnectButton(true);
|
|
1013
|
+
}, 10000);
|
|
1014
|
+
return function () {
|
|
1015
|
+
return clearTimeout(timeout);
|
|
1016
|
+
};
|
|
1017
|
+
}, []);
|
|
1005
1018
|
|
|
1006
1019
|
if (props.pending) {
|
|
1007
1020
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
@@ -1041,7 +1054,7 @@ var ConnectingWalletDialog = (function (props) {
|
|
|
1041
1054
|
},
|
|
1042
1055
|
className: "TextButton"
|
|
1043
1056
|
}, "Connect with another wallet")))),
|
|
1044
|
-
footer: /*#__PURE__*/React.createElement("div", {
|
|
1057
|
+
footer: showConnectButton && /*#__PURE__*/React.createElement("div", {
|
|
1045
1058
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
1046
1059
|
}, /*#__PURE__*/React.createElement("button", {
|
|
1047
1060
|
className: "ButtonPrimary",
|
|
@@ -1670,7 +1683,7 @@ var CardStyle = (function (style) {
|
|
|
1670
1683
|
});
|
|
1671
1684
|
|
|
1672
1685
|
var DialogStyle = (function (style) {
|
|
1673
|
-
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 0.8rem;\n }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n max-height:
|
|
1686
|
+
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 0.8rem;\n }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n max-height: 60vh !important;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogStackCell {\n vertical-align: bottom;\n }\n\n .ReactDialogAnimation {\n bottom: -100px !important;\n max-height: 66vh !important;\n top: inherit !important;\n transition: opacity 0.4s ease, bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n }\n\n .DialogBody {\n background: rgb(248,248,248);\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .DialogBody.HeightAuto {\n height: auto;\n }\n\n .DialogHeader {\n background: rgb(248,248,248);\n border-top-left-radius: 0.8rem;\n border-top-right-radius: 0.8rem;\n display: flex;\n flex-direction: row;\n position: relative;\n }\n\n .DialogHeaderTitle {\n flex-basis: auto;\n flex-grow: 1;\n }\n \n .DialogHeaderAction {\n height: 3rem;\n }\n\n .DialogFooter {\n background: rgb(248,248,248);\n border-bottom-left-radius: 0.8rem;\n border-bottom-right-radius: 0.8rem;\n line-height: 1.5rem;\n min-height: 2rem;\n position: relative;\n text-align: center;\n }\n\n .ReactShadowDOMInsideContainer > .ReactDialog {\n display: table;\n }\n\n ";
|
|
1674
1687
|
});
|
|
1675
1688
|
|
|
1676
1689
|
var FontStyle = (function (style) {
|
|
@@ -1823,11 +1836,36 @@ var Connect = function Connect(options) {
|
|
|
1823
1836
|
|
|
1824
1837
|
return new Promise( /*#__PURE__*/function () {
|
|
1825
1838
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(resolve, reject) {
|
|
1839
|
+
var wallet, accounts;
|
|
1826
1840
|
return regenerator.wrap(function _callee$(_context) {
|
|
1827
1841
|
while (1) {
|
|
1828
1842
|
switch (_context.prev = _context.next) {
|
|
1829
1843
|
case 0:
|
|
1830
|
-
getWallet();
|
|
1844
|
+
wallet = getWallet();
|
|
1845
|
+
|
|
1846
|
+
if (!wallet) {
|
|
1847
|
+
_context.next = 7;
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
_context.next = 4;
|
|
1852
|
+
return wallet.accounts();
|
|
1853
|
+
|
|
1854
|
+
case 4:
|
|
1855
|
+
accounts = _context.sent;
|
|
1856
|
+
|
|
1857
|
+
if (!(accounts instanceof Array && accounts.length > 0)) {
|
|
1858
|
+
_context.next = 7;
|
|
1859
|
+
break;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
return _context.abrupt("return", resolve({
|
|
1863
|
+
wallet: wallet,
|
|
1864
|
+
accounts: accounts,
|
|
1865
|
+
account: accounts[0]
|
|
1866
|
+
}));
|
|
1867
|
+
|
|
1868
|
+
case 7:
|
|
1831
1869
|
mount({
|
|
1832
1870
|
style: style,
|
|
1833
1871
|
document: ensureDocument(document)
|
|
@@ -1854,7 +1892,7 @@ var Connect = function Connect(options) {
|
|
|
1854
1892
|
};
|
|
1855
1893
|
});
|
|
1856
1894
|
|
|
1857
|
-
case
|
|
1895
|
+
case 8:
|
|
1858
1896
|
case "end":
|
|
1859
1897
|
return _context.stop();
|
|
1860
1898
|
}
|
|
@@ -3748,6 +3786,185 @@ var Donation = /*#__PURE__*/function () {
|
|
|
3748
3786
|
};
|
|
3749
3787
|
}();
|
|
3750
3788
|
|
|
3789
|
+
var SignLoginDialog = (function (props) {
|
|
3790
|
+
var _useContext = useContext(ErrorContext),
|
|
3791
|
+
setError = _useContext.setError;
|
|
3792
|
+
|
|
3793
|
+
var _useState = useState(false),
|
|
3794
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3795
|
+
showSignButton = _useState2[0],
|
|
3796
|
+
setShowSignButton = _useState2[1];
|
|
3797
|
+
|
|
3798
|
+
var _useContext2 = useContext(ConfigurationContext),
|
|
3799
|
+
message = _useContext2.message,
|
|
3800
|
+
endpoint = _useContext2.endpoint;
|
|
3801
|
+
|
|
3802
|
+
var _useContext3 = useContext(ConfigurationContext),
|
|
3803
|
+
recover = _useContext3.recover;
|
|
3804
|
+
|
|
3805
|
+
var wallet = getWallet();
|
|
3806
|
+
wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
|
|
3807
|
+
var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
|
|
3808
|
+
|
|
3809
|
+
if (typeof recover != 'function') {
|
|
3810
|
+
recover = function recover(_ref) {
|
|
3811
|
+
var message = _ref.message,
|
|
3812
|
+
signature = _ref.signature;
|
|
3813
|
+
return new Promise(function (resolve, reject) {
|
|
3814
|
+
fetch(endpoint, {
|
|
3815
|
+
method: 'POST',
|
|
3816
|
+
body: JSON.stringify({
|
|
3817
|
+
message: message,
|
|
3818
|
+
signature: signature
|
|
3819
|
+
})
|
|
3820
|
+
}).then(function (response) {
|
|
3821
|
+
if (response.status == 200) {
|
|
3822
|
+
response.text().then(function (account) {
|
|
3823
|
+
resolve(account);
|
|
3824
|
+
})["catch"](setError);
|
|
3825
|
+
} else {
|
|
3826
|
+
response.text().then(function (text) {
|
|
3827
|
+
setError(text || 'Recovering login signature failed!');
|
|
3828
|
+
});
|
|
3829
|
+
}
|
|
3830
|
+
});
|
|
3831
|
+
});
|
|
3832
|
+
};
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
var login = function login() {
|
|
3836
|
+
wallet.sign(message).then(function (signature) {
|
|
3837
|
+
recover({
|
|
3838
|
+
message: message,
|
|
3839
|
+
signature: signature
|
|
3840
|
+
}).then(props.resolve)["catch"](setError);
|
|
3841
|
+
})["catch"](setError);
|
|
3842
|
+
};
|
|
3843
|
+
|
|
3844
|
+
useEffect(login, []);
|
|
3845
|
+
useEffect(function () {
|
|
3846
|
+
var timeout = setTimeout(function () {
|
|
3847
|
+
return setShowSignButton(true);
|
|
3848
|
+
}, 10000);
|
|
3849
|
+
return function () {
|
|
3850
|
+
return clearTimeout(timeout);
|
|
3851
|
+
};
|
|
3852
|
+
}, []);
|
|
3853
|
+
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
3854
|
+
stacked: true,
|
|
3855
|
+
body: /*#__PURE__*/React.createElement("div", null, walletLogo && /*#__PURE__*/React.createElement("div", {
|
|
3856
|
+
className: "GraphicWrapper PaddingTopS PaddingBottomS"
|
|
3857
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
3858
|
+
className: "Graphic",
|
|
3859
|
+
src: walletLogo
|
|
3860
|
+
})), /*#__PURE__*/React.createElement("h1", {
|
|
3861
|
+
className: "LineHeightL Text FontSizeL FontWeightBold PaddingTopS"
|
|
3862
|
+
}, "Wallet Login"), /*#__PURE__*/React.createElement("div", {
|
|
3863
|
+
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
3864
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
3865
|
+
className: "FontSizeM PaddingLeftM PaddingRightM"
|
|
3866
|
+
}, "Please sign the login message with your connected wallet."))),
|
|
3867
|
+
footer: showSignButton && /*#__PURE__*/React.createElement("div", {
|
|
3868
|
+
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
3869
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
3870
|
+
className: "ButtonPrimary",
|
|
3871
|
+
onClick: login
|
|
3872
|
+
}, "Log in"))
|
|
3873
|
+
});
|
|
3874
|
+
});
|
|
3875
|
+
|
|
3876
|
+
var LoginStack = (function (props) {
|
|
3877
|
+
var _useContext = useContext(ClosableContext),
|
|
3878
|
+
open = _useContext.open,
|
|
3879
|
+
close = _useContext.close;
|
|
3880
|
+
|
|
3881
|
+
var _useState = useState(true),
|
|
3882
|
+
_useState2 = _slicedToArray(_useState, 2);
|
|
3883
|
+
_useState2[0];
|
|
3884
|
+
_useState2[1];
|
|
3885
|
+
|
|
3886
|
+
return /*#__PURE__*/React.createElement(ReactDialogStack, {
|
|
3887
|
+
open: open,
|
|
3888
|
+
close: close,
|
|
3889
|
+
start: "SignLogin",
|
|
3890
|
+
container: props.container,
|
|
3891
|
+
document: props.document,
|
|
3892
|
+
dialogs: {
|
|
3893
|
+
SignLogin: /*#__PURE__*/React.createElement(SignLoginDialog, {
|
|
3894
|
+
resolve: props.resolve
|
|
3895
|
+
})
|
|
3896
|
+
}
|
|
3897
|
+
});
|
|
3898
|
+
});
|
|
3899
|
+
|
|
3900
|
+
var Login = function Login(options) {
|
|
3901
|
+
var style, error, document, message, endpoint, recover;
|
|
3902
|
+
|
|
3903
|
+
if (_typeof(options) == 'object') {
|
|
3904
|
+
style = options.style;
|
|
3905
|
+
error = options.error;
|
|
3906
|
+
document = options.document;
|
|
3907
|
+
message = options.message;
|
|
3908
|
+
endpoint = options.endpoint;
|
|
3909
|
+
recover = options.recover;
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3912
|
+
return new Promise( /*#__PURE__*/function () {
|
|
3913
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
|
|
3914
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
3915
|
+
while (1) {
|
|
3916
|
+
switch (_context.prev = _context.next) {
|
|
3917
|
+
case 0:
|
|
3918
|
+
Connect().then(function () {
|
|
3919
|
+
mount({
|
|
3920
|
+
style: style,
|
|
3921
|
+
document: ensureDocument(document)
|
|
3922
|
+
}, function (unmount) {
|
|
3923
|
+
var rejectBeforeUnmount = function rejectBeforeUnmount() {
|
|
3924
|
+
reject('USER_CLOSED_DIALOG');
|
|
3925
|
+
unmount();
|
|
3926
|
+
};
|
|
3927
|
+
|
|
3928
|
+
return function (container) {
|
|
3929
|
+
return /*#__PURE__*/React.createElement(ErrorProvider, {
|
|
3930
|
+
error: error,
|
|
3931
|
+
container: container,
|
|
3932
|
+
unmount: unmount
|
|
3933
|
+
}, /*#__PURE__*/React.createElement(ConfigurationProvider, {
|
|
3934
|
+
configuration: {
|
|
3935
|
+
message: message,
|
|
3936
|
+
endpoint: endpoint || '/login',
|
|
3937
|
+
recover: recover
|
|
3938
|
+
}
|
|
3939
|
+
}, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
|
|
3940
|
+
unmount: rejectBeforeUnmount
|
|
3941
|
+
}, /*#__PURE__*/React.createElement(LoginStack, {
|
|
3942
|
+
document: document,
|
|
3943
|
+
container: container,
|
|
3944
|
+
resolve: function resolve(account) {
|
|
3945
|
+
unmount();
|
|
3946
|
+
|
|
3947
|
+
_resolve(account);
|
|
3948
|
+
}
|
|
3949
|
+
}), /*#__PURE__*/React.createElement(PoweredBy, null)))));
|
|
3950
|
+
};
|
|
3951
|
+
});
|
|
3952
|
+
})["catch"](reject);
|
|
3953
|
+
|
|
3954
|
+
case 1:
|
|
3955
|
+
case "end":
|
|
3956
|
+
return _context.stop();
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
}, _callee);
|
|
3960
|
+
}));
|
|
3961
|
+
|
|
3962
|
+
return function (_x, _x2) {
|
|
3963
|
+
return _ref.apply(this, arguments);
|
|
3964
|
+
};
|
|
3965
|
+
}());
|
|
3966
|
+
};
|
|
3967
|
+
|
|
3751
3968
|
var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
|
|
3752
3969
|
|
|
3753
3970
|
var PaymentAmountRoutingProvider = (function (props) {
|
|
@@ -4456,9 +4673,10 @@ var Sale = /*#__PURE__*/function () {
|
|
|
4456
4673
|
|
|
4457
4674
|
var DePayWidgets = {
|
|
4458
4675
|
Connect: Connect,
|
|
4676
|
+
Donation: Donation,
|
|
4677
|
+
Login: Login,
|
|
4459
4678
|
Payment: Payment,
|
|
4460
4679
|
Sale: Sale,
|
|
4461
|
-
Donation: Donation,
|
|
4462
4680
|
provider: provider
|
|
4463
4681
|
};
|
|
4464
4682
|
|