@aurora-is-near/intents-swap-widget 3.17.2 → 3.17.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/{config-BVaLnxO9.js → config-VpsP2eLV.js} +1022 -958
- package/dist/{config-BVaLnxO9.js.map → config-VpsP2eLV.js.map} +1 -1
- package/dist/config.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/ext/alchemy/index.js +1 -1
- package/dist/ext/index.js +1 -1
- package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
- package/dist/features/BalanceRpcLoader/index.js +1 -1
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
- package/dist/features/ChainsDropdown/index.js +1 -1
- package/dist/features/DepositMethodSwitcher.js +1 -1
- package/dist/features/ErrorBoundary.js +1 -1
- package/dist/features/ExternalDeposit.js +1 -1
- package/dist/features/SendAddress/index.js +1 -1
- package/dist/features/SendAddress/useNotification.js +1 -1
- package/dist/features/SubmitButton/index.js +1 -1
- package/dist/features/SuccessScreen/index.js +1 -1
- package/dist/features/SwapDirectionSwitcher.js +1 -1
- package/dist/features/SwapQuote/SwapQuote.js +1 -1
- package/dist/features/SwapQuote/index.js +1 -1
- package/dist/features/TokenInput/TokenInput.js +1 -1
- package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
- package/dist/features/TokenInput/TokenInputSource.js +1 -1
- package/dist/features/TokenInput/TokenInputTarget.js +1 -1
- package/dist/features/TokenInput/WalletBalance.js +1 -1
- package/dist/features/TokenInput/hooks/index.js +1 -1
- package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
- package/dist/features/TokenInput/index.js +1 -1
- package/dist/features/TokensList/TokenItem.d.ts +2 -2
- package/dist/features/TokensList/TokenItem.js +1 -2
- package/dist/features/TokensList/TokensList.js +10 -2
- package/dist/features/TokensList/TokensList.js.map +1 -1
- package/dist/features/TokensList/constants.d.ts +4 -0
- package/dist/features/TokensList/constants.js +8 -0
- package/dist/features/TokensList/constants.js.map +1 -0
- package/dist/features/TokensList/hooks/index.d.ts +1 -0
- package/dist/features/TokensList/hooks/index.js +5 -0
- package/dist/features/TokensList/hooks/index.js.map +1 -0
- package/dist/features/TokensList/hooks/useFocusOnList.d.ts +9 -0
- package/dist/features/TokensList/hooks/useFocusOnList.js +33 -0
- package/dist/features/TokensList/hooks/useFocusOnList.js.map +1 -0
- package/dist/features/TokensList/index.d.ts +2 -1
- package/dist/features/TokensList/index.js +1 -1
- package/dist/features/TokensList/types.d.ts +14 -0
- package/dist/features/TokensList/types.js +2 -0
- package/dist/features/TokensList/types.js.map +1 -0
- package/dist/features/TokensList/utils/getFirstGroupItemTotalIndex.d.ts +9 -0
- package/dist/features/TokensList/utils/getFirstGroupItemTotalIndex.js +8 -0
- package/dist/features/TokensList/utils/getFirstGroupItemTotalIndex.js.map +1 -0
- package/dist/features/TokensList/utils/getGroupHeadersTotalIndexes.d.ts +8 -0
- package/dist/features/TokensList/utils/getGroupHeadersTotalIndexes.js +5 -0
- package/dist/features/TokensList/utils/getGroupHeadersTotalIndexes.js.map +1 -0
- package/dist/features/TokensList/utils/getListItemsTotalCount.d.ts +8 -0
- package/dist/features/TokensList/utils/getListItemsTotalCount.js +8 -0
- package/dist/features/TokensList/utils/getListItemsTotalCount.js.map +1 -0
- package/dist/features/TokensList/utils/getListState.d.ts +9 -0
- package/dist/features/TokensList/utils/getListState.js +5 -0
- package/dist/features/TokensList/utils/getListState.js.map +1 -0
- package/dist/features/TokensList/utils/getListTotalHeight.d.ts +8 -0
- package/dist/features/TokensList/utils/getListTotalHeight.js +12 -0
- package/dist/features/TokensList/utils/getListTotalHeight.js.map +1 -0
- package/dist/features/TokensList/utils/getTokenByTotalIndex.d.ts +9 -0
- package/dist/features/TokensList/utils/getTokenByTotalIndex.js +7 -0
- package/dist/features/TokensList/utils/getTokenByTotalIndex.js.map +1 -0
- package/dist/features/TokensList/utils/index.d.ts +6 -0
- package/dist/features/TokensList/utils/index.js +15 -0
- package/dist/features/TokensList/utils/index.js.map +1 -0
- package/dist/features/TokensModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/features/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAllTokens.js +1 -1
- package/dist/hooks/useChains.js +1 -1
- package/dist/hooks/useCompatibilityCheck.js +1 -1
- package/dist/hooks/useDefaultToken.js +1 -1
- package/dist/hooks/useExternalDepositStatus/index.js +1 -1
- package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
- package/dist/hooks/useIntentsBalance.js +1 -1
- package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
- package/dist/hooks/useMakeDepositAddress.js +1 -1
- package/dist/hooks/useMakeIntentsTransfer.js +1 -1
- package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
- package/dist/hooks/useMakeQuote.js +1 -1
- package/dist/hooks/useMakeQuoteTransfer.js +1 -1
- package/dist/hooks/useMakeTransfer.js +1 -1
- package/dist/hooks/useMergedBalance.js +1 -1
- package/dist/hooks/useSwitchChain.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +1 -1
- package/dist/hooks/useTokensFiltered.js +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/index.js +1 -1
- package/dist/machine/effects/index.js +1 -1
- package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
- package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
- package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
- package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
- package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
- package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
- package/dist/machine/effects/useWalletConnEffect.js +1 -1
- package/dist/machine/events/index.js +1 -1
- package/dist/machine/events/tokenSelect.js +1 -1
- package/dist/machine/events/validateInputAndMoveTo.js +1 -1
- package/dist/machine/events/validateInputs.js +1 -1
- package/dist/machine/index.js +1 -1
- package/dist/machine/snap.js +1 -1
- package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
- package/dist/machine/subscriptions/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/package.json +1 -1
- package/src/features/TokensList/TokenItem.tsx +7 -3
- package/src/features/TokensList/TokensList.tsx +151 -57
- package/src/features/TokensList/constants.ts +4 -0
- package/src/features/TokensList/hooks/index.ts +1 -0
- package/src/features/TokensList/hooks/useFocusOnList.ts +56 -0
- package/src/features/TokensList/types.ts +28 -0
- package/src/features/TokensList/utils/getFirstGroupItemTotalIndex.ts +28 -0
- package/src/features/TokensList/utils/getGroupHeadersTotalIndexes.ts +21 -0
- package/src/features/TokensList/utils/getListItemsTotalCount.ts +14 -0
- package/src/features/TokensList/utils/getListState.ts +16 -0
- package/src/features/TokensList/utils/getListTotalHeight.ts +25 -0
- package/src/features/TokensList/utils/getTokenByTotalIndex.ts +19 -0
- package/src/features/TokensList/utils/index.ts +6 -0
package/dist/config.js
CHANGED
|
@@ -8,7 +8,7 @@ import "react";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "react-i18next";
|
|
10
10
|
import "./localisation.js";
|
|
11
|
-
import { W as M,
|
|
11
|
+
import { W as M, ah as N, y as O } from "./config-VpsP2eLV.js";
|
|
12
12
|
import "@headlessui/react";
|
|
13
13
|
import "framer-motion";
|
|
14
14
|
import "lucide-react";
|
package/dist/errors.js
CHANGED
|
@@ -3,7 +3,7 @@ import "@tanstack/react-query";
|
|
|
3
3
|
import "./parse.js";
|
|
4
4
|
import "./load.js";
|
|
5
5
|
import "./types.js";
|
|
6
|
-
import { t as s } from "../../config-
|
|
6
|
+
import { t as s } from "../../config-VpsP2eLV.js";
|
|
7
7
|
import "../../machine/guards/index.js";
|
|
8
8
|
import "../../machine/machine.js";
|
|
9
9
|
import "../../machine/events/utils/fireEvent.js";
|
package/dist/ext/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import "../../logger.js";
|
|
|
3
3
|
import "../../utils/ton/getTonTokenBalance.js";
|
|
4
4
|
import "../../utils/solana/getSolanaTokenBalance.js";
|
|
5
5
|
import "../../hooks/useWalletAddressForToken.js";
|
|
6
|
-
import { D as x } from "../../config-
|
|
6
|
+
import { D as x } from "../../config-VpsP2eLV.js";
|
|
7
7
|
import "../../utils/evm/isEvmChain.js";
|
|
8
8
|
import "../../utils/evm/isEvmToken.js";
|
|
9
9
|
import "../../utils/evm/isEvmBaseToken.js";
|
|
@@ -5,7 +5,7 @@ import { AnimatePresence as F, motion as T } from "framer-motion";
|
|
|
5
5
|
import * as x from "lucide-react";
|
|
6
6
|
import { ChainItem as d } from "./ChainItem.js";
|
|
7
7
|
import { AllNetworksIcon as h } from "./AllNetworksIcon.js";
|
|
8
|
-
import { d as z, y as O } from "../../config-
|
|
8
|
+
import { d as z, y as O } from "../../config-VpsP2eLV.js";
|
|
9
9
|
import { Hr as j } from "../../components/Hr.js";
|
|
10
10
|
import { Icon as i } from "../../components/Icon.js";
|
|
11
11
|
import { notReachable as u } from "../../utils/notReachable.js";
|
|
@@ -3,7 +3,7 @@ import * as l from "lucide-react";
|
|
|
3
3
|
import { cn as m } from "../utils/cn.js";
|
|
4
4
|
import { Card as p } from "../components/Card.js";
|
|
5
5
|
import { Button as i } from "../components/Button.js";
|
|
6
|
-
import { b as c } from "../config-
|
|
6
|
+
import { b as c } from "../config-VpsP2eLV.js";
|
|
7
7
|
import "ethers";
|
|
8
8
|
import "../machine/machine.js";
|
|
9
9
|
import { fireEvent as d } from "../machine/events/utils/fireEvent.js";
|
|
@@ -12,7 +12,7 @@ import { formatAddressTruncate as _ } from "../utils/formatters/formatAddressTru
|
|
|
12
12
|
import "../utils/cn.js";
|
|
13
13
|
import { notReachable as l } from "../utils/notReachable.js";
|
|
14
14
|
import "@tanstack/react-query";
|
|
15
|
-
import { b as E, u as I } from "../config-
|
|
15
|
+
import { b as E, u as I } from "../config-VpsP2eLV.js";
|
|
16
16
|
import { guardStates as k } from "../machine/guards/index.js";
|
|
17
17
|
import { moveTo as A } from "../machine/machine.js";
|
|
18
18
|
import { fireEvent as o } from "../machine/events/utils/fireEvent.js";
|
|
@@ -11,7 +11,7 @@ import "../../constants/chains.js";
|
|
|
11
11
|
import "viem";
|
|
12
12
|
import "ethers";
|
|
13
13
|
import { cn as M } from "../../utils/cn.js";
|
|
14
|
-
import { b as V, y as _ } from "../../config-
|
|
14
|
+
import { b as V, y as _ } from "../../config-VpsP2eLV.js";
|
|
15
15
|
import "../../machine/machine.js";
|
|
16
16
|
import { fireEvent as d } from "../../machine/events/utils/fireEvent.js";
|
|
17
17
|
import { useTypedTranslation as j } from "../../localisation.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo as o } from "react";
|
|
2
|
-
import { b as d, y as l } from "../../config-
|
|
2
|
+
import { b as d, y as l } from "../../config-VpsP2eLV.js";
|
|
3
3
|
import { useTypedTranslation as c } from "../../localisation.js";
|
|
4
4
|
import { getIntentsAccountId as u } from "../../utils/intents/getIntentsAccountId.js";
|
|
5
5
|
import { CHAINS_LIST as f, EVM_CHAINS as m } from "../../constants/chains.js";
|
|
@@ -3,7 +3,7 @@ import "react-i18next";
|
|
|
3
3
|
import "../../components/Button.js";
|
|
4
4
|
import "../../components/TinyNumber.js";
|
|
5
5
|
import "../../components/ErrorMessage.js";
|
|
6
|
-
import { S as b } from "../../config-
|
|
6
|
+
import { S as b } from "../../config-VpsP2eLV.js";
|
|
7
7
|
import "../../localisation.js";
|
|
8
8
|
import "../../utils/checkers/isNotEmptyAmount.js";
|
|
9
9
|
export {
|
|
@@ -5,7 +5,7 @@ import { SummaryItem as n } from "./SummaryItem.js";
|
|
|
5
5
|
import { Hr as w } from "../../components/Hr.js";
|
|
6
6
|
import { Card as y } from "../../components/Card.js";
|
|
7
7
|
import { CloseButton as b } from "../../components/CloseButton.js";
|
|
8
|
-
import { b as A } from "../../config-
|
|
8
|
+
import { b as A } from "../../config-VpsP2eLV.js";
|
|
9
9
|
import "ethers";
|
|
10
10
|
import "../../machine/machine.js";
|
|
11
11
|
import { fireEvent as C } from "../../machine/events/utils/fireEvent.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { DirectionSwitcher as r } from "../components/DirectionSwitcher.js";
|
|
3
|
-
import { b as i } from "../config-
|
|
3
|
+
import { b as i } from "../config-VpsP2eLV.js";
|
|
4
4
|
import "ethers";
|
|
5
5
|
import "../machine/machine.js";
|
|
6
6
|
import { fireEvent as n } from "../machine/events/utils/fireEvent.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "./SwapQuoteSkeleton.js";
|
|
3
|
-
import { a3 as s } from "../../config-
|
|
3
|
+
import { a3 as s } from "../../config-VpsP2eLV.js";
|
|
4
4
|
import "../../components/Notes.js";
|
|
5
5
|
import "../../components/Accordion.js";
|
|
6
6
|
import "../../utils/formatters/formatUsdAmount.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { a5 as I } from "../../config-
|
|
3
|
+
import { a5 as I } from "../../config-VpsP2eLV.js";
|
|
4
4
|
import "./utils/getBalancePortion.js";
|
|
5
5
|
import "./utils/getUsdDisplayAmount.js";
|
|
6
6
|
import "./TokenInputHeading.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Token, TokenBalance } from '../../types/token';
|
|
2
|
-
export declare const TOKEN_ITEM_HEIGHT = 58;
|
|
3
2
|
type Msg = {
|
|
4
3
|
type: 'on_select_token';
|
|
5
4
|
token: Token;
|
|
@@ -9,8 +8,9 @@ type Props = {
|
|
|
9
8
|
balance: TokenBalance;
|
|
10
9
|
showBalance?: boolean;
|
|
11
10
|
isNotSelectable?: boolean;
|
|
11
|
+
isFocused?: boolean;
|
|
12
12
|
className?: string;
|
|
13
13
|
onMsg: (msg: Msg) => void;
|
|
14
14
|
};
|
|
15
|
-
export declare const TokenItem: ({ token, balance, showBalance, isNotSelectable, className, onMsg, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const TokenItem: ({ token, balance, showBalance, isNotSelectable, isFocused, className, onMsg, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../utils/cn.js";
|
|
3
|
-
import { aa as
|
|
3
|
+
import { aa as e } from "../../config-VpsP2eLV.js";
|
|
4
4
|
import "../../components/TokenIcon.js";
|
|
5
5
|
import "../../components/TinyNumber.js";
|
|
6
6
|
import "../../utils/formatters/getUsdDisplayBalance.js";
|
|
7
7
|
export {
|
|
8
|
-
T as TOKEN_ITEM_HEIGHT,
|
|
9
8
|
e as TokenItem
|
|
10
9
|
};
|
|
11
10
|
//# sourceMappingURL=TokenItem.js.map
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "virtua";
|
|
3
3
|
import "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ac as g } from "../../config-VpsP2eLV.js";
|
|
5
|
+
import "./hooks/useFocusOnList.js";
|
|
5
6
|
import "./TokensListPlaceholder.js";
|
|
7
|
+
import "./constants.js";
|
|
8
|
+
import "./utils/getGroupHeadersTotalIndexes.js";
|
|
9
|
+
import "./utils/getFirstGroupItemTotalIndex.js";
|
|
10
|
+
import "./utils/getListItemsTotalCount.js";
|
|
11
|
+
import "./utils/getTokenByTotalIndex.js";
|
|
12
|
+
import "./utils/getListTotalHeight.js";
|
|
13
|
+
import "./utils/getListState.js";
|
|
6
14
|
import "../../utils/cn.js";
|
|
7
15
|
import "../../components/Hr.js";
|
|
8
16
|
import "../../utils/intents/getTokenBalanceKey.js";
|
|
9
17
|
import "../../localisation.js";
|
|
10
18
|
export {
|
|
11
|
-
|
|
19
|
+
g as TokensList
|
|
12
20
|
};
|
|
13
21
|
//# sourceMappingURL=TokensList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokensList.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TokensList.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/features/TokensList/constants.ts"],"sourcesContent":["export const MAX_LIST_VIEW_AREA_HEIGHT = '450px';\nexport const LIST_CONTAINER_ID = 'virtual-tokens-list';\nexport const TOKEN_ITEM_HEIGHT = 58;\nexport const LIST_SECTION_HEADER_HEIGHT = 62;\n"],"names":["MAX_LIST_VIEW_AREA_HEIGHT","LIST_CONTAINER_ID","TOKEN_ITEM_HEIGHT","LIST_SECTION_HEADER_HEIGHT"],"mappings":"AAAO,MAAMA,IAA4B,SAC5BC,IAAoB,uBACpBC,IAAoB,IACpBC,IAA6B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFocusOnList } from './useFocusOnList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VListHandle } from 'virtua';
|
|
2
|
+
type Args = {
|
|
3
|
+
initialFocusedIndex: number;
|
|
4
|
+
listRef: VListHandle | null;
|
|
5
|
+
onFocus: (index: number) => void;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const useFocusOnList: ({ initialFocusedIndex, listRef, onFocus, onBlur, }: Args) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback as u, useEffect as m } from "react";
|
|
2
|
+
import { LIST_CONTAINER_ID as r } from "../constants.js";
|
|
3
|
+
import { useHandleKeyDown as c } from "../../../hooks/useHandleKeyDown.js";
|
|
4
|
+
const f = ({
|
|
5
|
+
initialFocusedIndex: n,
|
|
6
|
+
listRef: s,
|
|
7
|
+
onFocus: i,
|
|
8
|
+
onBlur: o
|
|
9
|
+
}) => {
|
|
10
|
+
c("ArrowDown", () => {
|
|
11
|
+
const e = document.getElementById(r);
|
|
12
|
+
e && document.activeElement !== e && (i(n), s?.scrollToIndex(n, { align: "nearest" }), setTimeout(() => {
|
|
13
|
+
e.focus({ preventScroll: !0 });
|
|
14
|
+
}, 0));
|
|
15
|
+
});
|
|
16
|
+
const t = u(
|
|
17
|
+
(e) => {
|
|
18
|
+
const l = document.getElementById(r);
|
|
19
|
+
e.target === l && o();
|
|
20
|
+
},
|
|
21
|
+
[o]
|
|
22
|
+
);
|
|
23
|
+
m(() => {
|
|
24
|
+
const e = document.getElementById(r);
|
|
25
|
+
return e?.addEventListener("blur", t), () => {
|
|
26
|
+
e?.removeEventListener("blur", t);
|
|
27
|
+
};
|
|
28
|
+
}, [t]);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
f as useFocusOnList
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=useFocusOnList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFocusOnList.js","sources":["../../../../src/features/TokensList/hooks/useFocusOnList.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport type { VListHandle } from 'virtua';\n\nimport { LIST_CONTAINER_ID } from '../constants';\n\nimport { useHandleKeyDown } from '@/hooks/useHandleKeyDown';\n\ntype Args = {\n initialFocusedIndex: number;\n listRef: VListHandle | null;\n onFocus: (index: number) => void;\n onBlur: () => void;\n};\n\nexport const useFocusOnList = ({\n initialFocusedIndex,\n listRef,\n onFocus,\n onBlur,\n}: Args) => {\n useHandleKeyDown('ArrowDown', () => {\n const virtualListDiv = document.getElementById(LIST_CONTAINER_ID);\n\n if (virtualListDiv && document.activeElement !== virtualListDiv) {\n onFocus(initialFocusedIndex);\n listRef?.scrollToIndex(initialFocusedIndex, { align: 'nearest' });\n\n // required to prevent initial scroll on focus\n // which causes list's jump\n setTimeout(() => {\n virtualListDiv.focus({ preventScroll: true });\n }, 0);\n }\n });\n\n const handleBlur = useCallback(\n (event: FocusEvent) => {\n const virtualListDiv = document.getElementById(LIST_CONTAINER_ID);\n\n if (event.target === virtualListDiv) {\n onBlur();\n }\n },\n [onBlur],\n );\n\n useEffect(() => {\n const virtualListDiv = document.getElementById(LIST_CONTAINER_ID);\n\n virtualListDiv?.addEventListener('blur', handleBlur);\n\n return () => {\n virtualListDiv?.removeEventListener('blur', handleBlur);\n };\n }, [handleBlur]);\n};\n"],"names":["useFocusOnList","initialFocusedIndex","listRef","onFocus","onBlur","useHandleKeyDown","virtualListDiv","LIST_CONTAINER_ID","handleBlur","useCallback","event","useEffect"],"mappings":";;;AAcO,MAAMA,IAAiB,CAAC;AAAA,EAC7B,qBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AACF,MAAY;AACV,EAAAC,EAAiB,aAAa,MAAM;AAClC,UAAMC,IAAiB,SAAS,eAAeC,CAAiB;AAEhE,IAAID,KAAkB,SAAS,kBAAkBA,MAC/CH,EAAQF,CAAmB,GAC3BC,GAAS,cAAcD,GAAqB,EAAE,OAAO,WAAW,GAIhE,WAAW,MAAM;AACf,MAAAK,EAAe,MAAM,EAAE,eAAe,GAAA,CAAM;AAAA,IAC9C,GAAG,CAAC;AAAA,EAER,CAAC;AAED,QAAME,IAAaC;AAAA,IACjB,CAACC,MAAsB;AACrB,YAAMJ,IAAiB,SAAS,eAAeC,CAAiB;AAEhE,MAAIG,EAAM,WAAWJ,KACnBF,EAAA;AAAA,IAEJ;AAAA,IACA,CAACA,CAAM;AAAA,EAAA;AAGT,EAAAO,EAAU,MAAM;AACd,UAAML,IAAiB,SAAS,eAAeC,CAAiB;AAEhE,WAAAD,GAAgB,iBAAiB,QAAQE,CAAU,GAE5C,MAAM;AACX,MAAAF,GAAgB,oBAAoB,QAAQE,CAAU;AAAA,IACxD;AAAA,EACF,GAAG,CAACA,CAAU,CAAC;AACjB;"}
|
|
@@ -29,11 +29,12 @@ export declare const TokensList: (({ variant, search, className, groupTokens, sh
|
|
|
29
29
|
actionLabel: string;
|
|
30
30
|
actionType?: "primary" | "outlined";
|
|
31
31
|
})) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
Item: ({ token, balance, showBalance, isNotSelectable, className, onMsg, }: {
|
|
32
|
+
Item: ({ token, balance, showBalance, isNotSelectable, isFocused, className, onMsg, }: {
|
|
33
33
|
token: import('../..').Token;
|
|
34
34
|
balance: import('../..').TokenBalance;
|
|
35
35
|
showBalance?: boolean;
|
|
36
36
|
isNotSelectable?: boolean;
|
|
37
|
+
isFocused?: boolean;
|
|
37
38
|
className?: string;
|
|
38
39
|
onMsg: (msg: {
|
|
39
40
|
type: "on_select_token";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Token } from '../../types/token';
|
|
2
|
+
type OddGroup = {
|
|
3
|
+
label: string | null;
|
|
4
|
+
count: number;
|
|
5
|
+
tokens?: never;
|
|
6
|
+
};
|
|
7
|
+
type EvenGroup = {
|
|
8
|
+
label?: never;
|
|
9
|
+
count?: never;
|
|
10
|
+
tokens: Token[];
|
|
11
|
+
};
|
|
12
|
+
export type ListGroup<N extends number = 6> = N extends 0 ? [] : N extends 1 ? [EvenGroup] : N extends 2 ? [OddGroup, EvenGroup] : N extends 4 ? [OddGroup, EvenGroup, OddGroup, EvenGroup] : N extends 6 ? [OddGroup, EvenGroup, OddGroup, EvenGroup, OddGroup, EvenGroup] : never;
|
|
13
|
+
export type AnyListGroup = ListGroup<0 | 1 | 2 | 4 | 6>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyListGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get index across all groups of the first item in a given group
|
|
4
|
+
*
|
|
5
|
+
* @param tokensList - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @param groupIndex - The index of the group
|
|
7
|
+
* @returns The total index of the first item in the group
|
|
8
|
+
*/
|
|
9
|
+
export declare const getFirstGroupItemTotalIndex: (tokensList: AnyListGroup, groupIndex: number) => number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const u = (r, e) => {
|
|
2
|
+
const t = e % 2 !== 0 ? e : 0;
|
|
3
|
+
return t <= 1 ? t : r.reduce((o, n, s) => o + (n.tokens && s < t ? n.tokens.length + 1 : 0), 0) + 1;
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
u as getFirstGroupItemTotalIndex
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=getFirstGroupItemTotalIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFirstGroupItemTotalIndex.js","sources":["../../../../src/features/TokensList/utils/getFirstGroupItemTotalIndex.ts"],"sourcesContent":["import type { AnyListGroup } from '../types';\n\n/**\n * Get index across all groups of the first item in a given group\n *\n * @param tokensList - The list of tokens (grouped or ungrouped)\n * @param groupIndex - The index of the group\n * @returns The total index of the first item in the group\n */\nexport const getFirstGroupItemTotalIndex = (\n tokensList: AnyListGroup,\n groupIndex: number,\n) => {\n const tokensGroupIndex = groupIndex % 2 !== 0 ? groupIndex : 0;\n\n if (tokensGroupIndex <= 1) {\n return tokensGroupIndex;\n }\n\n return (\n tokensList.reduce((acc, group, index) => {\n return (\n acc +\n (group.tokens && index < tokensGroupIndex ? group.tokens.length + 1 : 0)\n );\n }, 0) + 1\n ); // +1 for current group's header\n};\n"],"names":["getFirstGroupItemTotalIndex","tokensList","groupIndex","tokensGroupIndex","acc","group","index"],"mappings":"AASO,MAAMA,IAA8B,CACzCC,GACAC,MACG;AACH,QAAMC,IAAmBD,IAAa,MAAM,IAAIA,IAAa;AAE7D,SAAIC,KAAoB,IACfA,IAIPF,EAAW,OAAO,CAACG,GAAKC,GAAOC,MAE3BF,KACCC,EAAM,UAAUC,IAAQH,IAAmBE,EAAM,OAAO,SAAS,IAAI,IAEvE,CAAC,IAAI;AAEZ;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyListGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get positions of all group headers in the combined list
|
|
4
|
+
*
|
|
5
|
+
* @param tokensList - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @returns List of positions of all group headers in the combined list
|
|
7
|
+
*/
|
|
8
|
+
export declare const getGroupHeadersTotalIndexes: (tokensList: AnyListGroup) => number[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGroupHeadersTotalIndexes.js","sources":["../../../../src/features/TokensList/utils/getGroupHeadersTotalIndexes.ts"],"sourcesContent":["import type { AnyListGroup } from '../types';\n\n/**\n * Get positions of all group headers in the combined list\n *\n * @param tokensList - The list of tokens (grouped or ungrouped)\n * @returns List of positions of all group headers in the combined list\n */\nexport const getGroupHeadersTotalIndexes = (tokensList: AnyListGroup) => {\n return tokensList.reduce<number[]>((acc, group, index) => {\n if (index === 0 && group.label) {\n return [0];\n }\n\n if (group.tokens && index < tokensList.length - 1) {\n return [...acc, (acc[acc.length - 1] ?? 0) + group.tokens.length + 1];\n }\n\n return acc;\n }, []);\n};\n"],"names":["getGroupHeadersTotalIndexes","tokensList","acc","group","index"],"mappings":"AAQO,MAAMA,IAA8B,CAACC,MACnCA,EAAW,OAAiB,CAACC,GAAKC,GAAOC,MAC1CA,MAAU,KAAKD,EAAM,QAChB,CAAC,CAAC,IAGPA,EAAM,UAAUC,IAAQH,EAAW,SAAS,IACvC,CAAC,GAAGC,IAAMA,EAAIA,EAAI,SAAS,CAAC,KAAK,KAAKC,EAAM,OAAO,SAAS,CAAC,IAG/DD,GACN,CAAA,CAAE;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyListGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the total number of RENDERED items in the list (including group headers)
|
|
4
|
+
*
|
|
5
|
+
* @param tokensList - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @returns The total number of items in the list
|
|
7
|
+
*/
|
|
8
|
+
export declare const getListItemsTotalCount: (tokensList: AnyListGroup) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getListItemsTotalCount.js","sources":["../../../../src/features/TokensList/utils/getListItemsTotalCount.ts"],"sourcesContent":["import type { AnyListGroup } from '../types';\n\n/**\n * Get the total number of RENDERED items in the list (including group headers)\n *\n * @param tokensList - The list of tokens (grouped or ungrouped)\n * @returns The total number of items in the list\n */\nexport const getListItemsTotalCount = (tokensList: AnyListGroup) => {\n return tokensList.reduce(\n (acc, group) => acc + (group.tokens?.length ?? 0) + (group.label ? 1 : 0),\n 0,\n );\n};\n"],"names":["getListItemsTotalCount","tokensList","acc","group"],"mappings":"AAQO,MAAMA,IAAyB,CAACC,MAC9BA,EAAW;AAAA,EAChB,CAACC,GAAKC,MAAUD,KAAOC,EAAM,QAAQ,UAAU,MAAMA,EAAM,QAAQ,IAAI;AAAA,EACvE;AAAA;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Token } from '../../../types/token';
|
|
2
|
+
/**
|
|
3
|
+
* Get the state of the list
|
|
4
|
+
*
|
|
5
|
+
* @param tokens - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @param search - The search string
|
|
7
|
+
* @returns The state of the list: 'EMPTY_SEARCH', 'NO_TOKENS', 'HAS_TOKENS'
|
|
8
|
+
*/
|
|
9
|
+
export declare const getListState: (tokens: ReadonlyArray<Token>, search: string) => "HAS_TOKENS" | "NO_TOKENS" | "EMPTY_SEARCH";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getListState.js","sources":["../../../../src/features/TokensList/utils/getListState.ts"],"sourcesContent":["import type { Token } from '@/types/token';\n\n/**\n * Get the state of the list\n *\n * @param tokens - The list of tokens (grouped or ungrouped)\n * @param search - The search string\n * @returns The state of the list: 'EMPTY_SEARCH', 'NO_TOKENS', 'HAS_TOKENS'\n */\nexport const getListState = (tokens: ReadonlyArray<Token>, search: string) => {\n if (tokens.length) {\n return 'HAS_TOKENS';\n }\n\n return !search ? 'NO_TOKENS' : 'EMPTY_SEARCH';\n};\n"],"names":["getListState","tokens","search"],"mappings":"AASO,MAAMA,IAAe,CAACC,GAA8BC,MACrDD,EAAO,SACF,eAGDC,IAAuB,iBAAd;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyListGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the total height of the list
|
|
4
|
+
*
|
|
5
|
+
* @param tokensList - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @returns The total height of the list
|
|
7
|
+
*/
|
|
8
|
+
export declare const getListTotalHeight: (tokensList: AnyListGroup) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TOKEN_ITEM_HEIGHT as n, LIST_SECTION_HEADER_HEIGHT as r } from "../constants.js";
|
|
2
|
+
const T = (t) => t.reduce(
|
|
3
|
+
(e, o) => e + (o.tokens?.length ?? 0),
|
|
4
|
+
0
|
|
5
|
+
), E = (t) => {
|
|
6
|
+
const e = T(t);
|
|
7
|
+
return e ? e * n + t.filter((o) => !!o.label).length * r : n * 2;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
E as getListTotalHeight
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=getListTotalHeight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getListTotalHeight.js","sources":["../../../../src/features/TokensList/utils/getListTotalHeight.ts"],"sourcesContent":["import { LIST_SECTION_HEADER_HEIGHT, TOKEN_ITEM_HEIGHT } from '../constants';\nimport type { AnyListGroup } from '../types';\n\nconst getTokensTotalCount = (tokensList: AnyListGroup) => {\n return tokensList.reduce(\n (acc, group) => acc + (group.tokens?.length ?? 0),\n 0,\n );\n};\n\n/**\n * Get the total height of the list\n *\n * @param tokensList - The list of tokens (grouped or ungrouped)\n * @returns The total height of the list\n */\nexport const getListTotalHeight = (tokensList: AnyListGroup) => {\n const tokensCount = getTokensTotalCount(tokensList);\n\n return tokensCount\n ? tokensCount * TOKEN_ITEM_HEIGHT +\n tokensList.filter((group) => !!group.label).length *\n LIST_SECTION_HEADER_HEIGHT\n : TOKEN_ITEM_HEIGHT * 2;\n};\n"],"names":["getTokensTotalCount","tokensList","acc","group","getListTotalHeight","tokensCount","TOKEN_ITEM_HEIGHT","LIST_SECTION_HEADER_HEIGHT"],"mappings":";AAGA,MAAMA,IAAsB,CAACC,MACpBA,EAAW;AAAA,EAChB,CAACC,GAAKC,MAAUD,KAAOC,EAAM,QAAQ,UAAU;AAAA,EAC/C;AAAA,GAUSC,IAAqB,CAACH,MAA6B;AAC9D,QAAMI,IAAcL,EAAoBC,CAAU;AAElD,SAAOI,IACHA,IAAcC,IACZL,EAAW,OAAO,CAACE,MAAU,CAAC,CAACA,EAAM,KAAK,EAAE,SAC1CI,IACJD,IAAoB;AAC1B;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AnyListGroup } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the token by total index across all groups and headers
|
|
4
|
+
*
|
|
5
|
+
* @param tokensList - The list of tokens (grouped or ungrouped)
|
|
6
|
+
* @param totalIndex - The total index of the token
|
|
7
|
+
* @returns The token
|
|
8
|
+
*/
|
|
9
|
+
export declare const getTokenByTotalIndex: (tokensList: AnyListGroup, totalIndex: number) => import('../../..').Token | null | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTokenByTotalIndex.js","sources":["../../../../src/features/TokensList/utils/getTokenByTotalIndex.ts"],"sourcesContent":["import type { AnyListGroup } from '../types';\n\n/**\n * Get the token by total index across all groups and headers\n *\n * @param tokensList - The list of tokens (grouped or ungrouped)\n * @param totalIndex - The total index of the token\n * @returns The token\n */\nexport const getTokenByTotalIndex = (\n tokensList: AnyListGroup,\n totalIndex: number,\n) => {\n const flatList = tokensList.flatMap((group) =>\n 'label' in group ? [null] : group.tokens,\n );\n\n return flatList[totalIndex];\n};\n"],"names":["getTokenByTotalIndex","tokensList","totalIndex","group"],"mappings":"AASO,MAAMA,IAAuB,CAClCC,GACAC,MAEiBD,EAAW;AAAA,EAAQ,CAACE,MACnC,WAAWA,IAAQ,CAAC,IAAI,IAAIA,EAAM;AAAA,EAGpBD,CAAU;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getGroupHeadersTotalIndexes } from './getGroupHeadersTotalIndexes';
|
|
2
|
+
export { getFirstGroupItemTotalIndex } from './getFirstGroupItemTotalIndex';
|
|
3
|
+
export { getListItemsTotalCount } from './getListItemsTotalCount';
|
|
4
|
+
export { getTokenByTotalIndex } from './getTokenByTotalIndex';
|
|
5
|
+
export { getListTotalHeight } from './getListTotalHeight';
|
|
6
|
+
export { getListState } from './getListState';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getGroupHeadersTotalIndexes as o } from "./getGroupHeadersTotalIndexes.js";
|
|
2
|
+
import { getFirstGroupItemTotalIndex as x } from "./getFirstGroupItemTotalIndex.js";
|
|
3
|
+
import { getListItemsTotalCount as p } from "./getListItemsTotalCount.js";
|
|
4
|
+
import { getTokenByTotalIndex as g } from "./getTokenByTotalIndex.js";
|
|
5
|
+
import { getListTotalHeight as f } from "./getListTotalHeight.js";
|
|
6
|
+
import { getListState as i } from "./getListState.js";
|
|
7
|
+
export {
|
|
8
|
+
x as getFirstGroupItemTotalIndex,
|
|
9
|
+
o as getGroupHeadersTotalIndexes,
|
|
10
|
+
p as getListItemsTotalCount,
|
|
11
|
+
i as getListState,
|
|
12
|
+
f as getListTotalHeight,
|
|
13
|
+
g as getTokenByTotalIndex
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|