@depay/widgets 12.10.12 → 12.11.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.
@@ -22404,13 +22404,39 @@
22404
22404
  function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
22405
22405
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22406
22406
  var SelectWalletList = (function (props) {
22407
+ var _useContext = React.useContext(ConfigurationContext),
22408
+ walletsConfiguration = _useContext.wallets;
22409
+ var allWallets$1;
22410
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22411
+ allWallets$1 = React.useMemo(function () {
22412
+ var adjustedWallets = _toConsumableArray(allWallets);
22413
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22414
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22415
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22416
+ return unsortedWallet.name === sortedWallet;
22417
+ });
22418
+ if (currentListIndex > -1) {
22419
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22420
+ }
22421
+ });
22422
+ }
22423
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22424
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22425
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22426
+ });
22427
+ }
22428
+ return adjustedWallets;
22429
+ }, [walletsConfiguration]);
22430
+ } else {
22431
+ allWallets$1 = allWallets;
22432
+ }
22407
22433
  var parentElement = React__default['default'].useRef();
22408
- var fuse = new Fuse__default['default'](allWallets, {
22434
+ var fuse = new Fuse__default['default'](allWallets$1, {
22409
22435
  keys: ['name'],
22410
22436
  threshold: 0.3,
22411
22437
  ignoreFieldNorm: true
22412
22438
  });
22413
- var _useState = React.useState(allWallets),
22439
+ var _useState = React.useState(allWallets$1),
22414
22440
  _useState2 = _slicedToArray(_useState, 2),
22415
22441
  resultList = _useState2[0],
22416
22442
  setResultList = _useState2[1];
@@ -22433,7 +22459,7 @@
22433
22459
  if (props.searchTerm.length) {
22434
22460
  setResultList(results);
22435
22461
  } else {
22436
- setResultList(allWallets);
22462
+ setResultList(allWallets$1);
22437
22463
  }
22438
22464
  }, [props.searchTerm]);
22439
22465
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -22503,9 +22529,35 @@
22503
22529
  _useState10 = _slicedToArray(_useState9, 2),
22504
22530
  dialogAnimationFinished = _useState10[0],
22505
22531
  setDialogAnimationFinished = _useState10[1];
22532
+ var _useContext = React.useContext(ConfigurationContext),
22533
+ walletsConfiguration = _useContext.wallets;
22506
22534
  var searchElement = React.useRef();
