@lifi/widget 2.0.0-beta.5 → 2.0.0-beta.7

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.
Files changed (82) hide show
  1. package/App.d.ts +3 -2
  2. package/AppDrawer.js +2 -1
  3. package/AppProvider.js +1 -1
  4. package/cjs/App.d.ts +3 -2
  5. package/cjs/AppDrawer.js +2 -1
  6. package/cjs/AppProvider.js +1 -1
  7. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  8. package/cjs/components/Header/Header.js +2 -2
  9. package/cjs/components/Header/Header.style.js +3 -0
  10. package/cjs/components/Header/NavigationHeader.js +7 -4
  11. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  12. package/cjs/components/Header/NavigationTabs.js +26 -0
  13. package/cjs/components/Header/NavigationTabs.style.d.ts +101 -0
  14. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  15. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  16. package/cjs/components/Header/WalletHeader.js +15 -8
  17. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  18. package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
  19. package/cjs/config/version.d.ts +1 -1
  20. package/cjs/config/version.js +1 -1
  21. package/cjs/hooks/index.d.ts +2 -1
  22. package/cjs/hooks/index.js +2 -1
  23. package/cjs/hooks/useContentHeight.js +3 -5
  24. package/cjs/hooks/useInitializer.js +0 -1
  25. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  26. package/cjs/hooks/useSwapOnly.js +9 -0
  27. package/cjs/hooks/useSwapRoutes.js +3 -1
  28. package/cjs/i18n/en.json +2 -2
  29. package/cjs/i18n/pt.json +19 -4
  30. package/cjs/i18n/uk.json +20 -5
  31. package/cjs/index.d.ts +1 -1
  32. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  33. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  34. package/cjs/stores/StoreProvider.d.ts +2 -2
  35. package/cjs/stores/StoreProvider.js +3 -2
  36. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  37. package/cjs/stores/settings/index.d.ts +1 -0
  38. package/cjs/stores/settings/index.js +1 -0
  39. package/cjs/stores/settings/types.d.ts +11 -0
  40. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  41. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  42. package/cjs/types/widget.d.ts +5 -1
  43. package/cjs/types/widget.js +3 -3
  44. package/components/ChainSelect/useChainSelect.js +7 -1
  45. package/components/Header/Header.js +3 -3
  46. package/components/Header/Header.style.js +3 -0
  47. package/components/Header/NavigationHeader.js +7 -4
  48. package/components/Header/NavigationTabs.d.ts +1 -0
  49. package/components/Header/NavigationTabs.js +22 -0
  50. package/components/Header/NavigationTabs.style.d.ts +101 -0
  51. package/components/Header/NavigationTabs.style.js +58 -0
  52. package/components/Header/WalletHeader.d.ts +1 -0
  53. package/components/Header/WalletHeader.js +12 -6
  54. package/components/Header/useHeaderActionStore.js +0 -1
  55. package/components/SelectTokenButton/SelectTokenButton.js +6 -3
  56. package/config/version.d.ts +1 -1
  57. package/config/version.js +1 -1
  58. package/hooks/index.d.ts +2 -1
  59. package/hooks/index.js +2 -1
  60. package/hooks/useContentHeight.js +4 -6
  61. package/hooks/useInitializer.js +0 -1
  62. package/hooks/useSwapOnly.d.ts +1 -0
  63. package/hooks/useSwapOnly.js +5 -0
  64. package/hooks/useSwapRoutes.js +3 -1
  65. package/i18n/en.json +2 -2
  66. package/i18n/pt.json +19 -4
  67. package/i18n/uk.json +20 -5
  68. package/index.d.ts +1 -1
  69. package/package.json +6 -6
  70. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  71. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  72. package/stores/StoreProvider.d.ts +2 -2
  73. package/stores/StoreProvider.js +3 -2
  74. package/stores/routes/RouteExecutionStore.js +0 -1
  75. package/stores/settings/index.d.ts +1 -0
  76. package/stores/settings/index.js +1 -0
  77. package/stores/settings/types.d.ts +11 -0
  78. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  79. package/stores/settings/useSplitSubvariantStore.js +37 -0
  80. package/tsconfig.cjs.tsbuildinfo +1 -1
  81. package/types/widget.d.ts +5 -1
  82. package/types/widget.js +3 -3
