@depay/widgets 7.15.0 → 7.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -18884,7 +18884,7 @@ var ChangableAmountProvider = (function (props) {
18884
18884
  };
18885
18885
 
18886
18886
  var _useContext = useContext(ConfigurationContext),
18887
- amountConfiguration = _useContext.amount;
18887
+ configuredAmount = _useContext.amount;
18888
18888
  _useContext.toAmount;
18889
18889
  var recover = _useContext.recover;
18890
18890
 
@@ -18908,21 +18908,21 @@ var ChangableAmountProvider = (function (props) {
18908
18908
  acceptWithAmount = _useState4[0],
18909
18909
  setAcceptWithAmount = _useState4[1];
18910
18910
 
18911
- var _useState5 = useState(_typeof(amountConfiguration) == 'object' && amountConfiguration.fix && amountConfiguration.currency ? amountConfiguration.fix : null),
18911
+ var _useState5 = useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.fix : null),
18912
18912
  _useState6 = _slicedToArray(_useState5, 1),
18913
18913
  fixedAmount = _useState6[0];
18914
18914
 
18915
- var _useState7 = useState(_typeof(amountConfiguration) == 'object' && amountConfiguration.fix && amountConfiguration.currency ? amountConfiguration.currency : null),
18915
+ var _useState7 = useState(_typeof(configuredAmount) == 'object' && configuredAmount.fix && configuredAmount.currency ? configuredAmount.currency : null),
18916
18916
  _useState8 = _slicedToArray(_useState7, 1),
18917
18917
  fixedCurrency = _useState8[0];
18918
18918
 
18919
18919
  var startAmount;
18920
18920
 
18921
18921
  if (amountsMissing) {
18922
- if (_typeof(amountConfiguration) == "object" && amountConfiguration.start && amountConfiguration.start) {
18923
- startAmount = amountConfiguration.start;
18924
- } else if (_typeof(amountConfiguration) == "object" && amountConfiguration.fix) {
18925
- startAmount = amountConfiguration.fix;
18922
+ if (_typeof(configuredAmount) == "object" && configuredAmount.start && configuredAmount.start) {
18923
+ startAmount = configuredAmount.start;
18924
+ } else if (_typeof(configuredAmount) == "object" && configuredAmount.fix) {
18925
+ startAmount = configuredAmount.fix;
18926
18926
  } else {
18927
18927
  startAmount = 1;
18928
18928
  }
@@ -18938,7 +18938,7 @@ var ChangableAmountProvider = (function (props) {
18938
18938
  maxRoute = _useState12[0],
18939
18939
  setMaxRoute = _useState12[1];
18940
18940
 
18941
- var _useState13 = useState(100),
18941
+ var _useState13 = useState(),
18942
18942
  _useState14 = _slicedToArray(_useState13, 2),
18943
18943
  maxAmount = _useState14[0],
18944
18944
  setMaxAmount = _useState14[1];
@@ -18956,7 +18956,7 @@ var ChangableAmountProvider = (function (props) {
18956
18956
  conversionRate = _ref.conversionRate,
18957
18957
  fixedCurrencyConversionRate = _ref.fixedCurrencyConversionRate;
18958
18958
  return new Promise(function (resolve, reject) {
18959
- if (amountConfiguration && amountConfiguration.token) {
18959
+ if (configuredAmount && configuredAmount.token) {
18960
18960
  resolve(props.accept.map(function () {
18961
18961
  return amount;
18962
18962
  }));
@@ -19051,7 +19051,7 @@ var ChangableAmountProvider = (function (props) {
19051
19051
  useEffect(function () {
19052
19052
  if (amountsMissing && maxRoute) {
19053
19053
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
19054
- if (amountConfiguration && amountConfiguration.token) {
19054
+ if (configuredAmount && configuredAmount.token) {
19055
19055
  route({
19056
19056
  blockchain: maxRoute.blockchain,
19057
19057
  tokenIn: maxRoute.fromToken.address,
@@ -19061,6 +19061,11 @@ var ChangableAmountProvider = (function (props) {
19061
19061
  toAddress: account
19062
19062
  }).then(function (routes) {
19063
19063
  if (routes[0] == undefined) {
19064
+ Token.readable({
19065
+ amount: maxRoute.fromBalance,
19066
+ blockchain: maxRoute.blockchain,
19067
+ address: maxRoute.toToken.address
19068
+ }).then(setMaxAmount);
19064
19069
  return;
19065
19070
  }
19066
19071
 
@@ -20136,8 +20141,15 @@ var PaymentValueProvider = (function (props) {
20136
20141
  var _useContext3 = useContext(UpdatableContext),
20137
20142
  updatable = _useContext3.updatable;
20138
20143
 
20139
- var _useContext4 = useContext(PaymentContext),
20140
- payment = _useContext4.payment;
20144
+ var _useContext4 = useContext(ConfigurationContext),
20145
+ configuredAmount = _useContext4.amount,
20146
+ currencyCode = _useContext4.currencyCode;
20147
+
20148
+ var _useContext5 = useContext(ChangableAmountContext),
20149
+ amount = _useContext5.amount;
20150
+
20151
+ var _useContext6 = useContext(PaymentContext),
20152
+ payment = _useContext6.payment;
20141
20153
 
20142
20154
  var _useState = useState(),
20143
20155
  _useState2 = _slicedToArray(_useState, 2),
@@ -20146,16 +20158,21 @@ var PaymentValueProvider = (function (props) {
20146
20158
 
20147
20159
  var _useState3 = useState(),
20148
20160
  _useState4 = _slicedToArray(_useState3, 2),
20149
- paymentValueLoss = _useState4[0],
20150
- setPaymentValueLoss = _useState4[1];
20161
+ displayedPaymentValue = _useState4[0],
20162
+ setDisplayedPaymentValue = _useState4[1];
20151
20163
 
20152
- var _useContext5 = useContext(ConfigurationContext),
20153
- currency = _useContext5.currency;
20154
-
20155
- var _useState5 = useState(0),
20164
+ var _useState5 = useState(),
20156
20165
  _useState6 = _slicedToArray(_useState5, 2),
20157
- reloadCount = _useState6[0],
20158
- setReloadCount = _useState6[1];
20166
+ paymentValueLoss = _useState6[0],
20167
+ setPaymentValueLoss = _useState6[1];
20168
+
20169
+ var _useContext7 = useContext(ConfigurationContext),
20170
+ currency = _useContext7.currency;
20171
+
20172
+ var _useState7 = useState(0),
20173
+ _useState8 = _slicedToArray(_useState7, 2),
20174
+ reloadCount = _useState8[0],
20175
+ setReloadCount = _useState8[1];
20159
20176
 
20160
20177
  var updatePaymentValue = function updatePaymentValue(_ref) {
20161
20178
  var updatable = _ref.updatable,
@@ -20222,6 +20239,20 @@ var PaymentValueProvider = (function (props) {
20222
20239
  })["catch"](setError);
20223
20240
  };
20224
20241
 
20242
+ useEffect(function () {
20243
+ if (paymentValue && amount && configuredAmount && configuredAmount.currency && configuredAmount.fix) {
20244
+ setDisplayedPaymentValue(paymentValue.toString());
20245
+ } else if (amount && (configuredAmount == undefined || (configuredAmount === null || configuredAmount === void 0 ? void 0 : configuredAmount.token) != true)) {
20246
+ setDisplayedPaymentValue(new Currency({
20247
+ amount: amount.toFixed(2),
20248
+ code: currencyCode
20249
+ }).toString());
20250
+ } else if (paymentValue && paymentValue.toString().length && (configuredAmount === null || configuredAmount === void 0 ? void 0 : configuredAmount.token) != true) {
20251
+ setDisplayedPaymentValue(paymentValue.toString());
20252
+ } else if (payment) {
20253
+ setDisplayedPaymentValue("".concat(payment.symbol, " ").concat(payment.amount));
20254
+ }
20255
+ }, [paymentValue, payment, amount, configuredAmount]);
20225
20256
  useEffect(function () {
20226
20257
  if (account && payment) {
20227
20258
  updatePaymentValue({
@@ -20244,7 +20275,8 @@ var PaymentValueProvider = (function (props) {
20244
20275
  return /*#__PURE__*/React.createElement(PaymentValueContext.Provider, {
20245
20276
  value: {
20246
20277
  paymentValue: paymentValue,
20247
- paymentValueLoss: paymentValueLoss
20278
+ paymentValueLoss: paymentValueLoss,
20279
+ displayedPaymentValue: displayedPaymentValue
20248
20280
  }
20249
20281
  }, props.children);
20250
20282
  });
@@ -20301,18 +20333,21 @@ var ChangeAmountDialog = (function (props) {
20301
20333
  setAmount = _useContext4.setAmount,
20302
20334
  maxAmount = _useContext4.maxAmount;
20303
20335
 
20336
+ var _useContext5 = useContext(PaymentValueContext);
20337
+ _useContext5.displayedPaymentValue;
20338
+
20304
20339
  var _useState = useState(amount),
20305
20340
  _useState2 = _slicedToArray(_useState, 2),
20306
20341
  inputAmount = _useState2[0],
20307
20342
  setInputAmount = _useState2[1];
20308
20343
 
20309
- var _useContext5 = useContext(ConfigurationContext),
20310
- currencyCode = _useContext5.currencyCode,
20311
- amountConfiguration = _useContext5.amount;
20344
+ var _useContext6 = useContext(ConfigurationContext),
20345
+ currencyCode = _useContext6.currencyCode,
20346
+ amountConfiguration = _useContext6.amount;
20312
20347
 
20313
- var _useContext6 = useContext(PaymentRoutingContext);
20314
- _useContext6.allRoutes;
20315
- var setSelectedRoute = _useContext6.setSelectedRoute;
20348
+ var _useContext7 = useContext(PaymentRoutingContext);
20349
+ _useContext7.allRoutes;
20350
+ var setSelectedRoute = _useContext7.setSelectedRoute;
20316
20351
 
20317
20352
  var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
20318
20353
  var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
@@ -20347,7 +20382,11 @@ var ChangeAmountDialog = (function (props) {
20347
20382
 
20348
20383
  var toValidValue = function toValidValue(value) {
20349
20384
  value = toValidStep(value);
20350
- value = Math.max(min, Math.min(value, maxAmount));
20385
+
20386
+ if (maxAmount) {
20387
+ value = Math.max(min, Math.min(value, maxAmount));
20388
+ }
20389
+
20351
20390
  value = toValidStep(value);
20352
20391
  return value;
20353
20392
  };
@@ -20374,7 +20413,7 @@ var ChangeAmountDialog = (function (props) {
20374
20413
  }, /*#__PURE__*/React.createElement("div", {
20375
20414
  className: "PaddingBottomM"
20376
20415
  }, /*#__PURE__*/React.createElement("input", {
20377
- max: parseFloat(maxAmount),
20416
+ max: maxAmount ? parseFloat(maxAmount) : null,
20378
20417
  min: min,
20379
20418
  step: step,
20380
20419
  className: "Input FontSizeXXL TextAlignCenter",
@@ -20387,7 +20426,7 @@ var ChangeAmountDialog = (function (props) {
20387
20426
  onBlur: function onBlur(event) {
20388
20427
  setValidValue(event.target.value);
20389
20428
  }
20390
- })), /*#__PURE__*/React.createElement("div", {
20429
+ })), maxAmount && /*#__PURE__*/React.createElement("div", {
20391
20430
  style: {
20392
20431
  height: '40px'
20393
20432
  }
@@ -20449,8 +20488,9 @@ var ChangePaymentDialog = (function (props) {
20449
20488
  allRoutes = _useContext2.allRoutes,
20450
20489
  setSelectedRoute = _useContext2.setSelectedRoute;
20451
20490
 
20452
- var _useContext3 = useContext(PaymentValueContext),
20453
- paymentValue = _useContext3.paymentValue;
20491
+ var _useContext3 = useContext(PaymentValueContext);
20492
+ _useContext3.paymentValue;
20493
+ var displayedPaymentValue = _useContext3.displayedPaymentValue;
20454
20494
 
20455
20495
  var _useContext4 = useContext(NavigateStackContext),
20456
20496
  navigate = _useContext4.navigate;
@@ -20535,9 +20575,9 @@ var ChangePaymentDialog = (function (props) {
20535
20575
  className: "PaddingTopS PaddingLeftM PaddingRightM PaddingBottomS"
20536
20576
  }, /*#__PURE__*/React.createElement("h1", {
20537
20577
  className: "LineHeightL FontSizeL TextCenter"
20538
- }, "Change Payment"), paymentValue != undefined && /*#__PURE__*/React.createElement("div", {
20578
+ }, "Change Payment"), displayedPaymentValue != undefined && /*#__PURE__*/React.createElement("div", {
20539
20579
  className: "FontSizeL TextCenter FontWeightBold"
20540
- }, /*#__PURE__*/React.createElement("strong", null, paymentValue.toString()))),
20580
+ }, /*#__PURE__*/React.createElement("strong", null, displayedPaymentValue.toString()))),
20541
20581
  body: /*#__PURE__*/React.createElement("div", {
20542
20582
  className: "MaxHeight PaddingTopXS"
20543
20583
  }, /*#__PURE__*/React.createElement("div", {
@@ -20660,41 +20700,38 @@ var LoadingText = (function (props) {
20660
20700
  });
20661
20701
 
20662
20702
  var Footer = (function () {
20663
- var _useContext = useContext(ConfigurationContext),
20664
- currencyCode = _useContext.currencyCode,
20665
- configuredAmount = _useContext.amount;
20666
-
20667
- var _useContext2 = useContext(ChangableAmountContext),
20668
- amount = _useContext2.amount;
20669
- _useContext2.amountsMissing;
20703
+ var _useContext = useContext(ChangableAmountContext);
20704
+ _useContext.amount;
20705
+ _useContext.amountsMissing;
20670
20706
 
20671
- var _useContext3 = useContext(PaymentTrackingContext),
20672
- tracking = _useContext3.tracking,
20673
- release = _useContext3.release,
20674
- forwardTo = _useContext3.forwardTo,
20675
- trackingFailed = _useContext3.trackingFailed;
20707
+ var _useContext2 = useContext(PaymentTrackingContext),
20708
+ tracking = _useContext2.tracking,
20709
+ release = _useContext2.release,
20710
+ forwardTo = _useContext2.forwardTo,
20711
+ trackingFailed = _useContext2.trackingFailed;
20676
20712
 
20677
- var _useContext4 = useContext(PaymentContext),
20678
- payment = _useContext4.payment,
20679
- paymentState = _useContext4.paymentState,
20680
- pay = _useContext4.pay,
20681
- transaction = _useContext4.transaction,
20682
- approve = _useContext4.approve,
20683
- approvalTransaction = _useContext4.approvalTransaction;
20713
+ var _useContext3 = useContext(PaymentContext),
20714
+ payment = _useContext3.payment,
20715
+ paymentState = _useContext3.paymentState,
20716
+ pay = _useContext3.pay,
20717
+ transaction = _useContext3.transaction,
20718
+ approve = _useContext3.approve,
20719
+ approvalTransaction = _useContext3.approvalTransaction;
20684
20720
 
20685
- var _useContext5 = useContext(PaymentValueContext),
20686
- paymentValue = _useContext5.paymentValue,
20687
- paymentValueLoss = _useContext5.paymentValueLoss;
20721
+ var _useContext4 = useContext(PaymentValueContext);
20722
+ _useContext4.paymentValue;
20723
+ var displayedPaymentValue = _useContext4.displayedPaymentValue,
20724
+ paymentValueLoss = _useContext4.paymentValueLoss;
20688
20725
 
20689
- var _useContext6 = useContext(PaymentRoutingContext),
20690
- updatedRouteWithNewPrice = _useContext6.updatedRouteWithNewPrice,
20691
- updateRouteWithNewPrice = _useContext6.updateRouteWithNewPrice;
20726
+ var _useContext5 = useContext(PaymentRoutingContext),
20727
+ updatedRouteWithNewPrice = _useContext5.updatedRouteWithNewPrice,
20728
+ updateRouteWithNewPrice = _useContext5.updateRouteWithNewPrice;
20692
20729
 
20693
- var _useContext7 = useContext(NavigateStackContext);
20694
- _useContext7.navigate;
20730
+ var _useContext6 = useContext(NavigateStackContext);
20731
+ _useContext6.navigate;
20695
20732
 
20696
- var _useContext8 = useContext(ClosableContext),
20697
- close = _useContext8.close;
20733
+ var _useContext7 = useContext(ClosableContext),
20734
+ close = _useContext7.close;
20698
20735
 
20699
20736
  var trackingInfo = function trackingInfo() {
20700
20737
  if (tracking != true) {
@@ -20821,21 +20858,6 @@ var Footer = (function () {
20821
20858
  };
20822
20859
 
20823
20860
  var mainAction = function mainAction() {
20824
- var displayedAmount;
20825
-
20826
- if (amount && configuredAmount && configuredAmount.currency && configuredAmount.fix) {
20827
- displayedAmount = paymentValue.toString();
20828
- } else if (amount && (configuredAmount == undefined || (configuredAmount === null || configuredAmount === void 0 ? void 0 : configuredAmount.token) != true)) {
20829
- displayedAmount = new Currency({
20830
- amount: amount.toFixed(2),
20831
- code: currencyCode
20832
- }).toString();
20833
- } else if (paymentValue && paymentValue.toString().length && (configuredAmount === null || configuredAmount === void 0 ? void 0 : configuredAmount.token) != true) {
20834
- displayedAmount = paymentValue.toString();
20835
- } else {
20836
- displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
20837
- }
20838
-
20839
20861
  if (updatedRouteWithNewPrice) {
20840
20862
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
20841
20863
  className: "PaddingBottomXS"
@@ -20855,7 +20877,7 @@ var Footer = (function () {
20855
20877
  }, /*#__PURE__*/React.createElement("strong", null, "Payment token would lose ", paymentValueLoss, "% of it's value!"))), /*#__PURE__*/React.createElement("button", {
20856
20878
  className: "ButtonPrimary disabled",
20857
20879
  onClick: function onClick() {}
20858
- }, "Pay ", displayedAmount));
20880
+ }, "Pay ", displayedPaymentValue));
20859
20881
  } else if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
20860
20882
  return /*#__PURE__*/React.createElement("button", {
20861
20883
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
@@ -20866,7 +20888,7 @@ var Footer = (function () {
20866
20888
 
20867
20889
  pay();
20868
20890
  }
20869
- }, "Pay ", displayedAmount);
20891
+ }, "Pay ", displayedPaymentValue);
20870
20892
  } else if (paymentState == 'paying') {
20871
20893
  return /*#__PURE__*/React.createElement("a", {
20872
20894
  className: "ButtonPrimary",
@@ -20909,19 +20931,22 @@ var Footer = (function () {
20909
20931
  });
20910
20932
 
20911
20933
  var DonationOverviewDialog = (function (props) {
20912
- var _useContext = useContext(ConfigurationContext),
20913
- currencyCode = _useContext.currencyCode,
20914
- title = _useContext.title;
20934
+ var _useContext = useContext(ConfigurationContext);
20935
+ _useContext.currencyCode;
20936
+ var title = _useContext.title;
20915
20937
 
20916
- var _useContext2 = useContext(ChangableAmountContext),
20917
- amount = _useContext2.amount;
20938
+ var _useContext2 = useContext(ChangableAmountContext);
20939
+ _useContext2.amount;
20918
20940
 
20919
20941
  var _useContext3 = useContext(PaymentContext),
20920
20942
  payment = _useContext3.payment,
20921
20943
  paymentState = _useContext3.paymentState;
20922
20944
 
20923
- var _useContext4 = useContext(NavigateStackContext),
20924
- navigate = _useContext4.navigate;
20945
+ var _useContext4 = useContext(PaymentValueContext),
20946
+ displayedPaymentValue = _useContext4.displayedPaymentValue;
20947
+
20948
+ var _useContext5 = useContext(NavigateStackContext),
20949
+ navigate = _useContext5.navigate;
20925
20950
 
20926
20951
  if (payment == undefined) {
20927
20952
  return /*#__PURE__*/React.createElement(DonationOverviewSkeleton, null);
@@ -20956,10 +20981,7 @@ var DonationOverviewDialog = (function (props) {
20956
20981
  className: "CardText"
20957
20982
  }, /*#__PURE__*/React.createElement("div", {
20958
20983
  className: "TokenAmountRow"
20959
- }, new Currency({
20960
- amount: amount.toFixed(2),
20961
- code: currencyCode
20962
- }).toString())))), /*#__PURE__*/React.createElement("div", {
20984
+ }, displayedPaymentValue)))), /*#__PURE__*/React.createElement("div", {
20963
20985
  className: "CardAction"
20964
20986
  }, /*#__PURE__*/React.createElement(ChevronRight, null))), /*#__PURE__*/React.createElement("div", {
20965
20987
  className: ["Card", paymentState == 'initialized' ? '' : 'disabled'].join(' '),