@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.
@@ -1,6 +1,6 @@
1
1
  import { wallets, getWallets } from '@depay/web3-wallets-solana';
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 as route$2 } from '@depay/web3-payments-solana';
5
5
  import copy from '@uiw/copy-to-clipboard';
6
6
  import { NavigateStackContext, ReactDialogStack } from '@depay/react-dialog-stack';
@@ -22407,13 +22407,39 @@ var MenuIcon = (function (props) {
22407
22407
  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; }
22408
22408
  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; }
22409
22409
  var SelectWalletList = (function (props) {
22410
+ var _useContext = useContext(ConfigurationContext),
22411
+ walletsConfiguration = _useContext.wallets;
22412
+ var allWallets$1;
22413
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22414
+ allWallets$1 = useMemo(function () {
22415
+ var adjustedWallets = _toConsumableArray(allWallets);
22416
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22417
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22418
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22419
+ return unsortedWallet.name === sortedWallet;
22420
+ });
22421
+ if (currentListIndex > -1) {
22422
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22423
+ }
22424
+ });
22425
+ }
22426
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22427
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22428
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22429
+ });
22430
+ }
22431
+ return adjustedWallets;
22432
+ }, [walletsConfiguration]);
22433
+ } else {
22434
+ allWallets$1 = allWallets;
22435
+ }
22410
22436
  var parentElement = React.useRef();