package/cjs/i18n/pt.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "button": {
3
3
  "auto": "Automático",
4
+ "buy": "Comprar",
5
+ "buyNow": "Comprar agora",
4
6
  "cancel": "Cancelar",
5
7
  "connectWallet": "Conectar carteira",
6
8
  "contactSupport": "Falar com o suporte",
@@ -23,6 +25,7 @@
23
25
  "resetSettings": "Redefinir as configurações",
24
26
  "restartSwap": "Reiniciar a conversão",
25
27
  "reviewGasSwap": "Rever o gás de conversão",
28
+ "reviewPurchase": "Revisar compra",
26
29
  "reviewSwap": "Rever conversão",
27
30
  "seeDetails": "Ver detalhes",
28
31
  "showAll": "Mostrar tudo",
@@ -39,10 +42,14 @@
39
42
  },
40
43
  "header": {
41
44
  "activeSwaps": "Conversões ativas",
45
+ "bridge": "Ponte",
42
46
  "checkout": "Finalizar",
43
47
  "from": "Converter a partir de",
44
48
  "gas": "Gás",
45
49
  "gasSwap": "Conversão de gás",
50
+ "payWith": "Pagar com",
51
+ "purchase": "Compra",
52
+ "purchaseDetails": "Detalhes da compra",
46
53
  "routes": "Você recebe",
47
54
  "selectChain": "Selecionar uma rede",
48
55
  "selectWallet": "Selecionar sua carteira",
@@ -75,6 +82,7 @@
75
82
  "currentAmount": "Quantidade atual",
76
83
  "error": {
77
84
  "message": {
85
+ "allowanceRequired": "A quantidade a ser transferida para {{tokenSymbol}} excede a sua permissão atual. Por favor, aumente a sua permissão e tente novamente.",
78
86
  "slippageThreshold": "A derrapagem é maior do que o limite definido. Solicite uma nova rota para obter uma nova cotação.",
79
87
  "transactionFailed": "Por favor, verifique o explorador de blocos para mais informações.",
80
88
  "transactionNotSent": "A transação não foi enviada. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} na {{chainName}} permanece na sua carteira.",
@@ -82,6 +90,7 @@
82
90
  "unknown": "Por favor, tente novamente ou fale com o suporte."
83
91
  },
84
92
  "title": {
93
+ "allowanceRequired": "Permissão insuficiente",
85
94
  "balanceIsTooLow": "O saldo é muito baixo",
86
95
  "chainSwitch": "Necessário mudança de rede",
87
96
  "failed": "Conversão falhou",
@@ -131,7 +140,6 @@
131
140
  "onChain": "em {{nome da rede}}",
132
141
  "otherTokens": "Outros tokens",
133
142
  "ownedBy": "Possuído por",
134
- "payWith": "Pagar com",
135
143
  "process": {
136
144
  "crossChain": {
137
145
  "actionRequired": "Por favor, assine a transação",
@@ -139,6 +147,9 @@
139
147
  "pending": "Aguardando a transação da ponte",
140
148
  "started": "Preparando a transação da ponte"
141
149
  },
150
+ "nft": {
151
+ "done": "NFT comprado"
152
+ },
142
153
  "receivingChain": {
143
154
  "done": "Ponte concluída",
144
155
  "partial": "Ponte parcialmente concluída",
@@ -165,24 +176,27 @@
165
176
  "rateChange": "Alterar taxa",
166
177
  "receiving": "Recebendo",
167
178
  "refuelStepDetails": "Obter gás via {{tool}}",
168
- "routes": "Você recebe",
169
- "selectChain": "Rede",
179
+ "selectChain": "Selecione a rede",
170
180
  "selectChainAndToken": "Selecione a rede e o token",
171
- "selectToken": "Token",
181
+ "selectToken": "Selecione o Token",
172
182
  "sendToAddress": "Enviar para",
173
183
  "sendToWallet": "Enviar para uma carteira diferente",
174
184
  "sentToAddress": "Enviar para",
175
185
  "stepBridge": "Ponte",
186
+ "stepBridgeAndBuy": "Transfira e compre",
176
187
  "stepDetails": "{{tool}} via LI.FI",
177
188
  "stepSwap": "Conversão",
178
189
  "stepSwapAndBridge": "Converter e enviar pela ponte",
190
+ "stepSwapAndBuy": "Converta e compre",
179
191
  "success": {
180
192
  "message": {
181
193
  "swapPartiallySuccessful": "Tentamos completar a conversão, mas a {{tool}} ficou sem liquidez para o token {{tokenSymbol}}.",
194
+ "purchaseSuccessful": "Agora você tem {{assetName}} na carteira {{walletAddress}} na cadeia {{chainName}}",
182
195
  "swapSuccessful": "Agora há {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} na carteira {{walletAddress}} na rede {{chainName}}."
183
196
  },
184
197
  "title": {
185
198
  "gasSwapSuccessful": "Conversão de gás bem sucedida",
199
+ "purchaseSuccessful": "Compra efetuada com sucesso",
186
200
  "refundIssued": "Reembolso emitido",
187
201
  "swapPartiallySuccessful": "Conversão parcialmente bem sucedida",
188
202
  "swapSuccessful": "Conversão bem sucedida"
@@ -237,6 +251,7 @@
237
251
  },
238
252
  "numberOfSteps": "Um número de passos para a conversão. Cada etapa pode conter 1-2 transações que requerem uma assinatura.",
239
253
  "progressToNextUpdate": "Os dados exibidos serão atualizados automaticamente após {{value}} segundos. Clique aqui para atualizar manualmente.",
254
+ "recommended": "Uma rota econômica que equilibra complexidade e facilidade de uso.",
240
255
  "settingsModified": "Configurações (modificado)"
241
256
  },
242
257
  "wallet": {
package/cjs/i18n/uk.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "button": {
3
3
  "auto": "Авто",
4
+ "buy": "Придбати",
5
+ "buyNow": "Придбати",
4
6
  "cancel": "Скасувати",
5
7
  "connectWallet": "Під'єднати гаманець",
6
8
  "contactSupport": "Служба підтримки",
@@ -23,6 +25,7 @@
23
25
  "resetSettings": "Скинути налаштування",
24
26
  "restartSwap": "Перезапустити своп",
25
27
  "reviewGasSwap": "Переглянути своп газу",
28
+ "reviewPurchase": "Перегляд покупки",
26
29
  "reviewSwap": "Переглянути своп",
27
30
  "seeDetails": "Детальніше",
28
31
  "showAll": "Показати всі",
@@ -39,12 +42,16 @@
39
42
  },
40
43
  "header": {
41
44
  "activeSwaps": "Активні свопи",
45
+ "bridge": "Бридж",
42
46
  "checkout": "Розрахунок",
43
47
  "from": "Своп з",
44
48
  "gas": "Газ",
45
49
  "gasSwap": "Своп газу",
50
+ "payWith": "Сплатити за допомогою",
51
+ "purchase": "Купівля",
52
+ "purchaseDetails": "Деталі покупки",
46
53
  "routes": "Ви отримаєте",
47
- "selectChain": "Оберіть чейн",
54
+ "selectChain": "Виберіть чейн",
48
55
  "selectWallet": "Виберіть свій гаманець",
49
56
  "settings": "Налаштування",
50
57
  "swap": "Своп",
@@ -75,6 +82,7 @@
75
82
  "currentAmount": "Поточна сума",
76
83
  "error": {
77
84
  "message": {
85
+ "allowanceRequired": "Сума переказу для {{tokenSymbol}} перевищує поточну межу. Збільшіть доступну кількість у гаманці та спробуйте ще раз.",
78
86
  "slippageThreshold": "Прослизання перевищує визначений поріг. Будь ласка, зробіть запит на новий маршрут, щоб отримати нову пропозицію.",
79
87
  "transactionFailed": "Будь ласка, перевірте провідник блоків для отримання додаткової інформації.",
80
88
  "transactionNotSent": "Транзакція не була відправлена. {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} на {{chainName}} все ще знаходяться у вашому гаманці.",
@@ -82,6 +90,7 @@
82
90
  "unknown": "Будь ласка, спробуйте ще раз або зверніться до служби підтримки."
83
91
  },
84
92
  "title": {
93
+ "allowanceRequired": "Недостатня дозволена кількість",
85
94
  "balanceIsTooLow": "Баланс занадто низький",
86
95
  "chainSwitch": "Потрібно переключити чейн.",
87
96
  "failed": "Помилка обміну.",
@@ -131,7 +140,6 @@
131
140
  "onChain": "на {{chainName}}",
132
141
  "otherTokens": "Інші токени",
133
142
  "ownedBy": "Власник",
134
- "payWith": "Оплатити з",
135
143
  "process": {
136
144
  "crossChain": {
137
145
  "actionRequired": "Будь ласка, підпишіть транзакцію",
@@ -139,6 +147,9 @@
139
147
  "pending": "Очікування бридж транзакції",
140
148
  "started": "Підготовка бридж транзакції"
141
149
  },
150
+ "nft": {
151
+ "done": "Придбано NFT"
152
+ },
142
153
  "receivingChain": {
143
154
  "done": "Бридж завершено",
144
155
  "partial": "Бридж частково завершено",
@@ -165,24 +176,27 @@
165
176
  "rateChange": "Зміна курсу",
166
177
  "receiving": "Отримання",
167
178
  "refuelStepDetails": "Отримати газ через {{tool}}",
168
- "routes": "Ви отримаєте",
169
- "selectChain": "Чейн",
179
+ "selectChain": "Виберіть чейн",
170
180
  "selectChainAndToken": "Виберіть чейн і токен",
171
- "selectToken": "Токен",
181
+ "selectToken": "Виберіть токен",
172
182
  "sendToAddress": "Відправити на {{address}}",
173
183
  "sendToWallet": "Надіслати на інший гаманець",
174
184
  "sentToAddress": "Відправлено на {{address}}",
175
185
  "stepBridge": "Бридж",
186
+ "stepBridgeAndBuy": "Бридж та покупка",
176
187
  "stepDetails": "{{tool}} через LI.FI",
177
188
  "stepSwap": "Своп",
178
189
  "stepSwapAndBridge": "Своп та бридж",
190
+ "stepSwapAndBuy": "Своп та покупка",
179
191
  "success": {
180
192
  "message": {
181
193
  "swapPartiallySuccessful": "Ми намагалися завершити своп, але {{tool}} не вистачило ліквідності токену {{tokenSymbol}}.",
194
+ "purchaseSuccessful": "Тепер ви маєте {{assetName}} в {{walletAddress}} гаманці на ланцюжку {{chainName}}.",
182
195
  "swapSuccessful": "Зараз є {{amount, number(maximumFractionDigits: 9)}} {{tokenSymbol}} у гаманці {{walletAddress}} на чейні {{chainName}}."
183
196
  },
184
197
  "title": {
185
198
  "gasSwapSuccessful": "Своп газу успішний",
199
+ "purchaseSuccessful": "Покупка успішна",
186
200
  "refundIssued": "Здійснено повернення коштів",
187
201
  "swapPartiallySuccessful": "Своп частково успішний",
188
202
  "swapSuccessful": "Своп успішний"
@@ -237,6 +251,7 @@
237
251
  },
238
252
  "numberOfSteps": "Кількість кроків свопу. Кожен крок може містити 1-3 транзакції, які потребують підпису.",
239
253
  "progressToNextUpdate": "Зображені дані автоматично оновляться через {{value}} секунд. Натисніть тут, щоб оновити вручну.",
254
+ "recommended": "Дешевий маршрут, який балансує складність і легкість використання.",
240
255
  "settingsModified": "Налаштування (змінено)"
241
256
  },
242
257
  "wallet": {
package/cjs/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export * from './config/version';
6
6
  export { useWidgetEvents, widgetEvents } from './hooks';
7
7
  export { useWallet } from './providers/WalletProvider';
8
8
  export * from './types';
9
- export declare const LiFiWidget: import("react").FC<import("./types").WidgetProps>;
9
+ export declare const LiFiWidget: import("react").ForwardRefExoticComponent<import("./types").WidgetDrawerProps & import("./types").WidgetConfig & import("./types").WidgetConfigPartialProps & import("react").RefAttributes<import("./AppDrawer").WidgetDrawer>>;
@@ -15,9 +15,11 @@ const SelectTokenPage = ({ formType }) => {
15
15
  const headerRef = (0, react_1.useRef)(null);
16
16
  const contentHeight = (0, hooks_1.useContentHeight)();
17
17
  const [tokenListHeight, setTokenListHeight] = (0, react_1.useState)(0);
18
+ const swapOnly = (0, hooks_1.useSwapOnly)();
18
19
  (0, react_1.useLayoutEffect)(() => {
19
20
  setTokenListHeight(Math.max(contentHeight - (headerRef.current?.offsetHeight ?? 0), minTokenListHeight));
20
21
  }, [contentHeight]);
21
- return ((0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: true, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { pt: 1, pb: 2, px: 3, ref: headerRef, children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 2, children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) })] }), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] }));
22
+ const hideChainSelect = swapOnly && formType === 'to';
23
+ return ((0, jsx_runtime_1.jsxs)(material_1.Container, { disableGutters: true, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { pt: 1, pb: 2, px: 3, ref: headerRef, children: [!hideChainSelect ? (0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }) : null, (0, jsx_runtime_1.jsx)(material_1.Box, { mt: !hideChainSelect ? 2 : 0, children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) })] }), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: tokenListHeight, onClick: navigateBack, formType: formType })] }));
22
24
  };