22507
- var _useContext = React.useContext(reactDialogStack.NavigateStackContext),
22508
- navigate = _useContext.navigate;
22535
+ var _useContext2 = React.useContext(reactDialogStack.NavigateStackContext),
22536
+ navigate = _useContext2.navigate;
22537
+ var allWallets$1;
22538
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22539
+ allWallets$1 = React.useMemo(function () {
22540
+ var adjustedWallets = _toConsumableArray(allWallets);
22541
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22542
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22543
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22544
+ return unsortedWallet.name === sortedWallet;
22545
+ });
22546
+ if (currentListIndex > -1) {
22547
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22548
+ }
22549
+ });
22550
+ }
22551
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22552
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22553
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22554
+ });
22555
+ }
22556
+ return adjustedWallets;
22557
+ }, [walletsConfiguration]);
22558
+ } else {
22559
+ allWallets$1 = allWallets;
22560
+ }
22509
22561
  var onClickWallet = function onClickWallet(walletMetaData, wallet) {
22510
22562
  if (walletMetaData.via == 'detected') {
22511
22563
  if (walletMetaData.connectionType == 'app') {
@@ -22537,6 +22589,11 @@
22537
22589
  navigate('ConnectWallet');
22538
22590
  }
22539
22591
  };
22592
+ React.useEffect(function () {
22593
+ if (allWallets$1.length === 1) {
22594
+ onClickWallet(allWallets$1[0]);
22595
+ }
22596
+ }, [allWallets$1]);
22540
22597
  React.useEffect(function () {
22541
22598
  var wallets = [];
22542
22599
  web3WalletsEvm.getWallets({
@@ -22546,9 +22603,9 @@
22546
22603
  }
22547
22604
  });
22548
22605
  var previouslyConnectedWalletName = get();
22549
- var previouslyConnectedWallet = allWallets.find(function (wallet) {
22606
+ var previouslyConnectedWallet = allWallets$1.find(function (wallet) {
22550
22607
  return wallet.name == previouslyConnectedWalletName;
22551
- }) || allWallets.find(function (wallet) {
22608
+ }) || allWallets$1.find(function (wallet) {
22552
22609
  return wallet.name == previouslyConnectedWalletName;
22553
22610
  });
22554
22611
  if (previouslyConnectedWallet) {
@@ -22579,7 +22636,7 @@
22579
22636
  return (target === null || target === void 0 ? void 0 : (_target$info = target.info) === null || _target$info === void 0 ? void 0 : _target$info.name) === (wallet === null || wallet === void 0 ? void 0 : (_wallet$info = wallet.info) === null || _wallet$info === void 0 ? void 0 : _wallet$info.name);
22580
22637
  }) === index;
22581
22638
  }).map(function (wallet, index) {
22582
- var walletMetaData = allWallets.find(function (walletFromList) {
22639
+ var walletMetaData = allWallets$1.find(function (walletFromList) {
22583
22640
  return walletFromList.name === (wallet.info ? wallet.info.name : wallet.name);
22584
22641
  });
22585
22642
  if (!walletMetaData) {
@@ -22660,7 +22717,7 @@
22660
22717
  className: "PaddingBottomXS PaddingLeftS PaddingRightS PaddingTopXS"
22661
22718
  }, /*#__PURE__*/React__default['default'].createElement("div", {
22662
22719
  className: "Row"
22663
- }, /*#__PURE__*/React__default['default'].createElement("input", {
22720
+ }, allWallets$1.length > 4 && /*#__PURE__*/React__default['default'].createElement("input", {
22664
22721
  className: "Search",
22665
22722
  value: searchTerm,
22666
22723
  onChange: function onChange(event) {
@@ -28475,12 +28532,12 @@
28475
28532
  }();
28476
28533
  var Payment = /*#__PURE__*/function () {
28477
28534
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
28478
- var accept, amount, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, recover, closable, integration, payload, link, container, before, wallet, title, action, document, unmount;
28535
+ var accept, amount, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, recover, closable, integration, payload, link, container, before, wallet, title, action, document, wallets, unmount;
28479
28536
  return regenerator.wrap(function _callee2$(_context2) {
28480
28537
  while (1) {
28481
28538
  switch (_context2.prev = _context2.next) {
28482
28539
  case 0:
28483
- accept = _ref3.accept, amount = _ref3.amount, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, payload = _ref3.payload, link = _ref3.link, container = _ref3.container, before = _ref3.before, wallet = _ref3.wallet, title = _ref3.title, action = _ref3.action, document = _ref3.document;
28540
+ accept = _ref3.accept, amount = _ref3.amount, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, payload = _ref3.payload, link = _ref3.link, container = _ref3.container, before = _ref3.before, wallet = _ref3.wallet, title = _ref3.title, action = _ref3.action, document = _ref3.document, wallets = _ref3.wallets;
28484
28541
  requireReactVersion();
28485
28542
  if (currency && !SUPPORTED_CURRENCIES.includes(currency.toLowerCase())) {
28486
28543
  currency = false;
@@ -28532,7 +28589,8 @@
28532
28589
  link: link,
28533
28590
  wallet: wallet,
28534
28591
  title: title,
28535
- action: action
28592
+ action: action,
28593
+ wallets: wallets
28536
28594
  }
28537
28595
  }, /*#__PURE__*/React__default['default'].createElement(UpdatableProvider, null, /*#__PURE__*/React__default['default'].createElement(ClosableProvider, {
28538
28596
  unmount: unmount,