@depay/widgets 6.0.2 → 6.2.2

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/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",
@@ -1331,14 +1344,14 @@ function _inherits(subClass, superClass) {
1331
1344
  throw new TypeError("Super expression must either be null or a function");
1332
1345
  }
1333
1346
 
1347
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1348
+ constructor: {
1349
+ value: subClass,
1350
+ writable: true,
1351
+ configurable: true
1352
+ }
1353
+ });
1334
1354
  Object.defineProperty(subClass, "prototype", {
1335
- value: Object.create(superClass && superClass.prototype, {
1336
- constructor: {
1337
- value: subClass,
1338
- writable: true,
1339
- configurable: true
1340
- }
1341
- }),
1342
1355
  writable: false
1343
1356
  });
1344
1357
  if (superClass) _setPrototypeOf(subClass, superClass);
@@ -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: 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 ";
1674
1687
  });
1675
1688
 
1676
1689
  var FontStyle = (function (style) {
@@ -3773,6 +3786,186 @@ var Donation = /*#__PURE__*/function () {
3773
3786
  };
3774
3787
  }();
3775
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(function () {
3845
+ return setTimeout(login, 1000);
3846
+ }, []);
3847
+ useEffect(function () {
3848
+ var timeout = setTimeout(function () {
3849
+ return setShowSignButton(true);
3850
+ }, 10000);
3851
+ return function () {
3852
+ return clearTimeout(timeout);
3853
+ };
3854
+ }, []);
3855
+ return /*#__PURE__*/React.createElement(Dialog$1, {
3856
+ body: /*#__PURE__*/React.createElement("div", null, walletLogo && /*#__PURE__*/React.createElement("div", {
3857
+ className: "GraphicWrapper PaddingTopS PaddingBottomS"
3858
+ }, /*#__PURE__*/React.createElement("img", {
3859
+ className: "Graphic",
3860
+ src: walletLogo
3861
+ })), /*#__PURE__*/React.createElement("h1", {
3862
+ className: "LineHeightL Text FontSizeL FontWeightBold PaddingTopS"
3863
+ }, "Wallet Login"), /*#__PURE__*/React.createElement("div", {
3864
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
3865
+ }, /*#__PURE__*/React.createElement("p", {
3866
+ className: "FontSizeM PaddingLeftM PaddingRightM"
3867
+ }, "Please sign the login message with your connected wallet."))),
3868
+ footer: showSignButton && /*#__PURE__*/React.createElement("div", {
3869
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
3870
+ }, /*#__PURE__*/React.createElement("button", {
3871
+ className: "ButtonPrimary",
3872
+ onClick: login
3873
+ }, "Log in"))
3874
+ });
3875
+ });
3876
+
3877
+ var LoginStack = (function (props) {
3878
+ var _useContext = useContext(ClosableContext),
3879
+ open = _useContext.open,
3880
+ close = _useContext.close;
3881
+
3882
+ var _useState = useState(true),
3883
+ _useState2 = _slicedToArray(_useState, 2);
3884
+ _useState2[0];
3885
+ _useState2[1];
3886
+
3887
+ return /*#__PURE__*/React.createElement(ReactDialogStack, {
3888
+ open: open,
3889
+ close: close,
3890
+ start: "SignLogin",
3891
+ container: props.container,
3892
+ document: props.document,
3893
+ dialogs: {
3894
+ SignLogin: /*#__PURE__*/React.createElement(SignLoginDialog, {
3895
+ resolve: props.resolve
3896
+ })
3897
+ }
3898
+ });
3899
+ });
3900
+
3901
+ var Login = function Login(options) {
3902
+ var style, error, document, message, endpoint, recover;
3903
+
3904
+ if (_typeof(options) == 'object') {
3905
+ style = options.style;
3906
+ error = options.error;
3907
+ document = options.document;
3908
+ message = options.message;
3909
+ endpoint = options.endpoint;
3910
+ recover = options.recover;
3911
+ }
3912
+
3913
+ return new Promise( /*#__PURE__*/function () {
3914
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_resolve, reject) {
3915
+ return regenerator.wrap(function _callee$(_context) {
3916
+ while (1) {
3917
+ switch (_context.prev = _context.next) {
3918
+ case 0:
3919
+ Connect().then(function () {
3920
+ mount({
3921
+ style: style,
3922
+ document: ensureDocument(document)
3923
+ }, function (unmount) {
3924
+ var rejectBeforeUnmount = function rejectBeforeUnmount() {
3925
+ reject('USER_CLOSED_DIALOG');
3926
+ unmount();
3927
+ };
3928
+
3929
+ return function (container) {
3930
+ return /*#__PURE__*/React.createElement(ErrorProvider, {
3931
+ error: error,
3932
+ container: container,
3933
+ unmount: unmount
3934
+ }, /*#__PURE__*/React.createElement(ConfigurationProvider, {
3935
+ configuration: {
3936
+ message: message,
3937
+ endpoint: endpoint || '/login',
3938
+ recover: recover
3939
+ }
3940
+ }, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
3941
+ unmount: rejectBeforeUnmount
3942
+ }, /*#__PURE__*/React.createElement(LoginStack, {
3943
+ document: document,
3944
+ container: container,
3945
+ resolve: function resolve(account) {
3946
+ unmount();
3947
+
3948
+ _resolve(account);
3949
+ }
3950
+ }), /*#__PURE__*/React.createElement(PoweredBy, null)))));
3951
+ };
3952
+ });
3953
+ })["catch"](reject);
3954
+
3955
+ case 1:
3956
+ case "end":
3957
+ return _context.stop();
3958
+ }
3959
+ }
3960
+ }, _callee);
3961
+ }));
3962
+
3963
+ return function (_x, _x2) {
3964
+ return _ref.apply(this, arguments);
3965
+ };
3966
+ }());
3967
+ };
3968
+
3776
3969
  var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
3777
3970
 
3778
3971
  var PaymentAmountRoutingProvider = (function (props) {
@@ -4481,9 +4674,10 @@ var Sale = /*#__PURE__*/function () {
4481
4674
 
4482
4675
  var DePayWidgets = {
4483
4676
  Connect: Connect,
4677
+ Donation: Donation,
4678
+ Login: Login,
4484
4679
  Payment: Payment,
4485
4680
  Sale: Sale,
4486
- Donation: Donation,
4487
4681
  provider: provider
4488
4682
  };
4489
4683