23
25
  exports.SelectTokenPage = SelectTokenPage;
@@ -26,6 +26,7 @@ const FormUpdater = ({ defaultValues }) => {
26
26
  const { isTouched: isToTokenTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.ToToken);
27
27
  const { isTouched: isFromAmountTouched } = getFieldState(SwapFormProvider_1.SwapFormKey.FromAmount);
28
28
  if (!fromChain && !isFromChainTouched && !isFromTokenTouched) {
29
+ resetField(SwapFormProvider_1.SwapFormKey.FromChain, { defaultValue: account.chainId });
29
30
  setValue(SwapFormProvider_1.SwapFormKey.FromChain, account.chainId);
30
31
  setValue(SwapFormProvider_1.SwapFormKey.FromToken, '');
31
32
  if (isFromAmountTouched) {
@@ -33,6 +34,7 @@ const FormUpdater = ({ defaultValues }) => {
33
34
  }
34
35
  }
35
36
  if (!toChain && !isToChainTouched && !isToTokenTouched) {
37
+ resetField(SwapFormProvider_1.SwapFormKey.ToChain, { defaultValue: account.chainId });
36
38
  setValue(SwapFormProvider_1.SwapFormKey.ToChain, account.chainId);
37
39
  setValue(SwapFormProvider_1.SwapFormKey.ToToken, '');
38
40
  }
@@ -43,6 +45,7 @@ const FormUpdater = ({ defaultValues }) => {
43
45
  fromChain,
44
46
  getFieldState,
45
47
  getValues,
48
+ resetField,
46
49
  setValue,
47
50
  toChain,
48
51
  ]);
@@ -1,3 +1,3 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import type { PersistStoreProviderProps } from './types';
3
- export declare const StoreProvider: React.FC<PropsWithChildren<PersistStoreProviderProps>>;
2
+ import type { WidgetConfigProps } from '../types';
3
+ export declare const StoreProvider: React.FC<PropsWithChildren<WidgetConfigProps>>;
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StoreProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const routes_1 = require("./routes");
6
- const StoreProvider = ({ children, namePrefix }) => {
7
- return ((0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: namePrefix, children: children }));
6
+ const settings_1 = require("./settings");
7
+ const StoreProvider = ({ children, config, }) => {
8
+ return ((0, jsx_runtime_1.jsx)(settings_1.SplitSubvariantStoreProvider, { state: config.subvariant === 'split' ? 'swap' : undefined, children: (0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, { namePrefix: config?.localStorageKeyPrefix, children: children }) }));
8
9
  };
9
10
  exports.StoreProvider = StoreProvider;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useRouteExecutionStoreContext = exports.useRouteExecutionStore = exports.RouteExecutionStoreProvider = exports.RouteExecutionStoreContext = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- /* eslint-disable no-underscore-dangle */
6
5
  const react_1 = require("react");
7
6
  const createRouteExecutionStore_1 = require("./createRouteExecutionStore");
8
7
  exports.RouteExecutionStoreContext = (0, react_1.createContext)(null);
@@ -3,3 +3,4 @@ export * from './useAppearance';
3
3
  export * from './useSendToWalletStore';
4
4
  export * from './useSettings';
5
5
  export * from './useSettingsStore';
6
+ export * from './useSplitSubvariantStore';
@@ -19,3 +19,4 @@ __exportStar(require("./useAppearance"), exports);
19
19
  __exportStar(require("./useSendToWalletStore"), exports);
20
20
  __exportStar(require("./useSettings"), exports);
21
21
  __exportStar(require("./useSettingsStore"), exports);
22
+ __exportStar(require("./useSplitSubvariantStore"), exports);
@@ -1,4 +1,6 @@
1
1
  import type { Order } from '@lifi/sdk';
2
+ import type { PropsWithChildren } from 'react';
3
+ import type { StoreApi, UseBoundStore } from 'zustand';
2
4
  import type { Appearance, WidgetConfig } from '../../types';
3
5
  export type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
4
6
  export type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
@@ -32,3 +34,12 @@ export interface SendToWalletStore extends SendToWalletState {
32
34
  toggleSendToWallet(): void;
33
35
  setSendToWallet(value: boolean): void;
34
36
  }
37
+ export interface SplitSubvariantState {
38
+ state?: 'swap' | 'bridge';
39
+ setState(state: 'swap' | 'bridge'): void;
40
+ }
41
+ export type SplitSubvariantStore = UseBoundStore<StoreApi<SplitSubvariantState>>;
42
+ export interface SplitSubvariantProps {
43
+ state?: 'swap' | 'bridge';
44
+ }
45
+ export type SplitSubvariantProviderProps = PropsWithChildren<SplitSubvariantProps>;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { SplitSubvariantProps, SplitSubvariantProviderProps, SplitSubvariantState, SplitSubvariantStore } from './types';
3
+ export declare const SplitSubvariantStoreContext: import("react").Context<SplitSubvariantStore | null>;
4
+ export declare function SplitSubvariantStoreProvider({ children, ...props }: SplitSubvariantProviderProps): JSX.Element;
5
+ export declare function useSplitSubvariantStore<T>(selector: (state: SplitSubvariantState) => T, equalityFn?: (left: T, right: T) => boolean): T;
6
+ export declare function useSplitSubvariantStoreContext(): SplitSubvariantStore;
7
+ export declare const createSplitSubvariantStore: ({ state }: SplitSubvariantProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<SplitSubvariantState>>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSplitSubvariantStore = exports.useSplitSubvariantStoreContext = exports.useSplitSubvariantStore = exports.SplitSubvariantStoreProvider = exports.SplitSubvariantStoreContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const zustand_1 = require("zustand");
7
+ exports.SplitSubvariantStoreContext = (0, react_1.createContext)(null);
8
+ const shouldRecreateStore = (store, props) => {
9
+ const { state } = store.getState();
10
+ return (!state && props.state) || (state && !props.state);
11
+ };
12
+ function SplitSubvariantStoreProvider({ children, ...props }) {
13
+ const storeRef = (0, react_1.useRef)();
14
+ if (!storeRef.current || shouldRecreateStore(storeRef.current, props)) {
15
+ storeRef.current = (0, exports.createSplitSubvariantStore)(props);
16
+ }
17
+ return ((0, jsx_runtime_1.jsx)(exports.SplitSubvariantStoreContext.Provider, { value: storeRef.current, children: children }));
18
+ }
19
+ exports.SplitSubvariantStoreProvider = SplitSubvariantStoreProvider;
20
+ function useSplitSubvariantStore(selector, equalityFn) {
21
+ const useStore = (0, react_1.useContext)(exports.SplitSubvariantStoreContext);
22
+ if (!useStore) {
23
+ throw new Error(`You forgot to wrap your component in <${SplitSubvariantStoreProvider.name}>.`);
24
+ }
25
+ return useStore(selector, equalityFn);
26
+ }
27
+ exports.useSplitSubvariantStore = useSplitSubvariantStore;
28
+ function useSplitSubvariantStoreContext() {
29
+ const useStore = (0, react_1.useContext)(exports.SplitSubvariantStoreContext);
30
+ if (!useStore) {
31
+ throw new Error(`You forgot to wrap your component in <${SplitSubvariantStoreProvider.name}>.`);
32
+ }
33
+ return useStore;
34
+ }
35
+ exports.useSplitSubvariantStoreContext = useSplitSubvariantStoreContext;
36
+ const createSplitSubvariantStore = ({ state }) => (0, zustand_1.create)((set) => ({
37
+ state,
38
+ setState(state) {
39
+ set(() => ({
40
+ state,
41
+ }));
42
+ },
43
+ }));
44
+ exports.createSplitSubvariantStore = createSplitSubvariantStore;
@@ -5,6 +5,7 @@ import type { TypographyOptions } from '@mui/material/styles/createTypography';
5
5
  import type { CSSProperties, ReactNode, RefObject } from 'react';
6
6
  import type { LanguageKey, LanguageResources } from '../providers';
7
7
  export type WidgetVariant = 'default' | 'expandable' | 'drawer' | 'refuel' | 'nft';
8
+ export type WidgetSubvariant = 'default' | 'split';
8
9
  export declare enum DisabledUI {
9
10
  FromAmount = "fromAmount",
10
11
  FromToken = "fromToken",
@@ -14,10 +15,12 @@ export declare enum DisabledUI {
14
15
  export type DisabledUIType = `${DisabledUI}`;
15
16
  export declare enum HiddenUI {
16
17
  Appearance = "appearance",
18
+ DrawerButton = "drawerButton",
19
+ History = "history",
17
20
  Language = "language",
18
21
  PoweredBy = "poweredBy",
19
22
  ToAddress = "toAddress",
20
- History = "history"
23
+ WalletMenu = "walletMenu"
21
24
  }
22
25
  export type HiddenUIType = `${HiddenUI}`;
23
26
  export declare enum RequiredUI {
@@ -73,6 +76,7 @@ export interface WidgetConfig {
73
76
  slippage?: number;
74
77
  insurance?: boolean;
75
78
  variant?: WidgetVariant;
79
+ subvariant?: WidgetSubvariant;
76
80
  appearance?: Appearance;
77
81
  theme?: ThemeConfig;
78
82
  containerStyle?: CSSProperties;
@@ -11,12 +11,12 @@ var DisabledUI;
11
11
  var HiddenUI;
12
12
  (function (HiddenUI) {
13
13
  HiddenUI["Appearance"] = "appearance";
14
- // FromAmount = 'fromAmount',
14
+ HiddenUI["DrawerButton"] = "drawerButton";
15
+ HiddenUI["History"] = "history";
15
16
  HiddenUI["Language"] = "language";
16
17
  HiddenUI["PoweredBy"] = "poweredBy";
17
18
  HiddenUI["ToAddress"] = "toAddress";
18
- HiddenUI["History"] = "history";
19
- // ToToken = 'toToken',
19
+ HiddenUI["WalletMenu"] = "walletMenu";
20
20
  })(HiddenUI = exports.HiddenUI || (exports.HiddenUI = {}));
21
21
  var RequiredUI;
22
22
  (function (RequiredUI) {
@@ -1,5 +1,5 @@
1
1
  import { useController, useFormContext } from 'react-hook-form';
2
- import { useChains } from '../../hooks';
2
+ import { useChains, useSwapOnly } from '../../hooks';
3
3
  import { SwapFormKey, SwapFormKeyHelper } from '../../providers';
4
4
  import { useChainOrder } from '../../stores';
5
5
  export const useChainSelect = (formType) => {
@@ -8,6 +8,7 @@ export const useChainSelect = (formType) => {
8
8
  const { setValue } = useFormContext();
9
9
  const { chains, isLoading } = useChains();
10
10
  const [chainOrder, setChainOrder] = useChainOrder();
11
+ const swapOnly = useSwapOnly();
11
12
  const getChains = () => {
12
13
  if (!chains) {
13
14
  return [];
@@ -20,6 +21,11 @@ export const useChainSelect = (formType) => {
20
21
  const setCurrentChain = (chainId) => {
21
22
  onChange(chainId);
22
23
  onBlur();
24
+ if (swapOnly) {
25
+ setValue(SwapFormKeyHelper.getChainKey('to'), chainId, {
26
+ shouldTouch: true,
27
+ });
28
+ }
23
29
  setValue(SwapFormKeyHelper.getTokenKey(formType), '');
24
30
  setValue(SwapFormKeyHelper.getAmountKey(formType), '');
25
31
  setValue(SwapFormKey.TokenSearchFilter, '');
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { useDefaultElementId } from '../../hooks';
4
4
  import { useWidgetConfig } from '../../providers';
5
- import { createElementId, ElementId, stickyHeaderRoutes } from '../../utils';
5
+ import { ElementId, createElementId, stickyHeaderRoutes } from '../../utils';
6
6
  import { Container } from './Header.style';
7
7
  import { NavigationHeader } from './NavigationHeader';
8
8
  import { WalletHeader } from './WalletHeader';
@@ -12,6 +12,6 @@ export const HeaderContainer = ({ children }) => {
12
12
  return (_jsx(Container, { id: createElementId(ElementId.Header, elementId), sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)), children: children }));
13
13
  };
14
14
  export const Header = () => {
15
- const { walletManagement } = useWidgetConfig();
16
- return (_jsxs(HeaderContainer, { children: [!walletManagement ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
15
+ const { walletManagement, subvariant } = useWidgetConfig();
16
+ return (_jsxs(HeaderContainer, { children: [!walletManagement && subvariant !== 'split' ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
17
17
  };
@@ -39,4 +39,7 @@ export const WalletButton = styled(Button)(({ theme }) => ({
39
39
  [`.${buttonClasses.endIcon} > *:nth-of-type(1)`]: {
40
40
  fontSize: '24px',
41
41
  },
42
+ [`.${buttonClasses.startIcon} > *:nth-of-type(1)`]: {
43
+ fontSize: '24px',
44
+ },
42
45
  }));
@@ -10,10 +10,12 @@ import { useWallet, useWidgetConfig } from '../../providers';
10
10
  import { HiddenUI } from '../../types';
11
11
  import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
12
12
  import { HeaderAppBar } from './Header.style';
13
+ import { NavigationTabs } from './NavigationTabs';
14
+ import { WalletMenuButton } from './WalletHeader';
13
15
  import { useHeaderActionStore } from './useHeaderActionStore';
14
16
  export const NavigationHeader = () => {
15
17
  const { t } = useTranslation();
16
- const { variant, hiddenUI } = useWidgetConfig();
18
+ const { variant, subvariant, hiddenUI, walletManagement } = useWidgetConfig();
17
19
  const { navigate, navigateBack } = useNavigateBack();
18
20
  const { account } = useWallet();
19
21
  const { element } = useHeaderActionStore();
@@ -23,6 +25,7 @@ export const NavigationHeader = () => {
23
25
  : pathname;
24
26
  const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
25
27
  const hasPath = navigationRoutesValues.includes(path);
28
+ const splitSubvariant = subvariant === 'split' && !hasPath;
26
29
  const handleHeaderTitle = () => {
27
30
  switch (path) {
28
31
  case navigationRoutes.selectWallet:
@@ -75,7 +78,7 @@ export const NavigationHeader = () => {
75
78
  }
76
79
  }
77
80
  };
78
- return (_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, _jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() }), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
79
- marginRight: -1.25,
80
- }, children: _jsx(SettingsIcon, {}) }) })] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] }));
81
+ return (_jsxs(_Fragment, { children: [_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, splitSubvariant ? (_jsx(Box, { flex: 1, children: !hiddenUI?.includes(HiddenUI.WalletMenu) ? (_jsx(WalletMenuButton, {})) : null })) : (_jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
82
+ marginRight: -1.25,
83
+ }, children: _jsx(SettingsIcon, {}) }) })] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] }), splitSubvariant ? _jsx(NavigationTabs, {}) : null] }));
81
84
  };
@@ -0,0 +1 @@
1
+ export declare const NavigationTabs: () => JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useFormContext } from 'react-hook-form';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { SwapFormKey } from '../../providers';
5
+ import { useSplitSubvariantStore } from '../../stores';
6
+ import { HeaderAppBar } from './Header.style';
7
+ import { NavbarTab, NavbarTabs } from './NavigationTabs.style';
8
+ export const NavigationTabs = () => {
9
+ const { t } = useTranslation();
10
+ const [state, setState] = useSplitSubvariantStore((state) => [
11
+ state.state,
12
+ state.setState,
13
+ ]);
14
+ const { setValue } = useFormContext();
15
+ const handleChange = (_, value) => {
16
+ setValue(SwapFormKey.FromAmount, '');
17
+ setValue(SwapFormKey.FromToken, '');
18
+ setValue(SwapFormKey.ToToken, '');
19
+ setState(value === 0 ? 'swap' : 'bridge');
20
+ };
21
+ return (_jsx(HeaderAppBar, { elevation: 0, sx: { py: 1 }, children: _jsxs(NavbarTabs, { value: state === 'swap' ? 0 : 1, onChange: handleChange, "aria-label": "tabs", indicatorColor: "primary", children: [_jsx(NavbarTab, { label: t('header.swap'), disableRipple: true }), _jsx(NavbarTab, { label: t('header.bridge'), disableRipple: true })] }) }));
22
+ };