@lifi/widget 4.0.0 → 4.2.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/App.d.ts +4 -2
- package/dist/esm/App.d.ts.map +1 -1
- package/dist/esm/App.js +4 -4
- package/dist/esm/App.js.map +1 -1
- package/dist/esm/AppDefault.js +14 -0
- package/dist/esm/AppDefault.js.map +1 -1
- package/dist/esm/AppDrawer.d.ts +1 -1
- package/dist/esm/AppDrawer.d.ts.map +1 -1
- package/dist/esm/AppDrawer.js +5 -6
- package/dist/esm/AppDrawer.js.map +1 -1
- package/dist/esm/AppDrawerContext.js +2 -2
- package/dist/esm/AppDrawerContext.js.map +1 -1
- package/dist/esm/components/ActionRow/ActionRow.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.js +2 -1
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +4 -2
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +4 -2
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -1
- package/dist/esm/components/AmountInputCard/AmountInputCard.style.js +98 -0
- package/dist/esm/components/AmountInputCard/AmountInputCard.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js +25 -0
- package/dist/esm/components/AmountInputCard/AmountInputCardPair.js.map +1 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.js +35 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.js.map +1 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js +11 -0
- package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/FiatValueToggle.js +41 -0
- package/dist/esm/components/AmountInputCard/FiatValueToggle.js.map +1 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.js +80 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.js.map +1 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.style.js +43 -0
- package/dist/esm/components/AmountInputCard/PercentageChips.style.js.map +1 -0
- package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js +137 -0
- package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js.map +1 -0
- package/dist/esm/components/AmountInputCard/SendAmountCard.js +102 -0
- package/dist/esm/components/AmountInputCard/SendAmountCard.js.map +1 -0
- package/dist/esm/components/AppContainer.js.map +1 -1
- package/dist/esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +12 -3
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.style.js.map +1 -1
- package/dist/esm/components/Avatar/SmallAvatar.js.map +1 -1
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +1 -0
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/dist/esm/components/BottomSheet/BottomSheet.js +3 -3
- package/dist/esm/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/esm/components/ButtonTertiary.js.map +1 -1
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/CardButton.style.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.js.map +1 -1
- package/dist/esm/components/Card/CardIconButton.js.map +1 -1
- package/dist/esm/components/Card/CardLabel.js.map +1 -1
- package/dist/esm/components/Card/CardTitle.js.map +1 -1
- package/dist/esm/components/Card/InputCard.js.map +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.js.map +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.style.js.map +1 -1
- package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/dist/esm/components/Chains/AllChainsAvatar.js.map +1 -1
- package/dist/esm/components/Chains/ChainList.js.map +1 -1
- package/dist/esm/components/Chains/ChainList.style.js.map +1 -1
- package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +2 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/ContextMenu.style.js.map +1 -1
- package/dist/esm/components/ContractComponent/NFT/NFT.style.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.style.js.map +1 -1
- package/dist/esm/components/EmptyListIndicator/EmptyListIndicator.style.js.map +1 -1
- package/dist/esm/components/ExecutionStatusCard/StatusIcon.js.map +1 -1
- package/dist/esm/components/ExecutionStatusCard/StatusIcon.style.js.map +1 -1
- package/dist/esm/components/ExecutionStatusCard/iconKey.js.map +1 -1
- package/dist/esm/components/Expansion/Expansion.style.js.map +1 -1
- package/dist/esm/components/Header/ActivitiesButton.style.js.map +1 -1
- package/dist/esm/components/Header/CloseDrawerButton.js +1 -0
- package/dist/esm/components/Header/CloseDrawerButton.js.map +1 -1
- package/dist/esm/components/Header/Header.js +7 -10
- package/dist/esm/components/Header/Header.js.map +1 -1
- package/dist/esm/components/Header/Header.style.js.map +1 -1
- package/dist/esm/components/Header/HeaderNavigationTabs.js +39 -0
- package/dist/esm/components/Header/HeaderNavigationTabs.js.map +1 -0
- package/dist/esm/components/Header/HeaderTabs.js +33 -0
- package/dist/esm/components/Header/HeaderTabs.js.map +1 -0
- package/dist/esm/components/Header/NavigationHeader.js +7 -5
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Header/SettingsButton.style.js.map +1 -1
- package/dist/esm/components/Header/WalletMenu.style.js.map +1 -1
- package/dist/esm/components/IconCircle/IconCircle.style.js +1 -1
- package/dist/esm/components/IconCircle/IconCircle.style.js.map +1 -1
- package/dist/esm/components/IconTypography.js.map +1 -1
- package/dist/esm/components/Input.js.map +1 -1
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js +99 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js.map +1 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js +52 -0
- package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.js +115 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js +89 -0
- package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js.map +1 -0
- package/dist/esm/components/LimitPriceCard/LimitPricePresets.js +91 -0
- package/dist/esm/components/LimitPriceCard/LimitPricePresets.js.map +1 -0
- package/dist/esm/components/ListItem/ListItem.js.map +1 -1
- package/dist/esm/components/ListItem/ListItemButton.js.map +1 -1
- package/dist/esm/components/ListItemButton.js.map +1 -1
- package/dist/esm/components/ListItemText.js.map +1 -1
- package/dist/esm/components/Menu.js.map +1 -1
- package/dist/esm/components/Messages/AlertMessage.style.js.map +1 -1
- package/dist/esm/components/Messages/GasRefuelMessage.style.js.map +1 -1
- package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
- package/dist/esm/components/PageContainer.js.map +1 -1
- package/dist/esm/components/PoweredBy/PoweredBy.js.map +1 -1
- package/dist/esm/components/PoweredBy/PoweredBy.style.js.map +1 -1
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js +1 -0
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js.map +1 -1
- package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.style.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteDetails.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteDetails.style.js +2 -2
- package/dist/esm/components/RouteCard/RouteDetails.style.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteProviderCard.js +118 -0
- package/dist/esm/components/RouteCard/RouteProviderCard.js.map +1 -0
- package/dist/esm/components/RouteCard/RouteToken.style.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteTokens.js.map +1 -1
- package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -1
- package/dist/esm/components/Routes/LimitOrderRoutes.js +34 -0
- package/dist/esm/components/Routes/LimitOrderRoutes.js.map +1 -0
- package/dist/esm/components/Routes/Routes.js +2 -2
- package/dist/esm/components/Routes/Routes.js.map +1 -1
- package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
- package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
- package/dist/esm/components/Search/SearchInput.style.js.map +1 -1
- package/dist/esm/components/Search/SearchNotFound.style.js.map +1 -1
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.style.js.map +1 -1
- package/dist/esm/components/SettingsListItemButton.js.map +1 -1
- package/dist/esm/components/SettingsPanel/SettingsPanel.js +51 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.js.map +1 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.style.js +33 -0
- package/dist/esm/components/SettingsPanel/SettingsPanel.style.js.map +1 -0
- package/dist/esm/components/SettingsPanel/utils.js +14 -0
- package/dist/esm/components/SettingsPanel/utils.js.map +1 -0
- package/dist/esm/components/Skeleton/WidgetSkeleton.js +50 -47
- package/dist/esm/components/Skeleton/WidgetSkeleton.js.map +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.style.js.map +1 -1
- package/dist/esm/components/Step/StepActions.js.map +1 -1
- package/dist/esm/components/Step/StepActions.style.js.map +1 -1
- package/dist/esm/components/StepActions/SentToWalletRow.style.js.map +1 -1
- package/dist/esm/components/StepActions/StepActionRow.style.js.map +1 -1
- package/dist/esm/components/SwapButton/SwapButton.js +50 -0
- package/dist/esm/components/SwapButton/SwapButton.js.map +1 -0
- package/dist/esm/components/SwapButton/SwapButton.style.js +24 -0
- package/dist/esm/components/SwapButton/SwapButton.style.js.map +1 -0
- package/dist/esm/components/Switch.js.map +1 -1
- package/dist/esm/components/Tabs/NavigationTabs.js +3 -0
- package/dist/esm/components/Tabs/NavigationTabs.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.style.js.map +1 -1
- package/dist/esm/components/Timer/StepStatusTimer.style.js.map +1 -1
- package/dist/esm/components/Token/Token.style.js.map +1 -1
- package/dist/esm/components/TokenList/PinTokenButton.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheet.js +4 -4
- package/dist/esm/components/TokenList/TokenDetailsSheet.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +4 -4
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.style.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.style.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.js +2 -2
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/dist/esm/components/TokenList/useTokenSelect.js +3 -3
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/components/TokenPillButton/TokenPillButton.js +52 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.js.map +1 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.style.js +39 -0
- package/dist/esm/components/TokenPillButton/TokenPillButton.style.js.map +1 -0
- package/dist/esm/components/TokenRate/TokenRate.style.js.map +1 -1
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.js.map +1 -1
- package/dist/esm/components/TransactionCard/ActiveTransactionCard.style.js.map +1 -1
- package/dist/esm/components/TransactionCard/TransactionCard.style.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/timer/validate.js.map +1 -1
- package/dist/esm/hooks/useAccountsBalancesData.js.map +1 -1
- package/dist/esm/hooks/useAvailableChains.js +1 -1
- package/dist/esm/hooks/useChainSearch.js +2 -1
- package/dist/esm/hooks/useChainSearch.js.map +1 -1
- package/dist/esm/hooks/useChains.js +1 -1
- package/dist/esm/hooks/useExplorer.js.map +1 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js +1 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
- package/dist/esm/hooks/useLanguages.js +2 -2
- package/dist/esm/hooks/useLanguages.js.map +1 -1
- package/dist/esm/hooks/useLimitMarketRate.js +24 -0
- package/dist/esm/hooks/useLimitMarketRate.js.map +1 -0
- package/dist/esm/hooks/useLinkedLimitFields.js +49 -0
- package/dist/esm/hooks/useLinkedLimitFields.js.map +1 -0
- package/dist/esm/hooks/useRouteExecution.js.map +1 -1
- package/dist/esm/hooks/useRouteExecutionMessage.js.map +1 -1
- package/dist/esm/hooks/useRouteRequiredAccountConnection.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +23 -6
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useSwapOnly.js +2 -4
- package/dist/esm/hooks/useSwapOnly.js.map +1 -1
- package/dist/esm/hooks/useToAddressRequirements.js +2 -2
- package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
- package/dist/esm/hooks/useToken.js.map +1 -1
- package/dist/esm/hooks/useTokenBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -1
- package/dist/esm/hooks/useTokenSearch.js +1 -1
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.js +17 -15
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/hooks/useTools.js +1 -1
- package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
- package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
- package/dist/esm/hooks/useTransactionList.js.map +1 -1
- package/dist/esm/hooks/useWideVariant.js +5 -2
- package/dist/esm/hooks/useWideVariant.js.map +1 -1
- package/dist/esm/i18n/en.json +25 -0
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/pages/ActivitiesPage/ActivitiesPage.js.map +1 -1
- package/dist/esm/pages/MainPage/LimitPageContent.js +23 -0
- package/dist/esm/pages/MainPage/LimitPageContent.js.map +1 -0
- package/dist/esm/pages/MainPage/MainPage.js +19 -22
- package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
- package/dist/esm/pages/MainPage/MainPageActions.js +28 -0
- package/dist/esm/pages/MainPage/MainPageActions.js.map +1 -0
- package/dist/esm/pages/MainPage/ReviewButton.js +11 -4
- package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
- package/dist/esm/pages/RoutePriorityPage.js +48 -0
- package/dist/esm/pages/RoutePriorityPage.js.map +1 -0
- package/dist/esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/dist/esm/pages/RoutesPage/RoutesPage.style.js.map +1 -1
- package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +3 -3
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js +3 -3
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.style.js.map +1 -1
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +2 -2
- package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/GasPriceSettings.js +1 -1
- package/dist/esm/pages/SettingsPage/ResetSettingsButton.style.js.map +1 -1
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js +12 -27
- package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js +3 -3
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js +3 -3
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js +133 -0
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js.map +1 -0
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js +14 -72
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +26 -14
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js.map +1 -1
- package/dist/esm/pages/SettingsPage/ThemeSettings.js +4 -0
- package/dist/esm/pages/SettingsPage/ThemeSettings.js.map +1 -1
- package/dist/esm/pages/TransactionDetailsPage/ContactSupportButton.style.js.map +1 -1
- package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
- package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsSkeleton.js.map +1 -1
- package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.js +3 -3
- package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js +16 -15
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.style.js.map +1 -1
- package/dist/esm/pages/TransactionPage/RouteTracker.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js +3 -3
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.style.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js +27 -31
- package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TransactionReview.js +4 -1
- package/dist/esm/pages/TransactionPage/TransactionReview.js.map +1 -1
- package/dist/esm/pages/TransactionPage/utils.js.map +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
- package/dist/esm/providers/I18nProvider/enResource.d.ts +1 -1
- package/dist/esm/providers/I18nProvider/enResource.js +1 -1
- package/dist/esm/providers/I18nProvider/i18n.js.map +1 -1
- package/dist/esm/providers/I18nProvider/types.d.ts +2 -2
- package/dist/esm/providers/QueryClientProvider.js +2 -2
- package/dist/esm/providers/QueryClientProvider.js.map +1 -1
- package/dist/esm/providers/SDKClientProvider.js +3 -3
- package/dist/esm/providers/SDKClientProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +4 -5
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/dist/esm/stores/StoreProvider.js +3 -4
- package/dist/esm/stores/StoreProvider.js.map +1 -1
- package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
- package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
- package/dist/esm/stores/bookmarks/createBookmarkStore.js.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.js +4 -4
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
- package/dist/esm/stores/form/FormStore.js +1 -1
- package/dist/esm/stores/form/FormStore.js.map +1 -1
- package/dist/esm/stores/form/URLSearchParamsBuilder.js +14 -3
- package/dist/esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
- package/dist/esm/stores/form/createFormStore.js +6 -2
- package/dist/esm/stores/form/createFormStore.js.map +1 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js +3 -0
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.js.map +1 -1
- package/dist/esm/stores/form/types.d.ts +9 -1
- package/dist/esm/stores/form/types.d.ts.map +1 -1
- package/dist/esm/stores/form/types.js.map +1 -1
- package/dist/esm/stores/form/useClearAmountFields.js +1 -0
- package/dist/esm/stores/form/useClearAmountFields.js.map +1 -1
- package/dist/esm/stores/form/useFieldActions.js.map +1 -1
- package/dist/esm/stores/form/useFieldValues.js.map +1 -1
- package/dist/esm/stores/form/useFormRef.js.map +1 -1
- package/dist/esm/stores/form/useFormStore.js +2 -2
- package/dist/esm/stores/form/useFormStore.js.map +1 -1
- package/dist/esm/stores/header/useHeaderStore.js +3 -3
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -1
- package/dist/esm/stores/navigationTabs/useNavigationTabLabel.js +22 -0
- package/dist/esm/stores/navigationTabs/useNavigationTabLabel.js.map +1 -0
- package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js +64 -0
- package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js.map +1 -0
- package/dist/esm/stores/navigationTabs/utils.js +122 -0
- package/dist/esm/stores/navigationTabs/utils.js.map +1 -0
- package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js +3 -3
- package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js.map +1 -1
- package/dist/esm/stores/pinnedTokens/createPinnedTokensStore.js.map +1 -1
- package/dist/esm/stores/routes/RouteExecutionStore.js +3 -3
- package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/routes/useIntermediateRoutesStore.js.map +1 -1
- package/dist/esm/stores/routes/useRouteExecutionIndicator.js.map +1 -1
- package/dist/esm/stores/routes/utils.js.map +1 -1
- package/dist/esm/stores/settings/SettingsStore.js +3 -3
- package/dist/esm/stores/settings/SettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/createSettingsStore.js +122 -96
- package/dist/esm/stores/settings/createSettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/types.d.ts +0 -2
- package/dist/esm/stores/settings/types.d.ts.map +1 -1
- package/dist/esm/stores/settings/types.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/themes/utils.js.map +1 -1
- package/dist/esm/types/events.d.ts +10 -1
- package/dist/esm/types/events.d.ts.map +1 -1
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/events.js.map +1 -1
- package/dist/esm/types/widget.d.ts +28 -2
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/esm/utils/compactNumberFormatter.js.map +1 -1
- package/dist/esm/utils/converters.js.map +1 -1
- package/dist/esm/utils/deepEqual.js.map +1 -1
- package/dist/esm/utils/fees.js.map +1 -1
- package/dist/esm/utils/format.d.ts +1 -1
- package/dist/esm/utils/format.d.ts.map +1 -1
- package/dist/esm/utils/format.js +2 -2
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/getActionMessage.js.map +1 -1
- package/dist/esm/utils/getErrorMessage.js.map +1 -1
- package/dist/esm/utils/item.js.map +1 -1
- package/dist/esm/utils/limitOrder.js +61 -0
- package/dist/esm/utils/limitOrder.js.map +1 -0
- package/dist/esm/utils/{variant.js → mode.js} +2 -2
- package/dist/esm/utils/mode.js.map +1 -0
- package/dist/esm/utils/navigationRoutes.d.ts +2 -0
- package/dist/esm/utils/navigationRoutes.d.ts.map +1 -1
- package/dist/esm/utils/navigationRoutes.js +6 -0
- package/dist/esm/utils/navigationRoutes.js.map +1 -1
- package/dist/esm/utils/prepareActions.js +1 -1
- package/dist/esm/utils/prepareActions.js.map +1 -1
- package/dist/esm/utils/timer.js.map +1 -1
- package/dist/esm/utils/token.js +1 -1
- package/dist/esm/utils/token.js.map +1 -1
- package/dist/esm/utils/tokenList.js.map +1 -1
- package/package.json +13 -13
- package/src/App.tsx +7 -7
- package/src/AppDefault.tsx +16 -0
- package/src/AppDrawer.tsx +77 -78
- package/src/AppDrawerContext.ts +2 -2
- package/src/components/AmountInput/AmountInputEndAdornment.style.ts +1 -1
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +5 -2
- package/src/components/AmountInputCard/AmountInputCard.style.tsx +157 -0
- package/src/components/AmountInputCard/AmountInputCardPair.tsx +25 -0
- package/src/components/AmountInputCard/BalanceDisplay.style.tsx +9 -0
- package/src/components/AmountInputCard/BalanceDisplay.tsx +46 -0
- package/src/components/AmountInputCard/FiatValueToggle.tsx +55 -0
- package/src/components/AmountInputCard/PercentageChips.style.tsx +60 -0
- package/src/components/AmountInputCard/PercentageChips.tsx +100 -0
- package/src/components/AmountInputCard/ReceiveAmountCard.tsx +219 -0
- package/src/components/AmountInputCard/SendAmountCard.tsx +179 -0
- package/src/components/Avatar/Avatar.tsx +8 -3
- package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +1 -0
- package/src/components/BottomSheet/BottomSheet.tsx +56 -52
- package/src/components/Header/CloseDrawerButton.tsx +5 -1
- package/src/components/Header/Header.tsx +20 -18
- package/src/components/Header/HeaderNavigationTabs.tsx +42 -0
- package/src/components/Header/HeaderTabs.tsx +48 -0
- package/src/components/Header/NavigationHeader.tsx +11 -8
- package/src/components/LimitOrderSettings/LimitOrderSettings.style.tsx +69 -0
- package/src/components/LimitOrderSettings/LimitOrderSettings.tsx +124 -0
- package/src/components/LimitPriceCard/LimitPriceCard.style.tsx +103 -0
- package/src/components/LimitPriceCard/LimitPriceCard.tsx +153 -0
- package/src/components/LimitPriceCard/LimitPricePresets.tsx +139 -0
- package/src/components/ReverseTokensButton/ReverseTokensButton.tsx +4 -1
- package/src/components/RouteCard/RouteProviderCard.tsx +113 -0
- package/src/components/Routes/LimitOrderRoutes.tsx +64 -0
- package/src/components/Routes/Routes.tsx +3 -2
- package/src/components/SettingsPanel/SettingsPanel.style.tsx +41 -0
- package/src/components/SettingsPanel/SettingsPanel.tsx +73 -0
- package/src/components/SettingsPanel/utils.ts +27 -0
- package/src/components/Skeleton/WidgetSkeleton.tsx +1 -1
- package/src/components/SwapButton/SwapButton.style.tsx +28 -0
- package/src/components/SwapButton/SwapButton.tsx +71 -0
- package/src/components/Tabs/NavigationTabs.tsx +3 -0
- package/src/components/TokenList/TokenDetailsSheet.tsx +9 -7
- package/src/components/TokenList/TokenDetailsSheetContent.tsx +176 -177
- package/src/components/TokenList/useTokenSelect.ts +2 -2
- package/src/components/TokenPillButton/TokenPillButton.style.tsx +50 -0
- package/src/components/TokenPillButton/TokenPillButton.tsx +81 -0
- package/src/config/version.ts +1 -1
- package/src/hooks/useLimitMarketRate.ts +39 -0
- package/src/hooks/useLinkedLimitFields.ts +74 -0
- package/src/hooks/useRoutes.ts +45 -4
- package/src/hooks/useSwapOnly.ts +2 -5
- package/src/hooks/useToAddressRequirements.ts +2 -2
- package/src/hooks/useWideVariant.ts +8 -2
- package/src/pages/MainPage/LimitPageContent.tsx +18 -0
- package/src/pages/MainPage/MainPage.tsx +43 -30
- package/src/pages/MainPage/MainPageActions.tsx +35 -0
- package/src/pages/MainPage/ReviewButton.tsx +15 -3
- package/src/pages/RoutePriorityPage.tsx +55 -0
- package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +176 -185
- package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +9 -6
- package/src/pages/SettingsPage/RoutePrioritySettings.tsx +14 -38
- package/src/pages/SettingsPage/SettingsCard/SettingCardExpandable.tsx +58 -65
- package/src/pages/SettingsPage/SettingsCard/SettingsAccordian.tsx +4 -4
- package/src/pages/SettingsPage/SlippageSettings/SlippagePage.tsx +176 -0
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.style.tsx +32 -25
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx +14 -128
- package/src/pages/SettingsPage/ThemeSettings.tsx +4 -0
- package/src/pages/TransactionPage/ConfirmToAddressSheet.tsx +9 -6
- package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +53 -58
- package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +24 -21
- package/src/pages/TransactionPage/TransactionExecutionContent.tsx +8 -6
- package/src/providers/QueryClientProvider.tsx +2 -2
- package/src/providers/SDKClientProvider.tsx +3 -7
- package/src/providers/WidgetProvider/WidgetProvider.tsx +6 -7
- package/src/stores/StoreProvider.tsx +3 -10
- package/src/stores/bookmarks/BookmarkStore.tsx +4 -4
- package/src/stores/chains/ChainOrderStore.tsx +4 -4
- package/src/stores/form/FormStore.tsx +2 -2
- package/src/stores/form/URLSearchParamsBuilder.tsx +25 -3
- package/src/stores/form/createFormStore.ts +7 -3
- package/src/stores/form/getDefaultValuesFromQueryString.ts +11 -0
- package/src/stores/form/types.ts +14 -1
- package/src/stores/form/useClearAmountFields.ts +1 -0
- package/src/stores/form/useFormStore.ts +2 -2
- package/src/stores/header/useHeaderStore.tsx +3 -5
- package/src/stores/navigationTabs/types.ts +33 -0
- package/src/stores/navigationTabs/useNavigationTabLabel.ts +28 -0
- package/src/stores/navigationTabs/useNavigationTabsStore.tsx +113 -0
- package/src/stores/navigationTabs/utils.ts +196 -0
- package/src/stores/pinnedTokens/PinnedTokensStore.tsx +4 -4
- package/src/stores/routes/RouteExecutionStore.tsx +4 -4
- package/src/stores/settings/SettingsStore.tsx +4 -4
- package/src/stores/settings/createSettingsStore.ts +48 -12
- package/src/stores/settings/types.ts +1 -16
- package/src/types/events.ts +12 -0
- package/src/types/widget.ts +40 -1
- package/src/utils/format.ts +6 -2
- package/src/utils/limitOrder.ts +88 -0
- package/src/utils/navigationRoutes.ts +6 -0
- package/dist/esm/components/Header/SplitNavigationTabs.js +0 -33
- package/dist/esm/components/Header/SplitNavigationTabs.js.map +0 -1
- package/dist/esm/stores/settings/useSplitModeStore.js +0 -36
- package/dist/esm/stores/settings/useSplitModeStore.js.map +0 -1
- package/dist/esm/utils/variant.js.map +0 -1
- package/src/components/Header/SplitNavigationTabs.tsx +0 -32
- package/src/stores/settings/useSplitModeStore.tsx +0 -58
- /package/src/utils/{variant.ts → mode.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk'
|
|
2
2
|
import { Button, Checkbox, FormControlLabel } from '@mui/material'
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
3
|
+
import type { JSX, Ref, RefObject } from 'react'
|
|
4
|
+
import { useRef, useState } from 'react'
|
|
5
5
|
import { useTranslation } from 'react-i18next'
|
|
6
6
|
import { BottomSheet } from '../../components/BottomSheet/BottomSheet.js'
|
|
7
7
|
import type { BottomSheetBase } from '../../components/BottomSheet/types.js'
|
|
@@ -27,26 +27,29 @@ interface TokenValueBottomSheetProps {
|
|
|
27
27
|
onCancel?(): void
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const TokenValueBottomSheet
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<TokenValueBottomSheetContent
|
|
42
|
-
route={route}
|
|
43
|
-
onContinue={onContinue}
|
|
44
|
-
onCancel={handleCancel}
|
|
45
|
-
/>
|
|
46
|
-
</BottomSheet>
|
|
47
|
-
)
|
|
30
|
+
export const TokenValueBottomSheet = ({
|
|
31
|
+
route,
|
|
32
|
+
onContinue,
|
|
33
|
+
onCancel,
|
|
34
|
+
ref,
|
|
35
|
+
}: TokenValueBottomSheetProps & {
|
|
36
|
+
ref?: Ref<BottomSheetBase>
|
|
37
|
+
}): JSX.Element => {
|
|
38
|
+
const handleCancel = () => {
|
|
39
|
+
;(ref as RefObject<BottomSheetBase>).current?.close()
|
|
40
|
+
onCancel?.()
|
|
48
41
|
}
|
|
49
|
-
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<BottomSheet ref={ref} onClose={onCancel}>
|
|
45
|
+
<TokenValueBottomSheetContent
|
|
46
|
+
route={route}
|
|
47
|
+
onContinue={onContinue}
|
|
48
|
+
onCancel={handleCancel}
|
|
49
|
+
/>
|
|
50
|
+
</BottomSheet>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
50
53
|
|
|
51
54
|
const TokenValueBottomSheetContent: React.FC<TokenValueBottomSheetProps> = ({
|
|
52
55
|
route,
|
|
@@ -76,13 +76,15 @@ export const TransactionExecutionContent: React.FC<
|
|
|
76
76
|
iconSlot={iconSlot}
|
|
77
77
|
footerSlot={footerSlot}
|
|
78
78
|
/>
|
|
79
|
-
<WarningMessages route={route} allowInteraction />
|
|
80
79
|
{status === RouteExecutionStatus.Failed ? (
|
|
81
|
-
|
|
82
|
-
route={route}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
<>
|
|
81
|
+
<WarningMessages route={route} allowInteraction />
|
|
82
|
+
<TransactionFailedButtons
|
|
83
|
+
route={route}
|
|
84
|
+
restartRoute={restartRoute}
|
|
85
|
+
deleteRoute={deleteRoute}
|
|
86
|
+
/>
|
|
87
|
+
</>
|
|
86
88
|
) : isDone ? (
|
|
87
89
|
<TransactionDoneButtons route={route} status={status} />
|
|
88
90
|
) : null}
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
QueryClientProvider as TanstackQueryClientProvider,
|
|
4
4
|
} from '@tanstack/react-query'
|
|
5
5
|
import type { PropsWithChildren } from 'react'
|
|
6
|
-
import {
|
|
6
|
+
import { use } from 'react'
|
|
7
7
|
import { queryClient } from '../config/queryClient.js'
|
|
8
8
|
|
|
9
9
|
export const QueryClientProvider: React.FC<PropsWithChildren> = ({
|
|
10
10
|
children,
|
|
11
11
|
}) => {
|
|
12
|
-
const existingQueryClient =
|
|
12
|
+
const existingQueryClient = use(TanstackQueryClientContext)
|
|
13
13
|
return existingQueryClient ? (
|
|
14
14
|
children
|
|
15
15
|
) : (
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createContext,
|
|
4
4
|
type JSX,
|
|
5
5
|
type PropsWithChildren,
|
|
6
|
-
|
|
6
|
+
use,
|
|
7
7
|
useMemo,
|
|
8
8
|
} from 'react'
|
|
9
9
|
import { version } from '../config/version.js'
|
|
@@ -11,7 +11,7 @@ import { useWidgetConfig } from './WidgetProvider/WidgetProvider.js'
|
|
|
11
11
|
|
|
12
12
|
const SDKClientContext = createContext<SDKClient>({} as SDKClient)
|
|
13
13
|
|
|
14
|
-
export const useSDKClient = (): SDKClient =>
|
|
14
|
+
export const useSDKClient = (): SDKClient => use(SDKClientContext)
|
|
15
15
|
|
|
16
16
|
export const SDKClientProvider = ({
|
|
17
17
|
children,
|
|
@@ -51,9 +51,5 @@ export const SDKClientProvider = ({
|
|
|
51
51
|
slippage,
|
|
52
52
|
])
|
|
53
53
|
|
|
54
|
-
return
|
|
55
|
-
<SDKClientContext.Provider value={client}>
|
|
56
|
-
{children}
|
|
57
|
-
</SDKClientContext.Provider>
|
|
58
|
-
)
|
|
54
|
+
return <SDKClientContext value={client}>{children}</SDKClientContext>
|
|
59
55
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Context } from 'react'
|
|
2
|
+
import { createContext, use, useId, useMemo } from 'react'
|
|
2
3
|
import { useSettingsActions } from '../../stores/settings/useSettingsActions.js'
|
|
3
4
|
import type { WidgetContextProps, WidgetProviderProps } from './types.js'
|
|
4
5
|
|
|
@@ -7,10 +8,10 @@ const initialContext: WidgetContextProps = {
|
|
|
7
8
|
integrator: '',
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const WidgetContext
|
|
11
|
+
export const WidgetContext: Context<WidgetContextProps> =
|
|
12
|
+
createContext<WidgetContextProps>(initialContext)
|
|
11
13
|
|
|
12
|
-
export const useWidgetConfig = (): WidgetContextProps =>
|
|
13
|
-
useContext(WidgetContext)
|
|
14
|
+
export const useWidgetConfig = (): WidgetContextProps => use(WidgetContext)
|
|
14
15
|
|
|
15
16
|
export const WidgetProvider: React.FC<
|
|
16
17
|
React.PropsWithChildren<WidgetProviderProps>
|
|
@@ -43,7 +44,5 @@ export const WidgetProvider: React.FC<
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}, [elementId, widgetConfig, setDefaultSettings])
|
|
46
|
-
return
|
|
47
|
-
<WidgetContext.Provider value={value}>{children}</WidgetContext.Provider>
|
|
48
|
-
)
|
|
47
|
+
return <WidgetContext value={value}>{children}</WidgetContext>
|
|
49
48
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react'
|
|
2
2
|
import type { WidgetConfigProps } from '../types/widget.js'
|
|
3
|
-
import { getSplitMode } from '../utils/variant.js'
|
|
4
3
|
import { BookmarkStoreProvider } from './bookmarks/BookmarkStore.js'
|
|
5
4
|
import { ChainOrderStoreProvider } from './chains/ChainOrderStore.js'
|
|
6
5
|
import { FormStoreProvider } from './form/FormStore.js'
|
|
7
6
|
import { HeaderStoreProvider } from './header/useHeaderStore.js'
|
|
7
|
+
import { NavigationTabsStoreProvider } from './navigationTabs/useNavigationTabsStore.js'
|
|
8
8
|
import { PinnedTokensStoreProvider } from './pinnedTokens/PinnedTokensStore.js'
|
|
9
9
|
import { RouteExecutionStoreProvider } from './routes/RouteExecutionStore.js'
|
|
10
|
-
import { SplitModeStoreProvider } from './settings/useSplitModeStore.js'
|
|
11
10
|
|
|
12
11
|
export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
|
|
13
12
|
children,
|
|
@@ -15,13 +14,7 @@ export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
|
|
|
15
14
|
formRef,
|
|
16
15
|
}) => {
|
|
17
16
|
return (
|
|
18
|
-
<
|
|
19
|
-
state={
|
|
20
|
-
config.mode === 'split'
|
|
21
|
-
? getSplitMode(config.modeOptions?.split)
|
|
22
|
-
: undefined
|
|
23
|
-
}
|
|
24
|
-
>
|
|
17
|
+
<NavigationTabsStoreProvider config={config}>
|
|
25
18
|
<HeaderStoreProvider namePrefix={config?.keyPrefix}>
|
|
26
19
|
<BookmarkStoreProvider namePrefix={config?.keyPrefix}>
|
|
27
20
|
<PinnedTokensStoreProvider namePrefix={config?.keyPrefix}>
|
|
@@ -35,6 +28,6 @@ export const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>> = ({
|
|
|
35
28
|
</PinnedTokensStoreProvider>
|
|
36
29
|
</BookmarkStoreProvider>
|
|
37
30
|
</HeaderStoreProvider>
|
|
38
|
-
</
|
|
31
|
+
</NavigationTabsStoreProvider>
|
|
39
32
|
)
|
|
40
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, use, useRef } from 'react'
|
|
2
2
|
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
4
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
@@ -19,14 +19,14 @@ export const BookmarkStoreProvider: React.FC<PersistStoreProviderProps> = ({
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
|
-
<BookmarkStoreContext
|
|
22
|
+
<BookmarkStoreContext value={storeRef.current}>
|
|
23
23
|
{children}
|
|
24
|
-
</BookmarkStoreContext
|
|
24
|
+
</BookmarkStoreContext>
|
|
25
25
|
)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function useBookmarkStore<T>(selector: (store: BookmarkState) => T): T {
|
|
29
|
-
const useStore =
|
|
29
|
+
const useStore = use(BookmarkStoreContext)
|
|
30
30
|
|
|
31
31
|
if (!useStore) {
|
|
32
32
|
throw new Error(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, type JSX,
|
|
1
|
+
import { createContext, type JSX, use, useEffect, useRef } from 'react'
|
|
2
2
|
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
3
3
|
import { useShallow } from 'zustand/shallow'
|
|
4
4
|
import { useChains } from '../../hooks/useChains.js'
|
|
@@ -141,14 +141,14 @@ export function ChainOrderStoreProvider({
|
|
|
141
141
|
])
|
|
142
142
|
|
|
143
143
|
return (
|
|
144
|
-
<ChainOrderStoreContext
|
|
144
|
+
<ChainOrderStoreContext value={storeRef.current}>
|
|
145
145
|
{children}
|
|
146
|
-
</ChainOrderStoreContext
|
|
146
|
+
</ChainOrderStoreContext>
|
|
147
147
|
)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function useChainOrderStoreContext() {
|
|
151
|
-
const useStore =
|
|
151
|
+
const useStore = use(ChainOrderStoreContext)
|
|
152
152
|
if (!useStore) {
|
|
153
153
|
throw new Error(
|
|
154
154
|
`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`
|
|
@@ -125,9 +125,9 @@ export const FormStoreProvider: React.FC<FormStoreProviderProps> = ({
|
|
|
125
125
|
useFormRef(storeRef.current, formRef)
|
|
126
126
|
|
|
127
127
|
return (
|
|
128
|
-
<FormStoreContext
|
|
128
|
+
<FormStoreContext value={storeRef.current}>
|
|
129
129
|
{children}
|
|
130
130
|
<FormUpdater reactiveFormValues={reactiveFormValues} />
|
|
131
|
-
</FormStoreContext
|
|
131
|
+
</FormStoreContext>
|
|
132
132
|
)
|
|
133
133
|
}
|
|
@@ -18,13 +18,23 @@ const formValueKeys: FormFieldNames[] = [
|
|
|
18
18
|
'toToken',
|
|
19
19
|
]
|
|
20
20
|
|
|
21
|
+
// Limit-order params are only mirrored to the URL while the limit tab is
|
|
22
|
+
// active, and stripped when the user leaves it. Unlike the base keys these are
|
|
23
|
+
// presence-gated (not touched-gated) so the URL fully reproduces the limit
|
|
24
|
+
// order — including the boolean/number fields, which are never "falsy-empty".
|
|
25
|
+
const limitFormValueKeys: FormFieldNames[] = [
|
|
26
|
+
'toAmount',
|
|
27
|
+
'validUntil',
|
|
28
|
+
'partiallyFillable',
|
|
29
|
+
]
|
|
30
|
+
|
|
21
31
|
export const URLSearchParamsBuilder = () => {
|
|
22
32
|
const { pathname } = useLocation()
|
|
23
33
|
const touchedFields = useTouchedFields()
|
|
24
|
-
const values = useFieldValues(...formValueKeys)
|
|
34
|
+
const values = useFieldValues(...formValueKeys, ...limitFormValueKeys)
|
|
25
35
|
const { setSelectedBookmark, addRecentWallet } = useBookmarkActions()
|
|
26
36
|
const { validateAddress } = useAddressValidation()
|
|
27
|
-
const { buildUrl } = useWidgetConfig()
|
|
37
|
+
const { buildUrl, mode } = useWidgetConfig()
|
|
28
38
|
// Using these methods as trying to use the touchedFields and values above
|
|
29
39
|
// often has a lag that can effect the widgets initialisation sequence
|
|
30
40
|
// and accidentally cause values to be wiped from the query string
|
|
@@ -85,9 +95,21 @@ export const URLSearchParamsBuilder = () => {
|
|
|
85
95
|
url.searchParams.delete(key)
|
|
86
96
|
}
|
|
87
97
|
})
|
|
98
|
+
// Limit params live in the URL only while the limit tab is active.
|
|
99
|
+
limitFormValueKeys.forEach((key) => {
|
|
100
|
+
const value = getFieldValues(key)[0]
|
|
101
|
+
// Booleans are always "set" (false is meaningful); strings/numbers use
|
|
102
|
+
// truthiness so an empty toAmount is treated as absent.
|
|
103
|
+
const hasValue = typeof value === 'boolean' ? true : Boolean(value)
|
|
104
|
+
if (mode === 'limit' && hasValue) {
|
|
105
|
+
url.searchParams.set(key, String(value))
|
|
106
|
+
} else {
|
|
107
|
+
url.searchParams.delete(key)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
88
110
|
url.searchParams.sort()
|
|
89
111
|
window.history.replaceState(window.history.state, '', url)
|
|
90
|
-
}, [pathname, touchedFields, values, isTouched, getFieldValues])
|
|
112
|
+
}, [pathname, touchedFields, values, isTouched, getFieldValues, mode])
|
|
91
113
|
|
|
92
114
|
return null
|
|
93
115
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
2
2
|
import { create } from 'zustand'
|
|
3
|
-
|
|
3
|
+
import { DEFAULT_VALID_UNTIL_SECONDS } from '../../utils/limitOrder.js'
|
|
4
4
|
import type {
|
|
5
5
|
DefaultValues,
|
|
6
6
|
FormFieldArray,
|
|
@@ -14,6 +14,9 @@ export const formDefaultValues: DefaultValues = {
|
|
|
14
14
|
fromAmount: '',
|
|
15
15
|
toAmount: '',
|
|
16
16
|
tokenSearchFilter: '',
|
|
17
|
+
priceInverted: false,
|
|
18
|
+
validUntil: DEFAULT_VALID_UNTIL_SECONDS,
|
|
19
|
+
partiallyFillable: true,
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
const defaultValueToFormValue = <T>(value: T): FormValueControl<T> => ({
|
|
@@ -32,7 +35,8 @@ const valuesToFormValues = (defaultValues: DefaultValues): FormValues => {
|
|
|
32
35
|
)
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
const isString = (str:
|
|
38
|
+
const isString = (str: unknown): str is string =>
|
|
39
|
+
typeof str === 'string' || str instanceof String
|
|
36
40
|
|
|
37
41
|
const getUpdatedTouchedFields = (userValues: FormValues) => {
|
|
38
42
|
return (Object.keys(userValues) as FormFieldNames[]).reduce(
|
|
@@ -58,7 +62,7 @@ const mergeDefaultFormValues = (
|
|
|
58
62
|
),
|
|
59
63
|
isDirty: !!(userValues[key]?.isDirty || defaultValues[key]?.isTouched),
|
|
60
64
|
value:
|
|
61
|
-
userValues[key]?.value
|
|
65
|
+
userValues[key]?.value !== undefined && userValues[key]?.value !== ''
|
|
62
66
|
? userValues[key]?.value
|
|
63
67
|
: defaultValues[key]?.value,
|
|
64
68
|
}
|
|
@@ -41,6 +41,17 @@ export const getDefaultValuesFromQueryString = ({
|
|
|
41
41
|
...(Number.isFinite(Number.parseFloat(searchParams.fromAmount))
|
|
42
42
|
? { fromAmount: formatInputAmount(searchParams.fromAmount) }
|
|
43
43
|
: {}),
|
|
44
|
+
...(Number.isFinite(Number.parseFloat(searchParams.toAmount))
|
|
45
|
+
? { toAmount: formatInputAmount(searchParams.toAmount) }
|
|
46
|
+
: {}),
|
|
47
|
+
// Limit-order params (written only while on the limit tab).
|
|
48
|
+
...(Number.isFinite(Number.parseInt(searchParams.validUntil, 10))
|
|
49
|
+
? { validUntil: Number.parseInt(searchParams.validUntil, 10) }
|
|
50
|
+
: {}),
|
|
51
|
+
...(searchParams.partiallyFillable === 'true' ||
|
|
52
|
+
searchParams.partiallyFillable === 'false'
|
|
53
|
+
? { partiallyFillable: searchParams.partiallyFillable === 'true' }
|
|
54
|
+
: {}),
|
|
44
55
|
...(includeToAddress && searchParams.toAddress
|
|
45
56
|
? { toAddress: searchParams.toAddress }
|
|
46
57
|
: {}),
|
package/src/stores/form/types.ts
CHANGED
|
@@ -14,9 +14,22 @@ export interface DefaultFieldValues {
|
|
|
14
14
|
export interface DefaultValues extends DefaultFieldValues {
|
|
15
15
|
contractCalls?: ContractCall[]
|
|
16
16
|
tokenSearchFilter: string
|
|
17
|
+
/** Limit-order: when true, the price is displayed/entered inverted. */
|
|
18
|
+
priceInverted: boolean
|
|
19
|
+
/** Limit-order: order validity as a duration in seconds. */
|
|
20
|
+
validUntil: number
|
|
21
|
+
/** Limit-order: whether the order may be partially filled. */
|
|
22
|
+
partiallyFillable: boolean
|
|
23
|
+
/** Limit-order: id of the route the user picked. */
|
|
24
|
+
selectedRouteId?: string
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
export type GenericFormValue =
|
|
27
|
+
export type GenericFormValue =
|
|
28
|
+
| string
|
|
29
|
+
| number
|
|
30
|
+
| boolean
|
|
31
|
+
| ContractCall[]
|
|
32
|
+
| undefined
|
|
20
33
|
export interface FormValueControl<T> {
|
|
21
34
|
isTouched: boolean
|
|
22
35
|
isDirty: boolean
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { use } from 'react'
|
|
2
2
|
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import { FormStoreContext } from './FormStoreContext.js'
|
|
4
4
|
import type { FormValuesState } from './types.js'
|
|
5
5
|
|
|
6
6
|
export function useFormStore<T>(selector: (state: FormValuesState) => T): T {
|
|
7
|
-
const useStore =
|
|
7
|
+
const useStore = use(FormStoreContext)
|
|
8
8
|
|
|
9
9
|
if (!useStore) {
|
|
10
10
|
throw new Error('You forgot to wrap your component in <FormStoreProvider>.')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, use, useRef } from 'react'
|
|
2
2
|
import { create } from 'zustand'
|
|
3
3
|
import { useShallow } from 'zustand/shallow'
|
|
4
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
@@ -14,14 +14,12 @@ export function HeaderStoreProvider({
|
|
|
14
14
|
storeRef.current = createHeaderStore()
|
|
15
15
|
}
|
|
16
16
|
return (
|
|
17
|
-
<HeaderStoreContext
|
|
18
|
-
{children}
|
|
19
|
-
</HeaderStoreContext.Provider>
|
|
17
|
+
<HeaderStoreContext value={storeRef.current}>{children}</HeaderStoreContext>
|
|
20
18
|
)
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
function useHeaderStoreContext() {
|
|
24
|
-
const useStore =
|
|
22
|
+
const useStore = use(HeaderStoreContext)
|
|
25
23
|
if (!useStore) {
|
|
26
24
|
throw new Error(
|
|
27
25
|
`You forgot to wrap your component in <${HeaderStoreProvider.name}>.`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
2
|
+
import type {
|
|
3
|
+
DefaultUI,
|
|
4
|
+
ModeOptions,
|
|
5
|
+
NavigationTabKey,
|
|
6
|
+
RequiredUIConfig,
|
|
7
|
+
WidgetMode,
|
|
8
|
+
WidgetVariant,
|
|
9
|
+
} from '../../types/widget.js'
|
|
10
|
+
|
|
11
|
+
export interface NavigationTab {
|
|
12
|
+
/** Stable, language-independent identity; resolved to a label via a hook. */
|
|
13
|
+
key: NavigationTabKey
|
|
14
|
+
/** When omitted, the tab inherits `config.variant`. */
|
|
15
|
+
variant?: WidgetVariant
|
|
16
|
+
/** When omitted, the tab inherits `config.mode`. */
|
|
17
|
+
mode?: WidgetMode
|
|
18
|
+
modeOptions?: ModeOptions
|
|
19
|
+
/** Layered over `config.defaultUI` while the tab is active. */
|
|
20
|
+
defaultUI?: DefaultUI
|
|
21
|
+
/** Layered over `config.requiredUI` while the tab is active. */
|
|
22
|
+
requiredUI?: RequiredUIConfig
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface NavigationTabsState {
|
|
26
|
+
/** Tabs to render in the header, resolved from config (empty when none). */
|
|
27
|
+
tabs: NavigationTabKey[]
|
|
28
|
+
/** Key of the active tab, or `undefined` when there are no tabs. */
|
|
29
|
+
activeTab?: NavigationTabKey
|
|
30
|
+
setActiveTab(activeTab: NavigationTabKey): void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type NavigationTabsStore = UseBoundStore<StoreApi<NavigationTabsState>>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next'
|
|
2
|
+
import type { NavigationTabKey } from '../../types/widget.js'
|
|
3
|
+
|
|
4
|
+
export const useNavigationTabLabel = (): ((
|
|
5
|
+
key: NavigationTabKey
|
|
6
|
+
) => string) => {
|
|
7
|
+
const { t } = useTranslation()
|
|
8
|
+
return (key: NavigationTabKey) => {
|
|
9
|
+
switch (key) {
|
|
10
|
+
case 'default':
|
|
11
|
+
return t('header.swapAndBridge')
|
|
12
|
+
case 'private':
|
|
13
|
+
return t('header.private')
|
|
14
|
+
case 'refuel':
|
|
15
|
+
return t('header.gas')
|
|
16
|
+
case 'swap':
|
|
17
|
+
case 'swap-advanced':
|
|
18
|
+
return t('header.swap')
|
|
19
|
+
case 'bridge':
|
|
20
|
+
case 'bridge-advanced':
|
|
21
|
+
return t('header.bridge')
|
|
22
|
+
case 'limit':
|
|
23
|
+
return t('header.limit')
|
|
24
|
+
default:
|
|
25
|
+
return t('header.swapAndBridge')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type JSX,
|
|
4
|
+
type PropsWithChildren,
|
|
5
|
+
use,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
} from 'react'
|
|
9
|
+
import { create } from 'zustand'
|
|
10
|
+
import { useShallow } from 'zustand/shallow'
|
|
11
|
+
import {
|
|
12
|
+
useWidgetConfig,
|
|
13
|
+
WidgetContext,
|
|
14
|
+
} from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
15
|
+
import type {
|
|
16
|
+
NavigationTabKey,
|
|
17
|
+
SplitMode,
|
|
18
|
+
WidgetConfig,
|
|
19
|
+
} from '../../types/widget.js'
|
|
20
|
+
import type { NavigationTabsState, NavigationTabsStore } from './types.js'
|
|
21
|
+
import {
|
|
22
|
+
getInitialActiveTab,
|
|
23
|
+
getNavigationTabKeys,
|
|
24
|
+
getTabDefaultUI,
|
|
25
|
+
getTabMode,
|
|
26
|
+
getTabModeOptions,
|
|
27
|
+
getTabRequiredUI,
|
|
28
|
+
getTabSplitMode,
|
|
29
|
+
getTabVariant,
|
|
30
|
+
} from './utils.js'
|
|
31
|
+
|
|
32
|
+
const NavigationTabsStoreContext = createContext<NavigationTabsStore | null>(
|
|
33
|
+
null
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export function NavigationTabsStoreProvider({
|
|
37
|
+
children,
|
|
38
|
+
config,
|
|
39
|
+
}: PropsWithChildren<{ config: WidgetConfig }>): JSX.Element {
|
|
40
|
+
const tabs = getNavigationTabKeys(config)
|
|
41
|
+
const initialActiveTab = getInitialActiveTab(config)
|
|
42
|
+
// Recreate (re-seeding tabs + active tab) only when the config-driven inputs
|
|
43
|
+
// change — not on runtime tab clicks, which must be preserved.
|
|
44
|
+
const signature = `${tabs.join(',')}|${initialActiveTab ?? ''}`
|
|
45
|
+
const storeRef = useRef<NavigationTabsStore>(null)
|
|
46
|
+
const signatureRef = useRef(signature)
|
|
47
|
+
let store = storeRef.current
|
|
48
|
+
if (!store || signatureRef.current !== signature) {
|
|
49
|
+
store = createNavigationTabsStore(tabs, initialActiveTab)
|
|
50
|
+
storeRef.current = store
|
|
51
|
+
signatureRef.current = signature
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Override the widget config with the active tab's mode, variant,
|
|
55
|
+
// modeOptions, defaultUI and requiredUI (each falling back to the config), so
|
|
56
|
+
// the rest of the widget reads tab-driven config transparently. No-op when
|
|
57
|
+
// there is no active tab.
|
|
58
|
+
const widgetConfig = useWidgetConfig()
|
|
59
|
+
const activeTab = store((state) => state.activeTab)
|
|
60
|
+
const tabConfig = useMemo(() => {
|
|
61
|
+
if (!activeTab) {
|
|
62
|
+
return widgetConfig
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
...widgetConfig,
|
|
66
|
+
mode: getTabMode(widgetConfig, activeTab),
|
|
67
|
+
variant: getTabVariant(widgetConfig, activeTab),
|
|
68
|
+
modeOptions: getTabModeOptions(widgetConfig, activeTab),
|
|
69
|
+
defaultUI: getTabDefaultUI(widgetConfig, activeTab),
|
|
70
|
+
requiredUI: getTabRequiredUI(widgetConfig, activeTab),
|
|
71
|
+
}
|
|
72
|
+
}, [widgetConfig, activeTab])
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<NavigationTabsStoreContext value={store}>
|
|
76
|
+
<WidgetContext value={tabConfig}>{children}</WidgetContext>
|
|
77
|
+
</NavigationTabsStoreContext>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function useNavigationTabsStoreContext(): NavigationTabsStore {
|
|
82
|
+
const useStore = use(NavigationTabsStoreContext)
|
|
83
|
+
if (!useStore) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`You forgot to wrap your component in <${NavigationTabsStoreProvider.name}>.`
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
return useStore
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function useNavigationTabsStore<T>(
|
|
92
|
+
selector: (state: NavigationTabsState) => T
|
|
93
|
+
): T {
|
|
94
|
+
const useStore = useNavigationTabsStoreContext()
|
|
95
|
+
return useStore(useShallow(selector))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Effective split mode derived from the active tab. */
|
|
99
|
+
export function useSplitMode(): SplitMode | undefined {
|
|
100
|
+
return useNavigationTabsStore((state) => getTabSplitMode(state.activeTab))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const createNavigationTabsStore = (
|
|
104
|
+
tabs: NavigationTabKey[],
|
|
105
|
+
initialActiveTab?: NavigationTabKey
|
|
106
|
+
): NavigationTabsStore =>
|
|
107
|
+
create<NavigationTabsState>((set) => ({
|
|
108
|
+
tabs,
|
|
109
|
+
activeTab: initialActiveTab,
|
|
110
|
+
setActiveTab(activeTab) {
|
|
111
|
+
set({ activeTab })
|
|
112
|
+
},
|
|
113
|
+
}))
|