@depay/widgets 5.1.0 → 6.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.
@@ -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",
@@ -1119,8 +1132,10 @@ var SelectWalletDialog = (function (props) {
1119
1132
  }
1120
1133
 
1121
1134
  var walletCards = availableWallets.map(function (wallet, index) {
1122
- return /*#__PURE__*/React.createElement("button", {
1135
+ return /*#__PURE__*/React.createElement("div", {
1123
1136
  key: index,
1137
+ className: "PaddingBottomXS"
1138
+ }, /*#__PURE__*/React.createElement("button", {
1124
1139
  className: "Card small",
1125
1140
  title: "Connect ".concat(wallet.name),
1126
1141
  onClick: function onClick() {
@@ -1136,7 +1151,7 @@ var SelectWalletDialog = (function (props) {
1136
1151
  className: "CardBodyWrapper PaddingLeftXS"
1137
1152
  }, /*#__PURE__*/React.createElement("h2", {
1138
1153
  className: "CardText FontWeightBold"
1139
- }, wallet.name))));
1154
+ }, wallet.name)))));
1140
1155
  });
1141
1156
  return /*#__PURE__*/React.createElement(Dialog$1, {
1142
1157
  header: /*#__PURE__*/React.createElement("div", {
@@ -1668,7 +1683,7 @@ var CardStyle = (function (style) {
1668
1683
  });
1669
1684
 
1670
1685
  var DialogStyle = (function (style) {
1671
- 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: 40vh !important;\n }\n\n .DialogFooter {\n padding-bottom: 50px;\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 ";
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 ";
1672
1687
  });
1673
1688
 
1674
1689
  var FontStyle = (function (style) {
@@ -3771,6 +3786,167 @@ var Donation = /*#__PURE__*/function () {
3771
3786
  };
3772
3787
  }();
3773
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 wallet = getWallet();
3803
+ wallet !== null && wallet !== void 0 && wallet.name ? wallet.name : 'wallet';
3804
+ var walletLogo = wallet !== null && wallet !== void 0 && wallet.logo ? wallet.logo : undefined;
3805
+
3806
+ var login = function login() {
3807
+ wallet.sign(message).then(function (signature) {
3808
+ fetch(endpoint, {
3809
+ method: 'POST',
3810
+ body: JSON.stringify({
3811
+ message: message,
3812
+ signature: signature
3813
+ })
3814
+ }).then(function (response) {
3815
+ if (response.status == 200) {
3816
+ response.text().then(function (account) {
3817
+ props.resolve(account);
3818
+ })["catch"](setError);
3819
+ } else {
3820
+ response.text().then(function (text) {
3821
+ setError(text || 'Recovering login signature failed!');
3822
+ });
3823
+ }
3824
+ })["catch"](setError);
3825
+ })["catch"](setError);
3826
+ };
3827
+
3828
+ useEffect(login, []);
3829
+ useEffect(function () {
3830
+ var timeout = setTimeout(function () {
3831
+ return setShowSignButton(true);
3832
+ }, 10000);
3833
+ return function () {
3834
+ return clearTimeout(timeout);
3835
+ };
3836
+ }, []);
3837
+ return /*#__PURE__*/React.createElement(Dialog$1, {
3838
+ stacked: true,
3839
+ body: /*#__PURE__*/React.createElement("div", null, walletLogo && /*#__PURE__*/React.createElement("div", {
3840
+ className: "GraphicWrapper PaddingTopS PaddingBottomS"
3841
+ }, /*#__PURE__*/React.createElement("img", {
3842
+ className: "Graphic",
3843
+ src: walletLogo
3844
+ })), /*#__PURE__*/React.createElement("h1", {
3845
+ className: "LineHeightL Text FontSizeL FontWeightBold PaddingTopS"
3846
+ }, "Wallet Login"), /*#__PURE__*/React.createElement("div", {
3847
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
3848
+ }, /*#__PURE__*/React.createElement("p", {
3849
+ className: "FontSizeM PaddingLeftM PaddingRightM"
3850
+ }, "Please sign the login message with your connected wallet."))),
3851
+ footer: showSignButton && /*#__PURE__*/React.createElement("div", {
3852
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
3853
+ }, /*#__PURE__*/React.createElement("button", {
3854
+ className: "ButtonPrimary",
3855
+ onClick: login
3856
+ }, "Log in"))
3857
+ });
3858
+ });
3859
+
3860
+ var LoginStack = (function (props) {
3861
+ var _useContext = useContext(ClosableContext),
3862
+ open = _useContext.open,
3863
+ close = _useContext.close;
3864
+
3865
+ var _useState = useState(true),
3866
+ _useState2 = _slicedToArray(_useState, 2);
3867
+ _useState2[0];
3868
+ _useState2[1];
3869
+
3870
+ return /*#__PURE__*/React.createElement(ReactDialogStack, {
3871
+ open: open,
3872
+ close: close,
3873
+ start: "SignLogin",
3874
+ container: props.container,
3875
+ document: props.document,
3876
+ dialogs: {
3877
+ SignLogin: /*#__PURE__*/React.createElement(SignLoginDialog, {
3878
+ resolve: props.resolve
3879
+ })
3880
+ }
3881
+ });
3882
+ });
3883
+
3884
+ var Login = function Login(options) {
3885
+ var style, error, document, message, endpoint;
3886
+
3887
+ if (_typeof(options) == 'object') {
3888
+ style = options.style;
3889
+ error = options.error;
3890
+ document = options.document;
3891
+ message = options.message;
3892
+ endpoint = options.endpoint;
3893
+ }
3894
+
3895
+ return new Promise( /*#__PURE__*/function () {
3896
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
3897
+ return regenerator.wrap(function _callee$(_context) {
3898
+ while (1) {
3899
+ switch (_context.prev = _context.next) {
3900
+ case 0:
3901
+ Connect().then(function () {
3902
+ mount({
3903
+ style: style,
3904
+ document: ensureDocument(document)
3905
+ }, function (unmount) {
3906
+ var rejectBeforeUnmount = function rejectBeforeUnmount() {
3907
+ reject('USER_CLOSED_DIALOG');
3908
+ unmount();
3909
+ };
3910
+
3911
+ return function (container) {
3912
+ return /*#__PURE__*/React.createElement(ErrorProvider, {
3913
+ error: error,
3914
+ container: container,
3915
+ unmount: unmount
3916
+ }, /*#__PURE__*/React.createElement(ConfigurationProvider, {
3917
+ configuration: {
3918
+ message: message,
3919
+ endpoint: endpoint || '/login'
3920
+ }
3921
+ }, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
3922
+ unmount: rejectBeforeUnmount
3923
+ }, /*#__PURE__*/React.createElement(LoginStack, {
3924
+ document: document,
3925
+ container: container,
3926
+ resolve: function resolve(account) {
3927
+ unmount();
3928
+
3929
+ _resolve(account);
3930
+ }
3931
+ }), /*#__PURE__*/React.createElement(PoweredBy, null)))));
3932
+ };
3933
+ });
3934
+ })["catch"](reject);
3935
+
3936
+ case 1:
3937
+ case "end":
3938
+ return _context.stop();
3939
+ }
3940
+ }
3941
+ }, _callee);
3942
+ }));
3943
+
3944
+ return function (_x, _x2) {
3945
+ return _ref.apply(this, arguments);
3946
+ };
3947
+ }());
3948
+ };
3949
+
3774
3950
  var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
3775
3951
 
3776
3952
  var PaymentAmountRoutingProvider = (function (props) {
@@ -4479,9 +4655,10 @@ var Sale = /*#__PURE__*/function () {
4479
4655
 
4480
4656
  var DePayWidgets = {
4481
4657
  Connect: Connect,
4658
+ Donation: Donation,
4659
+ Login: Login,
4482
4660
  Payment: Payment,
4483
4661
  Sale: Sale,
4484
- Donation: Donation,
4485
4662
  provider: provider
4486
4663
  };
4487
4664