22411
- var fuse = new Fuse(allWallets, {
22437
+ var fuse = new Fuse(allWallets$1, {
22412
22438
  keys: ['name'],
22413
22439
  threshold: 0.3,
22414
22440
  ignoreFieldNorm: true
22415
22441
  });
22416
- var _useState = useState(allWallets),
22442
+ var _useState = useState(allWallets$1),
22417
22443
  _useState2 = _slicedToArray(_useState, 2),
22418
22444
  resultList = _useState2[0],
22419
22445
  setResultList = _useState2[1];
@@ -22436,7 +22462,7 @@ var SelectWalletList = (function (props) {
22436
22462
  if (props.searchTerm.length) {
22437
22463
  setResultList(results);
22438
22464
  } else {
22439
- setResultList(allWallets);
22465
+ setResultList(allWallets$1);
22440
22466
  }
22441
22467
  }, [props.searchTerm]);
22442
22468
  return /*#__PURE__*/React.createElement("div", {
@@ -22506,9 +22532,35 @@ var SelectWalletDialog = (function (props) {
22506
22532
  _useState10 = _slicedToArray(_useState9, 2),
22507
22533
  dialogAnimationFinished = _useState10[0],
22508
22534
  setDialogAnimationFinished = _useState10[1];
22535
+ var _useContext = useContext(ConfigurationContext),
22536
+ walletsConfiguration = _useContext.wallets;
22509
22537
  var searchElement = useRef();
22510
- var _useContext = useContext(NavigateStackContext),
22511
- navigate = _useContext.navigate;
22538
+ var _useContext2 = useContext(NavigateStackContext),
22539
+ navigate = _useContext2.navigate;
22540
+ var allWallets$1;
22541
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort || walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22542
+ allWallets$1 = useMemo(function () {
22543
+ var adjustedWallets = _toConsumableArray(allWallets);
22544
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.sort) {
22545
+ walletsConfiguration.sort.forEach(function (sortedWallet, newIndex) {
22546
+ var currentListIndex = adjustedWallets.findIndex(function (unsortedWallet) {
22547
+ return unsortedWallet.name === sortedWallet;
22548
+ });
22549
+ if (currentListIndex > -1) {
22550
+ adjustedWallets.splice(newIndex, 0, adjustedWallets.splice(currentListIndex, 1)[0]);
22551
+ }
22552
+ });
22553
+ }
22554
+ if (walletsConfiguration !== null && walletsConfiguration !== void 0 && walletsConfiguration.whitelist) {
22555
+ adjustedWallets = adjustedWallets.filter(function (wallet) {
22556
+ return walletsConfiguration.whitelist.indexOf(wallet.name) > -1;
22557
+ });
22558
+ }
22559
+ return adjustedWallets;
22560
+ }, [walletsConfiguration]);
22561
+ } else {
22562
+ allWallets$1 = allWallets;
22563
+ }
22512
22564
  var onClickWallet = function onClickWallet(walletMetaData, wallet) {
22513
22565
  if (walletMetaData.via == 'detected') {
22514
22566
  if (walletMetaData.connectionType == 'app') {
@@ -22540,6 +22592,11 @@ var SelectWalletDialog = (function (props) {
22540
22592
  navigate('ConnectWallet');
22541
22593
  }
22542
22594
  };
22595
+ useEffect(function () {
22596
+ if (allWallets$1.length === 1) {
22597
+ onClickWallet(allWallets$1[0]);
22598
+ }
22599
+ }, [allWallets$1]);
22543
22600
  useEffect(function () {
22544
22601
  var wallets = [];
22545
22602
  getWallets({
@@ -22549,9 +22606,9 @@ var SelectWalletDialog = (function (props) {
22549
22606
  }
22550
22607
  });
22551
22608
  var previouslyConnectedWalletName = get$1();
22552
- var previouslyConnectedWallet = allWallets.find(function (wallet) {
22609
+ var previouslyConnectedWallet = allWallets$1.find(function (wallet) {
22553
22610
  return wallet.name == previouslyConnectedWalletName;
22554
- }) || allWallets.find(function (wallet) {
22611
+ }) || allWallets$1.find(function (wallet) {
22555
22612
  return wallet.name == previouslyConnectedWalletName;
22556
22613
  });
22557
22614
  if (previouslyConnectedWallet) {
@@ -22582,7 +22639,7 @@ var SelectWalletDialog = (function (props) {
22582
22639
  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);
22583
22640
  }) === index;
22584
22641
  }).map(function (wallet, index) {
22585
- var walletMetaData = allWallets.find(function (walletFromList) {
22642
+ var walletMetaData = allWallets$1.find(function (walletFromList) {
22586
22643
  return walletFromList.name === (wallet.info ? wallet.info.name : wallet.name);
22587
22644
  });
22588
22645
  if (!walletMetaData) {
@@ -22663,7 +22720,7 @@ var SelectWalletDialog = (function (props) {
22663
22720
  className: "PaddingBottomXS PaddingLeftS PaddingRightS PaddingTopXS"
22664
22721
  }, /*#__PURE__*/React.createElement("div", {
22665
22722
  className: "Row"
22666
- }, /*#__PURE__*/React.createElement("input", {
22723
+ }, allWallets$1.length > 4 && /*#__PURE__*/React.createElement("input", {
22667
22724
  className: "Search",
22668
22725
  value: searchTerm,
22669
22726
  onChange: function onChange(event) {
@@ -37411,12 +37468,12 @@ var preflight$1 = /*#__PURE__*/function () {
37411
37468
  }();
37412
37469
  var Payment = /*#__PURE__*/function () {
37413
37470
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
37414
- 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;
37471
+ 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;
37415
37472
  return regenerator.wrap(function _callee2$(_context2) {
37416
37473
  while (1) {
37417
37474
  switch (_context2.prev = _context2.next) {
37418
37475
  case 0:
37419
- 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;
37476
+ 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;
37420
37477
  requireReactVersion();
37421
37478
  if (currency && !SUPPORTED_CURRENCIES.includes(currency.toLowerCase())) {
37422
37479
  currency = false;
@@ -37468,7 +37525,8 @@ var Payment = /*#__PURE__*/function () {
37468
37525
  link: link,
37469
37526
  wallet: wallet,
37470
37527
  title: title,
37471
- action: action
37528
+ action: action,
37529
+ wallets: wallets
37472
37530
  }
37473
37531
  }, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
37474
37532
  unmount: unmount,