@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.
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { wallets, getWallets } from '@depay/web3-wallets';
2
2
  import Blockchains from '@depay/web3-blockchains';
3
- import React, { useState, useContext, useEffect, useCallback, useRef } from 'react';
3
+ import React, { useState, useContext, useEffect, useCallback, useMemo, useRef } from 'react';
4
4
  import { route, routers } from '@depay/web3-payments';
5
5
  import copy from '@uiw/copy-to-clipboard';
6
6
  import { NavigateStackContext, ReactDialogStack } from '@depay/react-dialog-stack';
@@ -22408,13 +22408,39 @@ var MenuIcon = (function (props) {
22408
22408
  function ownKeys$9(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; }
22409
22409
  function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22410
22410
  var SelectWalletList = (function (props) {
22411
+ var _useContext = useContext(ConfigurationContext),
22412
+ walletsConfiguration = _useContext.wallets;
22413
+ var allWallets$1;
22414
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22415
+ allWallets$1 = useMemo(function () {
22416
+ var adjustedWallets = _toConsumableArray(allWallets);
22417
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22418
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22419
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22420
+ return unsortedWallet.name === sortedWallet;
22421
+ });
22422
+ if (currentListIndex > -1) {
22423
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22424
+ }
22425
+ });
22426
+ }
22427
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22428
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22429
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22430
+ });
22431
+ }
22432
+ return adjustedWallets;
22433
+ }, [walletsConfiguration]);
22434
+ } else {
22435
+ allWallets$1 = allWallets;
22436
+ }
22411
22437
  var parentElement = React.useRef();
22412
- var fuse = new Fuse(allWallets, {
22438
+ var fuse = new Fuse(allWallets$1, {
22413
22439
  keys: ['name'],
22414
22440
  threshold: 0.3,
22415
22441
  ignoreFieldNorm: true
22416
22442
  });
22417
- var _useState = useState(allWallets),
22443
+ var _useState = useState(allWallets$1),
22418
22444
  _useState2 = _slicedToArray(_useState, 2),
22419
22445
  resultList = _useState2[0],
22420
22446
  setResultList = _useState2[1];
@@ -22437,7 +22463,7 @@ var SelectWalletList = (function (props) {
22437
22463
  if (props.searchTerm.length) {
22438
22464
  setResultList(results);
22439
22465
  } else {
22440
- setResultList(allWallets);
22466
+ setResultList(allWallets$1);
22441
22467
  }
22442
22468
  }, [props.searchTerm]);
22443
22469
  return /*#__PURE__*/React.createElement("div", {
@@ -22507,9 +22533,35 @@ var SelectWalletDialog = (function (props) {
22507
22533
  _useState10 = _slicedToArray(_useState9, 2),
22508
22534
  dialogAnimationFinished = _useState10[0],
22509
22535
  setDialogAnimationFinished = _useState10[1];
22536
+ var _useContext = useContext(ConfigurationContext),
22537
+ walletsConfiguration = _useContext.wallets;
22510
22538
  var searchElement = useRef();
22511
- var _useContext = useContext(NavigateStackContext),
22512
- navigate = _useContext.navigate;
22539
+ var _useContext2 = useContext(NavigateStackContext),
22540
+ navigate = _useContext2.navigate;
22541
+ var allWallets$1;
22542
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22543
+ allWallets$1 = useMemo(function () {
22544
+ var adjustedWallets = _toConsumableArray(allWallets);
22545
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22546
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22547
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22548
+ return unsortedWallet.name === sortedWallet;
22549
+ });
22550
+ if (currentListIndex > -1) {
22551
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22552
+ }
22553
+ });
22554
+ }
22555
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22556
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22557
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22558
+ });
22559
+ }
22560
+ return adjustedWallets;
22561
+ }, [walletsConfiguration]);
22562
+ } else {
22563
+ allWallets$1 = allWallets;
22564
+ }
22513
22565
  var onClickWallet = function onClickWallet(walletMetaData, wallet) {
22514
22566
  if (walletMetaData.via == 'detected') {
22515
22567
  if (walletMetaData.connectionType == 'app') {
@@ -22541,6 +22593,11 @@ var SelectWalletDialog = (function (props) {
22541
22593
  navigate('ConnectWallet');
22542
22594
  }
22543
22595
  };
22596
+ useEffect(function () {
22597
+ if (allWallets$1.length === 1) {
22598
+ onClickWallet(allWallets$1[0]);
22599
+ }
22600
+ }, [allWallets$1]);
22544
22601
  useEffect(function () {
22545
22602
  var wallets = [];
22546
22603
  getWallets({
@@ -22550,9 +22607,9 @@ var SelectWalletDialog = (function (props) {
22550
22607
  }
22551
22608
  });
22552
22609
  var previouslyConnectedWalletName = get();
22553
- var previouslyConnectedWallet = allWallets.find(function (wallet) {
22610
+ var previouslyConnectedWallet = allWallets$1.find(function (wallet) {
22554
22611
  return wallet.name == previouslyConnectedWalletName;
22555
- }) || allWallets.find(function (wallet) {
22612
+ }) || allWallets$1.find(function (wallet) {
22556
22613
  return wallet.name == previouslyConnectedWalletName;
22557
22614
  });
22558
22615
  if (previouslyConnectedWallet) {
@@ -22583,7 +22640,7 @@ var SelectWalletDialog = (function (props) {
22583
22640
  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);
22584
22641
  }) === index;
22585
22642
  }).map(function (wallet, index) {
22586
- var walletMetaData = allWallets.find(function (walletFromList) {
22643
+ var walletMetaData = allWallets$1.find(function (walletFromList) {
22587
22644
  return walletFromList.name === (wallet.info ? wallet.info.name : wallet.name);
22588
22645
  });
22589
22646
  if (!walletMetaData) {
@@ -22664,7 +22721,7 @@ var SelectWalletDialog = (function (props) {
22664
22721
  className: "PaddingBottomXS PaddingLeftS PaddingRightS PaddingTopXS"
22665
22722
  }, /*#__PURE__*/React.createElement("div", {
22666
22723
  className: "Row"
22667
- }, /*#__PURE__*/React.createElement("input", {
22724
+ }, allWallets$1.length > 4 && /*#__PURE__*/React.createElement("input", {
22668
22725
  className: "Search",
22669
22726
  value: searchTerm,
22670
22727
  onChange: function onChange(event) {
@@ -29765,12 +29822,12 @@ var preflight$1 = /*#__PURE__*/function () {
29765
29822
  }();
29766
29823
  var Payment = /*#__PURE__*/function () {
29767
29824
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
29768
- 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;
29825
+ 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;
29769
29826
  return regenerator.wrap(function _callee2$(_context2) {
29770
29827
  while (1) {
29771
29828
  switch (_context2.prev = _context2.next) {
29772
29829
  case 0:
29773
- 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;
29830
+ 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;
29774
29831
  requireReactVersion();
29775
29832
  if (currency && !SUPPORTED_CURRENCIES.includes(currency.toLowerCase())) {
29776
29833
  currency = false;
@@ -29822,7 +29879,8 @@ var Payment = /*#__PURE__*/function () {
29822
29879
  link: link,
29823
29880
  wallet: wallet,
29824
29881
  title: title,
29825
- action: action
29882
+ action: action,
29883
+ wallets: wallets
29826
29884
  }
29827
29885
  }, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
29828
29886
  unmount: unmount,