@lifi/widget 4.0.0 → 4.1.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/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.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -1
- 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.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.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 +26 -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.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/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/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/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/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/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/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.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/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.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 +1 -1
- 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/i18n/en.json +3 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/pages/ActivitiesPage/ActivitiesPage.js.map +1 -1
- package/dist/esm/pages/MainPage/ReviewButton.js +2 -2
- package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
- 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.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 +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/SlippageSettings.style.js.map +1 -1
- 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/utils.js.map +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
- package/dist/esm/providers/I18nProvider/i18n.js.map +1 -1
- package/dist/esm/providers/QueryClientProvider.js +2 -2
- package/dist/esm/providers/QueryClientProvider.js.map +1 -1
- package/dist/esm/providers/SDKClientProvider.js +26 -27
- package/dist/esm/providers/SDKClientProvider.js.map +1 -1
- package/dist/esm/providers/WidgetProvider/WidgetProvider.js +25 -27
- 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.map +1 -1
- package/dist/esm/stores/form/createFormStore.js.map +1 -1
- package/dist/esm/stores/form/getDefaultValuesFromQueryString.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 +62 -0
- package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js.map +1 -0
- package/dist/esm/stores/navigationTabs/utils.js +92 -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/widget.d.ts +19 -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.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/{variant.js → mode.js} +2 -2
- package/dist/esm/utils/mode.js.map +1 -0
- 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 +11 -11
- package/src/App.tsx +7 -7
- package/src/AppDrawer.tsx +77 -78
- package/src/AppDrawerContext.ts +2 -2
- 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 +25 -0
- package/src/components/Header/HeaderTabs.tsx +48 -0
- package/src/components/Header/NavigationHeader.tsx +11 -8
- package/src/components/ReverseTokensButton/ReverseTokensButton.tsx +4 -1
- package/src/components/Skeleton/WidgetSkeleton.tsx +1 -1
- 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/config/version.ts +1 -1
- package/src/hooks/useSwapOnly.ts +2 -5
- package/src/hooks/useToAddressRequirements.ts +2 -2
- package/src/pages/MainPage/ReviewButton.tsx +2 -2
- package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +176 -185
- package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +9 -6
- package/src/pages/SettingsPage/SettingsCard/SettingCardExpandable.tsx +58 -65
- package/src/pages/SettingsPage/SettingsCard/SettingsAccordian.tsx +4 -4
- 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/useFormStore.ts +2 -2
- package/src/stores/header/useHeaderStore.tsx +3 -5
- package/src/stores/navigationTabs/types.ts +27 -0
- package/src/stores/navigationTabs/useNavigationTabLabel.ts +28 -0
- package/src/stores/navigationTabs/useNavigationTabsStore.tsx +108 -0
- package/src/stores/navigationTabs/utils.ts +134 -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/widget.ts +31 -1
- 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
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InternalNavigationTabKey,
|
|
3
|
+
ModeOptions,
|
|
4
|
+
NavigationTabKey,
|
|
5
|
+
SplitMode,
|
|
6
|
+
SplitNavigationTabKey,
|
|
7
|
+
WidgetConfig,
|
|
8
|
+
WidgetMode,
|
|
9
|
+
WidgetVariant,
|
|
10
|
+
} from '../../types/widget.js'
|
|
11
|
+
import { getSplitMode } from '../../utils/mode.js'
|
|
12
|
+
import type { NavigationTab } from './types.js'
|
|
13
|
+
|
|
14
|
+
/** Configured navigation tabs by key. Labels are resolved from the key by a hook. */
|
|
15
|
+
const navigationTabsByKey: Record<InternalNavigationTabKey, NavigationTab> = {
|
|
16
|
+
default: { key: 'default', variant: 'wide', mode: 'default' },
|
|
17
|
+
private: {
|
|
18
|
+
key: 'private',
|
|
19
|
+
variant: 'compact',
|
|
20
|
+
mode: 'split',
|
|
21
|
+
modeOptions: { split: 'swap' },
|
|
22
|
+
},
|
|
23
|
+
refuel: { key: 'refuel', variant: 'wide', mode: 'refuel' },
|
|
24
|
+
limit: { key: 'limit', variant: 'compact', mode: 'limit' },
|
|
25
|
+
'swap-advanced': {
|
|
26
|
+
key: 'swap-advanced',
|
|
27
|
+
variant: 'wide',
|
|
28
|
+
mode: 'split',
|
|
29
|
+
modeOptions: { split: 'swap' },
|
|
30
|
+
},
|
|
31
|
+
'bridge-advanced': {
|
|
32
|
+
key: 'bridge-advanced',
|
|
33
|
+
variant: 'wide',
|
|
34
|
+
mode: 'split',
|
|
35
|
+
modeOptions: { split: 'bridge' },
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Split-mode tabs (Swap / Bridge), shown when no navigation tabs are configured. */
|
|
40
|
+
const splitTabs: NavigationTab[] = [
|
|
41
|
+
{
|
|
42
|
+
key: 'swap',
|
|
43
|
+
mode: 'split',
|
|
44
|
+
modeOptions: { split: 'swap' },
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: 'bridge',
|
|
48
|
+
mode: 'split',
|
|
49
|
+
modeOptions: { split: 'bridge' },
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
const splitTabsByKey = Object.fromEntries(
|
|
54
|
+
splitTabs.map((tab) => [tab.key, tab])
|
|
55
|
+
) as Record<SplitNavigationTabKey, NavigationTab>
|
|
56
|
+
|
|
57
|
+
/** Combined lookup across configured and split tabs. */
|
|
58
|
+
const tabByKey: Record<NavigationTabKey, NavigationTab> = {
|
|
59
|
+
...navigationTabsByKey,
|
|
60
|
+
...splitTabsByKey,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Tab keys shown in split mode when no navigation tabs are configured. */
|
|
64
|
+
export const splitTabKeys: NavigationTabKey[] = splitTabs.map((tab) => tab.key)
|
|
65
|
+
|
|
66
|
+
/** Resolves which navigation tabs the header should render from the config. */
|
|
67
|
+
export const getNavigationTabKeys = (
|
|
68
|
+
config: WidgetConfig
|
|
69
|
+
): NavigationTabKey[] => {
|
|
70
|
+
if (config._navigationTabs?.length) {
|
|
71
|
+
return config._navigationTabs
|
|
72
|
+
}
|
|
73
|
+
// Split mode shows Swap / Bridge tabs unless pinned to a single side.
|
|
74
|
+
if (
|
|
75
|
+
config.mode === 'split' &&
|
|
76
|
+
typeof config.modeOptions?.split !== 'string'
|
|
77
|
+
) {
|
|
78
|
+
return splitTabKeys
|
|
79
|
+
}
|
|
80
|
+
return []
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The tab the store seeds as active from the config. With navigation tabs it's
|
|
85
|
+
* the first configured tab; otherwise split mode's selection is itself a tab
|
|
86
|
+
* (`swap`/`bridge`), so it seeds the active tab too.
|
|
87
|
+
*/
|
|
88
|
+
export const getInitialActiveTab = (
|
|
89
|
+
config: WidgetConfig
|
|
90
|
+
): NavigationTabKey | undefined => {
|
|
91
|
+
if (config._navigationTabs?.length) {
|
|
92
|
+
return config._navigationTabs[0]
|
|
93
|
+
}
|
|
94
|
+
return config.mode === 'split'
|
|
95
|
+
? getSplitMode(config.modeOptions?.split)
|
|
96
|
+
: undefined
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Split mode (`swap`/`bridge`) implied by a tab, or `undefined` if not split. */
|
|
100
|
+
export const getTabSplitMode = (
|
|
101
|
+
key?: NavigationTabKey
|
|
102
|
+
): SplitMode | undefined => {
|
|
103
|
+
const tab = key ? tabByKey[key] : undefined
|
|
104
|
+
return tab?.mode === 'split'
|
|
105
|
+
? getSplitMode(tab.modeOptions?.split)
|
|
106
|
+
: undefined
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Variant for a tab, falling back to the widget config's variant when unset. */
|
|
110
|
+
export const getTabVariant = (
|
|
111
|
+
config: WidgetConfig,
|
|
112
|
+
key?: NavigationTabKey
|
|
113
|
+
): WidgetVariant | undefined => {
|
|
114
|
+
const tab = key ? tabByKey[key] : undefined
|
|
115
|
+
return tab?.variant ?? config.variant
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Mode for a tab, falling back to the widget config's mode when unset. */
|
|
119
|
+
export const getTabMode = (
|
|
120
|
+
config: WidgetConfig,
|
|
121
|
+
key?: NavigationTabKey
|
|
122
|
+
): WidgetMode | undefined => {
|
|
123
|
+
const tab = key ? tabByKey[key] : undefined
|
|
124
|
+
return tab?.mode ?? config.mode
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Mode options for a tab, falling back to the widget config's when unset. */
|
|
128
|
+
export const getTabModeOptions = (
|
|
129
|
+
config: WidgetConfig,
|
|
130
|
+
key?: NavigationTabKey
|
|
131
|
+
): ModeOptions | undefined => {
|
|
132
|
+
const tab = key ? tabByKey[key] : undefined
|
|
133
|
+
return tab?.modeOptions ?? config.modeOptions
|
|
134
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, use, useRef } from 'react'
|
|
2
2
|
import { useShallow } from 'zustand/shallow'
|
|
3
3
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
4
4
|
import { createPinnedTokensStore } from './createPinnedTokensStore.js'
|
|
@@ -17,16 +17,16 @@ export const PinnedTokensStoreProvider: React.FC<PersistStoreProviderProps> = ({
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<PinnedTokensStoreContext
|
|
20
|
+
<PinnedTokensStoreContext value={storeRef.current}>
|
|
21
21
|
{children}
|
|
22
|
-
</PinnedTokensStoreContext
|
|
22
|
+
</PinnedTokensStoreContext>
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function usePinnedTokensStore<T>(
|
|
27
27
|
selector: (store: PinnedTokensState) => T
|
|
28
28
|
): T {
|
|
29
|
-
const useStore =
|
|
29
|
+
const useStore = use(PinnedTokensStoreContext)
|
|
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, useRef } from 'react'
|
|
2
2
|
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
3
3
|
import { useShallow } from 'zustand/shallow'
|
|
4
4
|
import type { PersistStoreProviderProps } from '../types.js'
|
|
@@ -20,14 +20,14 @@ export function RouteExecutionStoreProvider({
|
|
|
20
20
|
storeRef.current = createRouteExecutionStore(props)
|
|
21
21
|
}
|
|
22
22
|
return (
|
|
23
|
-
<RouteExecutionStoreContext
|
|
23
|
+
<RouteExecutionStoreContext value={storeRef.current}>
|
|
24
24
|
{children}
|
|
25
|
-
</RouteExecutionStoreContext
|
|
25
|
+
</RouteExecutionStoreContext>
|
|
26
26
|
)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export function useRouteExecutionStoreContext(): any {
|
|
30
|
-
const useStore =
|
|
30
|
+
const useStore = use(RouteExecutionStoreContext)
|
|
31
31
|
if (!useStore) {
|
|
32
32
|
throw new Error(
|
|
33
33
|
`You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createContext,
|
|
3
3
|
type JSX,
|
|
4
4
|
type PropsWithChildren,
|
|
5
|
-
|
|
5
|
+
use,
|
|
6
6
|
useRef,
|
|
7
7
|
} from 'react'
|
|
8
8
|
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
@@ -23,14 +23,14 @@ export const SettingsStoreProvider = ({
|
|
|
23
23
|
storeRef.current = createSettingsStore(config)
|
|
24
24
|
}
|
|
25
25
|
return (
|
|
26
|
-
<SettingsStoreContext
|
|
26
|
+
<SettingsStoreContext value={storeRef.current}>
|
|
27
27
|
{children}
|
|
28
|
-
</SettingsStoreContext
|
|
28
|
+
</SettingsStoreContext>
|
|
29
29
|
)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function useSettingsStoreContext(): any {
|
|
33
|
-
const useStore =
|
|
33
|
+
const useStore = use(SettingsStoreContext)
|
|
34
34
|
if (!useStore) {
|
|
35
35
|
throw new Error(
|
|
36
36
|
'You forgot to wrap your component in SettingsStoreContext.'
|
|
@@ -6,7 +6,8 @@ import { allLanguages } from '../../providers/I18nProvider/constants.js'
|
|
|
6
6
|
import { loadLocale } from '../../providers/I18nProvider/i18n.js'
|
|
7
7
|
import type { LanguageKey } from '../../providers/I18nProvider/types.js'
|
|
8
8
|
import type { WidgetConfig } from '../../types/widget.js'
|
|
9
|
-
import
|
|
9
|
+
import { getConfigItemSets, isItemAllowedForSets } from '../../utils/item.js'
|
|
10
|
+
import type { SettingsProps, SettingsState, SettingsToolType } from './types.js'
|
|
10
11
|
import { SettingsToolTypes } from './types.js'
|
|
11
12
|
import { getStateValues } from './utils/getStateValues.js'
|
|
12
13
|
|
|
@@ -35,11 +36,44 @@ const defaultSettings: SettingsProps = {
|
|
|
35
36
|
|
|
36
37
|
export const createSettingsStore = (
|
|
37
38
|
config: WidgetConfig
|
|
38
|
-
): UseBoundStore<StoreApi<SettingsState>> =>
|
|
39
|
-
|
|
39
|
+
): UseBoundStore<StoreApi<SettingsState>> => {
|
|
40
|
+
const configItemsByToolType = {
|
|
41
|
+
Bridges: config.bridges,
|
|
42
|
+
Exchanges: config.exchanges,
|
|
43
|
+
}
|
|
44
|
+
// Tool state from a candidate map, keeping only config-allowed tools.
|
|
45
|
+
const buildToolState = (
|
|
46
|
+
toolType: SettingsToolType,
|
|
47
|
+
enabledMap: Record<string, boolean>
|
|
48
|
+
) => {
|
|
49
|
+
const configItemSets = getConfigItemSets(
|
|
50
|
+
configItemsByToolType[toolType],
|
|
51
|
+
(items) => new Set(items)
|
|
52
|
+
)
|
|
53
|
+
const allowed: Record<string, boolean> = Object.fromEntries(
|
|
54
|
+
Object.entries(enabledMap).filter(([key]) =>
|
|
55
|
+
isItemAllowedForSets(key, configItemSets)
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
const keys = Object.keys(allowed)
|
|
59
|
+
return {
|
|
60
|
+
[`_enabled${toolType}`]: allowed,
|
|
61
|
+
[`enabled${toolType}`]: keys.filter((key) => allowed[key]),
|
|
62
|
+
[`disabled${toolType}`]: keys.filter((key) => !allowed[key]),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const toEnabledMap = (keys: string[] = []): Record<string, boolean> =>
|
|
66
|
+
Object.fromEntries(keys.map((key) => [key, true] as const))
|
|
67
|
+
// Deny-only configs can't be seeded; the tool universe is unknown until /tools.
|
|
68
|
+
const initialSettings: SettingsProps = {
|
|
69
|
+
...defaultSettings,
|
|
70
|
+
...buildToolState('Bridges', toEnabledMap(config.bridges?.allow)),
|
|
71
|
+
...buildToolState('Exchanges', toEnabledMap(config.exchanges?.allow)),
|
|
72
|
+
}
|
|
73
|
+
return create<SettingsState>()(
|
|
40
74
|
persist(
|
|
41
75
|
(set, get) => ({
|
|
42
|
-
...
|
|
76
|
+
...initialSettings,
|
|
43
77
|
setValue: (key, value) =>
|
|
44
78
|
set(() => ({
|
|
45
79
|
[key]: value,
|
|
@@ -163,15 +197,16 @@ export const createSettingsStore = (
|
|
|
163
197
|
merge: (persistedState: any, currentState: SettingsState) => {
|
|
164
198
|
const state = { ...currentState, ...persistedState }
|
|
165
199
|
SettingsToolTypes.forEach((toolType) => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
const persistedEnabled = persistedState?.[`_enabled${toolType}`]
|
|
201
|
+
if (persistedEnabled) {
|
|
202
|
+
// Overlay persisted toggles on the config allow seed so an empty
|
|
203
|
+
// intersection keeps the allow-list instead of going unrestricted.
|
|
204
|
+
const allowMap = toEnabledMap(
|
|
205
|
+
configItemsByToolType[toolType]?.allow
|
|
172
206
|
)
|
|
173
|
-
|
|
174
|
-
|
|
207
|
+
Object.assign(
|
|
208
|
+
state,
|
|
209
|
+
buildToolState(toolType, { ...allowMap, ...persistedEnabled })
|
|
175
210
|
)
|
|
176
211
|
}
|
|
177
212
|
})
|
|
@@ -217,3 +252,4 @@ export const createSettingsStore = (
|
|
|
217
252
|
}
|
|
218
253
|
)
|
|
219
254
|
)
|
|
255
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Order } from '@lifi/sdk'
|
|
2
|
-
import type { PropsWithChildren } from 'react'
|
|
3
|
-
import type { StoreApi, UseBoundStore } from 'zustand'
|
|
4
2
|
import type { LanguageResource } from '../../providers/I18nProvider/types.js'
|
|
5
|
-
import type {
|
|
3
|
+
import type { WidgetConfig } from '../../types/widget.js'
|
|
6
4
|
|
|
7
5
|
export type ValueSetter<S> = <K extends keyof S>(
|
|
8
6
|
key: K,
|
|
@@ -48,19 +46,6 @@ export interface SettingsActions {
|
|
|
48
46
|
|
|
49
47
|
export type SettingsState = SettingsProps & SettingsActions
|
|
50
48
|
|
|
51
|
-
export interface SplitModeState {
|
|
52
|
-
state?: SplitMode
|
|
53
|
-
setState(state: SplitMode): void
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type SplitModeStore = UseBoundStore<StoreApi<SplitModeState>>
|
|
57
|
-
|
|
58
|
-
export interface SplitModeProps {
|
|
59
|
-
state?: SplitMode
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type SplitModeProviderProps = PropsWithChildren<SplitModeProps>
|
|
63
|
-
|
|
64
49
|
export interface SettingsStoreProviderProps {
|
|
65
50
|
config: WidgetConfig
|
|
66
51
|
}
|
package/src/types/widget.ts
CHANGED
|
@@ -35,7 +35,15 @@ import type {
|
|
|
35
35
|
import type { DefaultFieldValues } from '../stores/form/types.js'
|
|
36
36
|
|
|
37
37
|
export type WidgetVariant = 'compact' | 'wide' | 'drawer'
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
/** @internal Not part of the public API. */
|
|
40
|
+
export type InternalWidgetMode = 'limit'
|
|
41
|
+
export type WidgetMode =
|
|
42
|
+
| 'default'
|
|
43
|
+
| 'split'
|
|
44
|
+
| 'custom'
|
|
45
|
+
| 'refuel'
|
|
46
|
+
| InternalWidgetMode
|
|
39
47
|
export type SplitMode = 'bridge' | 'swap'
|
|
40
48
|
export type SplitModeOptions = {
|
|
41
49
|
defaultTab: SplitMode
|
|
@@ -51,6 +59,21 @@ export interface ModeOptions {
|
|
|
51
59
|
custom?: { type: CustomMode }
|
|
52
60
|
}
|
|
53
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Identity of a header navigation tab. Each key maps to a widget variant, mode and
|
|
64
|
+
* (optionally) mode options; labels are resolved from the key.
|
|
65
|
+
*/
|
|
66
|
+
export type SplitNavigationTabKey = SplitMode
|
|
67
|
+
/** @internal Not part of the public API. */
|
|
68
|
+
export type InternalNavigationTabKey =
|
|
69
|
+
| 'default'
|
|
70
|
+
| 'private'
|
|
71
|
+
| 'refuel'
|
|
72
|
+
| 'swap-advanced'
|
|
73
|
+
| 'bridge-advanced'
|
|
74
|
+
| 'limit'
|
|
75
|
+
export type NavigationTabKey = InternalNavigationTabKey | SplitNavigationTabKey
|
|
76
|
+
|
|
54
77
|
export type Appearance = PaletteMode | 'system'
|
|
55
78
|
export interface NavigationProps {
|
|
56
79
|
/**
|
|
@@ -344,6 +367,13 @@ export interface WidgetConfig {
|
|
|
344
367
|
variant?: WidgetVariant
|
|
345
368
|
mode?: WidgetMode
|
|
346
369
|
modeOptions?: ModeOptions
|
|
370
|
+
/**
|
|
371
|
+
* Header navigation tabs, in order. When set, the widget renders a tab bar
|
|
372
|
+
* and the active tab drives the displayed flow. Each entry is a tab key.
|
|
373
|
+
*
|
|
374
|
+
* @internal Not part of the public API.
|
|
375
|
+
*/
|
|
376
|
+
_navigationTabs?: NavigationTabKey[]
|
|
347
377
|
|
|
348
378
|
appearance?: Appearance
|
|
349
379
|
theme?: WidgetTheme
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useSplitModeStore } from "../../stores/settings/useSplitModeStore.js";
|
|
2
|
-
import { useFieldActions } from "../../stores/form/useFieldActions.js";
|
|
3
|
-
import { NavigationTab, NavigationTabs } from "../Tabs/NavigationTabs.js";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { useTranslation } from "react-i18next";
|
|
6
|
-
//#region src/components/Header/SplitNavigationTabs.tsx
|
|
7
|
-
const SplitNavigationTabs = () => {
|
|
8
|
-
const { t } = useTranslation();
|
|
9
|
-
const [state, setState] = useSplitModeStore((state) => [state.state, state.setState]);
|
|
10
|
-
const { setFieldValue } = useFieldActions();
|
|
11
|
-
const handleChange = (_, value) => {
|
|
12
|
-
setFieldValue("fromAmount", "");
|
|
13
|
-
setFieldValue("fromToken", "");
|
|
14
|
-
setFieldValue("toToken", "");
|
|
15
|
-
setState(value === 0 ? "swap" : "bridge");
|
|
16
|
-
};
|
|
17
|
-
return /* @__PURE__ */ jsxs(NavigationTabs, {
|
|
18
|
-
value: state === "swap" ? 0 : 1,
|
|
19
|
-
onChange: handleChange,
|
|
20
|
-
"aria-label": "tabs",
|
|
21
|
-
children: [/* @__PURE__ */ jsx(NavigationTab, {
|
|
22
|
-
label: t("header.swap"),
|
|
23
|
-
disableRipple: true
|
|
24
|
-
}), /* @__PURE__ */ jsx(NavigationTab, {
|
|
25
|
-
label: t("header.bridge"),
|
|
26
|
-
disableRipple: true
|
|
27
|
-
})]
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
export { SplitNavigationTabs };
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=SplitNavigationTabs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SplitNavigationTabs.js","names":[],"sources":["../../../../src/components/Header/SplitNavigationTabs.tsx"],"sourcesContent":["import type { JSX } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useFieldActions } from '../../stores/form/useFieldActions.js'\nimport { useSplitModeStore } from '../../stores/settings/useSplitModeStore.js'\nimport { NavigationTab, NavigationTabs } from '../Tabs/NavigationTabs.js'\n\nexport const SplitNavigationTabs = (): JSX.Element => {\n const { t } = useTranslation()\n const [state, setState] = useSplitModeStore((state) => [\n state.state,\n state.setState,\n ])\n\n const { setFieldValue } = useFieldActions()\n const handleChange = (_: React.SyntheticEvent, value: number) => {\n setFieldValue('fromAmount', '')\n setFieldValue('fromToken', '')\n setFieldValue('toToken', '')\n setState(value === 0 ? 'swap' : 'bridge')\n }\n\n return (\n <NavigationTabs\n value={state === 'swap' ? 0 : 1}\n onChange={handleChange}\n aria-label=\"tabs\"\n >\n <NavigationTab label={t('header.swap')} disableRipple />\n <NavigationTab label={t('header.bridge')} disableRipple />\n </NavigationTabs>\n )\n}\n"],"mappings":";;;;;;AAMA,MAAa,4BAAyC;CACpD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,OAAO,YAAY,mBAAmB,UAAU,CACrD,MAAM,OACN,MAAM,QACR,CAAC;CAED,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,gBAAgB,GAAyB,UAAkB;EAC/D,cAAc,cAAc,EAAE;EAC9B,cAAc,aAAa,EAAE;EAC7B,cAAc,WAAW,EAAE;EAC3B,SAAS,UAAU,IAAI,SAAS,QAAQ;CAC1C;CAEA,OACE,qBAAC,gBAAD;EACE,OAAO,UAAU,SAAS,IAAI;EAC9B,UAAU;EACV,cAAW;YAHb,CAKE,oBAAC,eAAD;GAAe,OAAO,EAAE,aAAa;GAAG,eAAA;EAAe,CAAA,GACvD,oBAAC,eAAD;GAAe,OAAO,EAAE,eAAe;GAAG,eAAA;EAAe,CAAA,CAC3C;;AAEpB"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useRef } from "react";
|
|
2
|
-
import { create } from "zustand";
|
|
3
|
-
import { useShallow } from "zustand/shallow";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/stores/settings/useSplitModeStore.tsx
|
|
6
|
-
const SplitModeStoreContext = createContext(null);
|
|
7
|
-
const shouldRecreateStore = (store, props) => {
|
|
8
|
-
const { state } = store.getState();
|
|
9
|
-
return state !== props.state;
|
|
10
|
-
};
|
|
11
|
-
function SplitModeStoreProvider({ children, ...props }) {
|
|
12
|
-
const storeRef = useRef(null);
|
|
13
|
-
if (!storeRef.current || shouldRecreateStore(storeRef.current, props)) storeRef.current = createSplitModeStore(props);
|
|
14
|
-
return /* @__PURE__ */ jsx(SplitModeStoreContext.Provider, {
|
|
15
|
-
value: storeRef.current,
|
|
16
|
-
children
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function useSplitModeStoreContext() {
|
|
20
|
-
const useStore = useContext(SplitModeStoreContext);
|
|
21
|
-
if (!useStore) throw new Error(`You forgot to wrap your component in <${SplitModeStoreProvider.name}>.`);
|
|
22
|
-
return useStore;
|
|
23
|
-
}
|
|
24
|
-
function useSplitModeStore(selector) {
|
|
25
|
-
return useSplitModeStoreContext()(useShallow(selector));
|
|
26
|
-
}
|
|
27
|
-
const createSplitModeStore = ({ state }) => create((set) => ({
|
|
28
|
-
state,
|
|
29
|
-
setState(state) {
|
|
30
|
-
set(() => ({ state }));
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
//#endregion
|
|
34
|
-
export { SplitModeStoreProvider, useSplitModeStore };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=useSplitModeStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSplitModeStore.js","names":[],"sources":["../../../../src/stores/settings/useSplitModeStore.tsx"],"sourcesContent":["import { createContext, type JSX, useContext, useRef } from 'react'\nimport { create } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport type {\n SplitModeProps,\n SplitModeProviderProps,\n SplitModeState,\n SplitModeStore,\n} from './types.js'\n\nconst SplitModeStoreContext = createContext<SplitModeStore | null>(null)\n\nconst shouldRecreateStore = (store: SplitModeStore, props: SplitModeProps) => {\n const { state } = store.getState()\n return state !== props.state\n}\n\nexport function SplitModeStoreProvider({\n children,\n ...props\n}: SplitModeProviderProps): JSX.Element {\n const storeRef = useRef<SplitModeStore>(null)\n if (!storeRef.current || shouldRecreateStore(storeRef.current, props)) {\n storeRef.current = createSplitModeStore(props)\n }\n return (\n <SplitModeStoreContext.Provider value={storeRef.current}>\n {children}\n </SplitModeStoreContext.Provider>\n )\n}\n\nfunction useSplitModeStoreContext() {\n const useStore = useContext(SplitModeStoreContext)\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${SplitModeStoreProvider.name}>.`\n )\n }\n return useStore\n}\n\nexport function useSplitModeStore<T>(\n selector: (state: SplitModeState) => T\n): T {\n const useStore = useSplitModeStoreContext()\n return useStore(useShallow(selector))\n}\n\nconst createSplitModeStore = ({ state }: SplitModeProps) =>\n create<SplitModeState>((set) => ({\n state,\n setState(state) {\n set(() => ({\n state,\n }))\n },\n }))\n"],"mappings":";;;;;AAUA,MAAM,wBAAwB,cAAqC,IAAI;AAEvE,MAAM,uBAAuB,OAAuB,UAA0B;CAC5E,MAAM,EAAE,UAAU,MAAM,SAAS;CACjC,OAAO,UAAU,MAAM;AACzB;AAEA,SAAgB,uBAAuB,EACrC,UACA,GAAG,SACmC;CACtC,MAAM,WAAW,OAAuB,IAAI;CAC5C,IAAI,CAAC,SAAS,WAAW,oBAAoB,SAAS,SAAS,KAAK,GAClE,SAAS,UAAU,qBAAqB,KAAK;CAE/C,OACE,oBAAC,sBAAsB,UAAvB;EAAgC,OAAO,SAAS;EAC7C;CAC6B,CAAA;AAEpC;AAEA,SAAS,2BAA2B;CAClC,MAAM,WAAW,WAAW,qBAAqB;CACjD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,uBAAuB,KAAK,GACvE;CAEF,OAAO;AACT;AAEA,SAAgB,kBACd,UACG;CAEH,OADiB,yBACH,EAAE,WAAW,QAAQ,CAAC;AACtC;AAEA,MAAM,wBAAwB,EAAE,YAC9B,QAAwB,SAAS;CAC/B;CACA,SAAS,OAAO;EACd,WAAW,EACT,MACF,EAAE;CACJ;AACF,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant.js","names":[],"sources":["../../../src/utils/variant.ts"],"sourcesContent":["import type { SplitMode, SplitModeOptions } from '../types/widget.js'\n\nexport const getSplitMode = (\n split?: SplitMode | SplitModeOptions\n): SplitMode => {\n if (!split) {\n return 'swap'\n }\n if (typeof split === 'string') {\n return split\n }\n return split.defaultTab\n}\n"],"mappings":";AAEA,MAAa,gBACX,UACc;CACd,IAAI,CAAC,OACH,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { JSX } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
4
|
-
import { useSplitModeStore } from '../../stores/settings/useSplitModeStore.js'
|
|
5
|
-
import { NavigationTab, NavigationTabs } from '../Tabs/NavigationTabs.js'
|
|
6
|
-
|
|
7
|
-
export const SplitNavigationTabs = (): JSX.Element => {
|
|
8
|
-
const { t } = useTranslation()
|
|
9
|
-
const [state, setState] = useSplitModeStore((state) => [
|
|
10
|
-
state.state,
|
|
11
|
-
state.setState,
|
|
12
|
-
])
|
|
13
|
-
|
|
14
|
-
const { setFieldValue } = useFieldActions()
|
|
15
|
-
const handleChange = (_: React.SyntheticEvent, value: number) => {
|
|
16
|
-
setFieldValue('fromAmount', '')
|
|
17
|
-
setFieldValue('fromToken', '')
|
|
18
|
-
setFieldValue('toToken', '')
|
|
19
|
-
setState(value === 0 ? 'swap' : 'bridge')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<NavigationTabs
|
|
24
|
-
value={state === 'swap' ? 0 : 1}
|
|
25
|
-
onChange={handleChange}
|
|
26
|
-
aria-label="tabs"
|
|
27
|
-
>
|
|
28
|
-
<NavigationTab label={t('header.swap')} disableRipple />
|
|
29
|
-
<NavigationTab label={t('header.bridge')} disableRipple />
|
|
30
|
-
</NavigationTabs>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createContext, type JSX, useContext, useRef } from 'react'
|
|
2
|
-
import { create } from 'zustand'
|
|
3
|
-
import { useShallow } from 'zustand/shallow'
|
|
4
|
-
import type {
|
|
5
|
-
SplitModeProps,
|
|
6
|
-
SplitModeProviderProps,
|
|
7
|
-
SplitModeState,
|
|
8
|
-
SplitModeStore,
|
|
9
|
-
} from './types.js'
|
|
10
|
-
|
|
11
|
-
const SplitModeStoreContext = createContext<SplitModeStore | null>(null)
|
|
12
|
-
|
|
13
|
-
const shouldRecreateStore = (store: SplitModeStore, props: SplitModeProps) => {
|
|
14
|
-
const { state } = store.getState()
|
|
15
|
-
return state !== props.state
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function SplitModeStoreProvider({
|
|
19
|
-
children,
|
|
20
|
-
...props
|
|
21
|
-
}: SplitModeProviderProps): JSX.Element {
|
|
22
|
-
const storeRef = useRef<SplitModeStore>(null)
|
|
23
|
-
if (!storeRef.current || shouldRecreateStore(storeRef.current, props)) {
|
|
24
|
-
storeRef.current = createSplitModeStore(props)
|
|
25
|
-
}
|
|
26
|
-
return (
|
|
27
|
-
<SplitModeStoreContext.Provider value={storeRef.current}>
|
|
28
|
-
{children}
|
|
29
|
-
</SplitModeStoreContext.Provider>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function useSplitModeStoreContext() {
|
|
34
|
-
const useStore = useContext(SplitModeStoreContext)
|
|
35
|
-
if (!useStore) {
|
|
36
|
-
throw new Error(
|
|
37
|
-
`You forgot to wrap your component in <${SplitModeStoreProvider.name}>.`
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
return useStore
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function useSplitModeStore<T>(
|
|
44
|
-
selector: (state: SplitModeState) => T
|
|
45
|
-
): T {
|
|
46
|
-
const useStore = useSplitModeStoreContext()
|
|
47
|
-
return useStore(useShallow(selector))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const createSplitModeStore = ({ state }: SplitModeProps) =>
|
|
51
|
-
create<SplitModeState>((set) => ({
|
|
52
|
-
state,
|
|
53
|
-
setState(state) {
|
|
54
|
-
set(() => ({
|
|
55
|
-
state,
|
|
56
|
-
}))
|
|
57
|
-
},
|
|
58
|
-
}))
|
|
File without changes
|