@lifi/widget 3.4.3 → 3.5.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/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/_esm/components/AppContainer.js +11 -3
- package/_esm/components/AppContainer.js.map +1 -1
- package/_esm/components/Card/CardIconButton.d.ts +1 -1
- package/_esm/components/Header/WalletMenu.js +5 -1
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Step/Step.js +16 -8
- package/_esm/components/Step/Step.js.map +1 -1
- package/_esm/components/Step/StepProcess.js +3 -1
- package/_esm/components/Step/StepProcess.js.map +1 -1
- package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
- package/_esm/components/Token/Token.js +8 -12
- package/_esm/components/Token/Token.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +4 -1
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenList.style.d.ts +2 -2
- package/_esm/components/TokenList/TokenListItem.js +3 -1
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TransactionDetails.js +5 -11
- package/_esm/components/TransactionDetails.js.map +1 -1
- package/_esm/config/constants.d.ts +2 -1
- package/_esm/config/constants.js +2 -1
- package/_esm/config/constants.js.map +1 -1
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/hooks/useExplorer.d.ts +5 -0
- package/_esm/hooks/useExplorer.js +40 -0
- package/_esm/hooks/useExplorer.js.map +1 -0
- package/_esm/hooks/useProcessMessage.js +3 -7
- package/_esm/hooks/useProcessMessage.js.map +1 -1
- package/_esm/hooks/useRoutes.d.ts +1 -1
- package/_esm/hooks/useRoutes.js +4 -0
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/i18n/bn.json +42 -33
- package/_esm/i18n/de.json +43 -34
- package/_esm/i18n/en.json +16 -11
- package/_esm/i18n/es.json +113 -104
- package/_esm/i18n/fr.json +45 -36
- package/_esm/i18n/hi.json +38 -29
- package/_esm/i18n/id.json +42 -33
- package/_esm/i18n/it.json +43 -34
- package/_esm/i18n/ja.json +45 -36
- package/_esm/i18n/ko.json +43 -34
- package/_esm/i18n/pt.json +45 -36
- package/_esm/i18n/th.json +45 -36
- package/_esm/i18n/tr.json +44 -35
- package/_esm/i18n/uk.json +45 -36
- package/_esm/i18n/vi.json +45 -36
- package/_esm/i18n/zh.json +45 -36
- package/_esm/pages/MainPage/ReviewButton.js +8 -6
- package/_esm/pages/MainPage/ReviewButton.js.map +1 -1
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js +2 -0
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js.map +1 -1
- package/_esm/pages/SendToWallet/BookmarksPage.js +3 -4
- package/_esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js +5 -4
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/RecentWalletsPage.js +3 -4
- package/_esm/pages/SendToWallet/RecentWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToConfiguredWalletPage.js +3 -4
- package/_esm/pages/SendToWallet/SendToConfiguredWalletPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.style.js +3 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.style.js.map +1 -1
- package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js +4 -13
- package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
- package/_esm/pages/TransactionDetailsPage/TransferIdCard.d.ts +5 -0
- package/_esm/pages/TransactionDetailsPage/TransferIdCard.js +32 -0
- package/_esm/pages/TransactionDetailsPage/TransferIdCard.js.map +1 -0
- package/_esm/pages/TransactionPage/StatusBottomSheet.js +2 -2
- package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/_esm/pages/TransactionPage/TransactionPage.js +8 -6
- package/_esm/pages/TransactionPage/TransactionPage.js.map +1 -1
- package/_esm/providers/I18nProvider/I18nProvider.js +2 -0
- package/_esm/providers/I18nProvider/I18nProvider.js.map +1 -1
- package/_esm/providers/I18nProvider/percentFormatter.d.ts +7 -0
- package/_esm/providers/I18nProvider/percentFormatter.js +19 -0
- package/_esm/providers/I18nProvider/percentFormatter.js.map +1 -0
- package/_esm/types/widget.d.ts +1 -0
- package/_esm/utils/elements.d.ts +2 -1
- package/_esm/utils/elements.js +1 -0
- package/_esm/utils/elements.js.map +1 -1
- package/components/AppContainer.tsx +31 -18
- package/components/Header/WalletMenu.tsx +7 -1
- package/components/Step/Step.tsx +16 -11
- package/components/Step/StepProcess.tsx +5 -2
- package/components/Token/Token.tsx +15 -18
- package/components/TokenList/TokenList.tsx +8 -1
- package/components/TokenList/TokenListItem.tsx +4 -1
- package/components/TransactionDetails.tsx +8 -17
- package/config/constants.ts +3 -1
- package/config/version.ts +1 -1
- package/hooks/useExplorer.ts +51 -0
- package/hooks/useProcessMessage.ts +3 -7
- package/hooks/useRoutes.ts +5 -0
- package/i18n/bn.json +42 -33
- package/i18n/de.json +43 -34
- package/i18n/en.json +16 -11
- package/i18n/es.json +113 -104
- package/i18n/fr.json +45 -36
- package/i18n/hi.json +38 -29
- package/i18n/id.json +42 -33
- package/i18n/it.json +43 -34
- package/i18n/ja.json +45 -36
- package/i18n/ko.json +43 -34
- package/i18n/pt.json +45 -36
- package/i18n/th.json +45 -36
- package/i18n/tr.json +44 -35
- package/i18n/uk.json +45 -36
- package/i18n/vi.json +45 -36
- package/i18n/zh.json +45 -36
- package/package.json +12 -12
- package/pages/MainPage/ReviewButton.tsx +8 -6
- package/pages/SelectTokenPage/useTokenListHeight.ts +3 -0
- package/pages/SendToWallet/BookmarksPage.tsx +6 -4
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +8 -7
- package/pages/SendToWallet/RecentWalletsPage.tsx +6 -6
- package/pages/SendToWallet/SendToConfiguredWalletPage.tsx +6 -6
- package/pages/SendToWallet/SendToWalletPage.style.tsx +3 -0
- package/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +5 -34
- package/pages/TransactionDetailsPage/TransferIdCard.tsx +67 -0
- package/pages/TransactionPage/StatusBottomSheet.tsx +9 -3
- package/pages/TransactionPage/TransactionPage.tsx +9 -7
- package/providers/I18nProvider/I18nProvider.tsx +2 -0
- package/providers/I18nProvider/percentFormatter.ts +18 -0
- package/types/widget.ts +1 -1
- package/utils/elements.ts +1 -0
|
@@ -35,7 +35,8 @@ export const TransactionPage: React.FC = () => {
|
|
|
35
35
|
const { setFieldValue } = useFieldActions();
|
|
36
36
|
const emitter = useWidgetEvents();
|
|
37
37
|
const { navigateBack } = useNavigateBack();
|
|
38
|
-
const { subvariant, contractSecondaryComponent } =
|
|
38
|
+
const { subvariant, subvariantOptions, contractSecondaryComponent } =
|
|
39
|
+
useWidgetConfig();
|
|
39
40
|
const { state }: any = useLocation();
|
|
40
41
|
const stateRouteId = state?.routeId;
|
|
41
42
|
const [routeId, setRouteId] = useState<string>(stateRouteId);
|
|
@@ -59,15 +60,14 @@ export const TransactionPage: React.FC = () => {
|
|
|
59
60
|
|
|
60
61
|
const getHeaderTitle = () => {
|
|
61
62
|
if (subvariant === 'custom') {
|
|
62
|
-
return t(`header
|
|
63
|
+
return t(`header.${subvariantOptions?.custom ?? 'checkout'}`);
|
|
63
64
|
} else {
|
|
64
65
|
if (route) {
|
|
65
66
|
const transactionType =
|
|
66
|
-
route.fromChainId === route.toChainId ? '
|
|
67
|
-
|
|
67
|
+
route.fromChainId === route.toChainId ? 'swap' : 'bridge';
|
|
68
68
|
return status === RouteExecutionStatus.Idle
|
|
69
|
-
? t(`button
|
|
70
|
-
: t(`header.${transactionType
|
|
69
|
+
? t(`button.${transactionType}Review`)
|
|
70
|
+
: t(`header.${transactionType}`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -159,7 +159,9 @@ export const TransactionPage: React.FC = () => {
|
|
|
159
159
|
case RouteExecutionStatus.Idle:
|
|
160
160
|
switch (subvariant) {
|
|
161
161
|
case 'custom':
|
|
162
|
-
return
|
|
162
|
+
return subvariantOptions?.custom === 'deposit'
|
|
163
|
+
? t(`button.deposit`)
|
|
164
|
+
: t(`button.buy`);
|
|
163
165
|
case 'refuel':
|
|
164
166
|
return t('button.startBridging');
|
|
165
167
|
default:
|
|
@@ -8,6 +8,7 @@ import { deepMerge } from '../../utils/deepMerge.js';
|
|
|
8
8
|
import { isItemAllowed } from '../../utils/item.js';
|
|
9
9
|
import { useWidgetConfig } from '../WidgetProvider/WidgetProvider.js';
|
|
10
10
|
import { currencyExtendedFormatter } from './currencyExtendedFormatter.js';
|
|
11
|
+
import { percentFormatter } from './percentFormatter.js';
|
|
11
12
|
import type { LanguageKey, LanguageTranslationResources } from './types.js';
|
|
12
13
|
|
|
13
14
|
export const I18nProvider: React.FC<React.PropsWithChildren> = ({
|
|
@@ -66,6 +67,7 @@ export const I18nProvider: React.FC<React.PropsWithChildren> = ({
|
|
|
66
67
|
'currencyExt',
|
|
67
68
|
currencyExtendedFormatter,
|
|
68
69
|
);
|
|
70
|
+
i18n.services.formatter?.addCached('percent', percentFormatter);
|
|
69
71
|
|
|
70
72
|
return i18n;
|
|
71
73
|
}, [language, languageResources, languages]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use <0.01% for both small positive and negative changes to keep it simple and clear, focusing on minimal impact rather than direction.
|
|
3
|
+
* Examples:
|
|
4
|
+
* +0.007% -> <0.01%
|
|
5
|
+
* -0.003% -> <0.01%
|
|
6
|
+
*/
|
|
7
|
+
export const percentFormatter = (lng: string | undefined, options: any) => {
|
|
8
|
+
const formatter = new Intl.NumberFormat(lng, {
|
|
9
|
+
...options,
|
|
10
|
+
style: 'percent',
|
|
11
|
+
});
|
|
12
|
+
return (value: any) => {
|
|
13
|
+
if ((value > 0 && value < 0.0001) || (value < 0 && value > -0.0001)) {
|
|
14
|
+
return `<${formatter.format(0.0001)}`;
|
|
15
|
+
}
|
|
16
|
+
return formatter.format(value);
|
|
17
|
+
};
|
|
18
|
+
};
|
package/types/widget.ts
CHANGED
|
@@ -188,7 +188,6 @@ export interface WidgetConfig {
|
|
|
188
188
|
contractSecondaryComponent?: ReactNode;
|
|
189
189
|
contractCompactComponent?: ReactNode;
|
|
190
190
|
contractTool?: WidgetContractTool;
|
|
191
|
-
|
|
192
191
|
integrator: string;
|
|
193
192
|
apiKey?: string;
|
|
194
193
|
/**
|
|
@@ -225,6 +224,7 @@ export interface WidgetConfig {
|
|
|
225
224
|
tokens?: WidgetTokens;
|
|
226
225
|
languages?: WidgetLanguages;
|
|
227
226
|
languageResources?: LanguageResources;
|
|
227
|
+
explorerUrls?: Record<number | 'internal', string[]>;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
export interface WidgetConfigProps {
|
package/utils/elements.ts
CHANGED