@lifi/widget 4.0.0-beta.19 → 4.0.0-beta.20
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/components/RouteCard/getMatchingLabels.js +1 -0
- package/dist/esm/components/RouteCard/getMatchingLabels.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/types/widget.d.ts +9 -1
- package/dist/esm/types/widget.d.ts.map +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/package.json +4 -4
- package/src/components/RouteCard/getMatchingLabels.ts +5 -0
- package/src/config/version.ts +1 -1
- package/src/types/widget.ts +9 -0
|
@@ -14,6 +14,7 @@ const getMatchingLabels = (route, routeLabels) => {
|
|
|
14
14
|
if (rule.toTokenAddress?.length) conditions.push(rule.toTokenAddress.includes(route.toToken.address));
|
|
15
15
|
if (rule.fromChainId?.length) conditions.push(rule.fromChainId.includes(route.fromChainId));
|
|
16
16
|
if (rule.toChainId?.length) conditions.push(rule.toChainId.includes(route.toChainId));
|
|
17
|
+
if (rule.match) conditions.push(rule.match(route));
|
|
17
18
|
return conditions.length && conditions.every(Boolean);
|
|
18
19
|
}).map((rule) => rule.label);
|
|
19
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMatchingLabels.js","names":[],"sources":["../../../../src/components/RouteCard/getMatchingLabels.ts"],"sourcesContent":["import type { Route } from '@lifi/sdk'\nimport type { RouteLabel, RouteLabelRule } from '../../types/widget.js'\nimport { getConfigItemSets, isItemAllowedForSets } from '../../utils/item.js'\n\nexport const getMatchingLabels = (\n route: Route,\n routeLabels?: RouteLabelRule[]\n): RouteLabel[] => {\n if (!routeLabels?.length) {\n return []\n }\n\n return routeLabels\n .filter((rule) => {\n const conditions: boolean[] = []\n\n // Check bridge/exchange matches if specified\n if (rule.bridges || rule.exchanges) {\n const toolNames = route.steps.flatMap((step) =>\n step.includedSteps.map((s) => s.tool)\n )\n const bridgesConfigSets = getConfigItemSets(\n rule.bridges,\n (bridges) => new Set(bridges)\n )\n const exchangesConfigSets = getConfigItemSets(\n rule.exchanges,\n (exchanges) => new Set(exchanges)\n )\n conditions.push(\n toolNames.some(\n (toolName) =>\n isItemAllowedForSets(toolName, bridgesConfigSets) &&\n isItemAllowedForSets(toolName, exchangesConfigSets)\n )\n )\n }\n\n // Check token matches if specified\n if (rule.fromTokenAddress?.length) {\n conditions.push(rule.fromTokenAddress.includes(route.fromToken.address))\n }\n\n if (rule.toTokenAddress?.length) {\n conditions.push(rule.toTokenAddress.includes(route.toToken.address))\n }\n\n // Check chain matches if specified\n if (rule.fromChainId?.length) {\n conditions.push(rule.fromChainId.includes(route.fromChainId))\n }\n\n if (rule.toChainId?.length) {\n conditions.push(rule.toChainId.includes(route.toChainId))\n }\n\n // Must have at least one condition and all conditions must be true\n return conditions.length && conditions.every(Boolean)\n })\n .map((rule) => rule.label)\n}\n"],"mappings":";;AAIA,MAAa,qBACX,OACA,gBACiB;CACjB,IAAI,CAAC,aAAa,QAChB,OAAO,EAAE;CAGX,OAAO,YACJ,QAAQ,SAAS;EAChB,MAAM,aAAwB,EAAE;EAGhC,IAAI,KAAK,WAAW,KAAK,WAAW;GAClC,MAAM,YAAY,MAAM,MAAM,SAAS,SACrC,KAAK,cAAc,KAAK,MAAM,EAAE,KAAK,CACtC;GACD,MAAM,oBAAoB,kBACxB,KAAK,UACJ,YAAY,IAAI,IAAI,QAAQ,CAC9B;GACD,MAAM,sBAAsB,kBAC1B,KAAK,YACJ,cAAc,IAAI,IAAI,UAAU,CAClC;GACD,WAAW,KACT,UAAU,MACP,aACC,qBAAqB,UAAU,kBAAkB,IACjD,qBAAqB,UAAU,oBAAoB,CACtD,CACF;;EAIH,IAAI,KAAK,kBAAkB,QACzB,WAAW,KAAK,KAAK,iBAAiB,SAAS,MAAM,UAAU,QAAQ,CAAC;EAG1E,IAAI,KAAK,gBAAgB,QACvB,WAAW,KAAK,KAAK,eAAe,SAAS,MAAM,QAAQ,QAAQ,CAAC;EAItE,IAAI,KAAK,aAAa,QACpB,WAAW,KAAK,KAAK,YAAY,SAAS,MAAM,YAAY,CAAC;EAG/D,IAAI,KAAK,WAAW,QAClB,WAAW,KAAK,KAAK,UAAU,SAAS,MAAM,UAAU,CAAC;EAI3D,OAAO,WAAW,UAAU,WAAW,MAAM,QAAQ;GACrD,CACD,KAAK,SAAS,KAAK,MAAM"}
|
|
1
|
+
{"version":3,"file":"getMatchingLabels.js","names":[],"sources":["../../../../src/components/RouteCard/getMatchingLabels.ts"],"sourcesContent":["import type { Route } from '@lifi/sdk'\nimport type { RouteLabel, RouteLabelRule } from '../../types/widget.js'\nimport { getConfigItemSets, isItemAllowedForSets } from '../../utils/item.js'\n\nexport const getMatchingLabels = (\n route: Route,\n routeLabels?: RouteLabelRule[]\n): RouteLabel[] => {\n if (!routeLabels?.length) {\n return []\n }\n\n return routeLabels\n .filter((rule) => {\n const conditions: boolean[] = []\n\n // Check bridge/exchange matches if specified\n if (rule.bridges || rule.exchanges) {\n const toolNames = route.steps.flatMap((step) =>\n step.includedSteps.map((s) => s.tool)\n )\n const bridgesConfigSets = getConfigItemSets(\n rule.bridges,\n (bridges) => new Set(bridges)\n )\n const exchangesConfigSets = getConfigItemSets(\n rule.exchanges,\n (exchanges) => new Set(exchanges)\n )\n conditions.push(\n toolNames.some(\n (toolName) =>\n isItemAllowedForSets(toolName, bridgesConfigSets) &&\n isItemAllowedForSets(toolName, exchangesConfigSets)\n )\n )\n }\n\n // Check token matches if specified\n if (rule.fromTokenAddress?.length) {\n conditions.push(rule.fromTokenAddress.includes(route.fromToken.address))\n }\n\n if (rule.toTokenAddress?.length) {\n conditions.push(rule.toTokenAddress.includes(route.toToken.address))\n }\n\n // Check chain matches if specified\n if (rule.fromChainId?.length) {\n conditions.push(rule.fromChainId.includes(route.fromChainId))\n }\n\n if (rule.toChainId?.length) {\n conditions.push(rule.toChainId.includes(route.toChainId))\n }\n\n // Evaluate custom match function if specified\n if (rule.match) {\n conditions.push(rule.match(route))\n }\n\n // Must have at least one condition and all conditions must be true\n return conditions.length && conditions.every(Boolean)\n })\n .map((rule) => rule.label)\n}\n"],"mappings":";;AAIA,MAAa,qBACX,OACA,gBACiB;CACjB,IAAI,CAAC,aAAa,QAChB,OAAO,EAAE;CAGX,OAAO,YACJ,QAAQ,SAAS;EAChB,MAAM,aAAwB,EAAE;EAGhC,IAAI,KAAK,WAAW,KAAK,WAAW;GAClC,MAAM,YAAY,MAAM,MAAM,SAAS,SACrC,KAAK,cAAc,KAAK,MAAM,EAAE,KAAK,CACtC;GACD,MAAM,oBAAoB,kBACxB,KAAK,UACJ,YAAY,IAAI,IAAI,QAAQ,CAC9B;GACD,MAAM,sBAAsB,kBAC1B,KAAK,YACJ,cAAc,IAAI,IAAI,UAAU,CAClC;GACD,WAAW,KACT,UAAU,MACP,aACC,qBAAqB,UAAU,kBAAkB,IACjD,qBAAqB,UAAU,oBAAoB,CACtD,CACF;;EAIH,IAAI,KAAK,kBAAkB,QACzB,WAAW,KAAK,KAAK,iBAAiB,SAAS,MAAM,UAAU,QAAQ,CAAC;EAG1E,IAAI,KAAK,gBAAgB,QACvB,WAAW,KAAK,KAAK,eAAe,SAAS,MAAM,QAAQ,QAAQ,CAAC;EAItE,IAAI,KAAK,aAAa,QACpB,WAAW,KAAK,KAAK,YAAY,SAAS,MAAM,YAAY,CAAC;EAG/D,IAAI,KAAK,WAAW,QAClB,WAAW,KAAK,KAAK,UAAU,SAAS,MAAM,UAAU,CAAC;EAI3D,IAAI,KAAK,OACP,WAAW,KAAK,KAAK,MAAM,MAAM,CAAC;EAIpC,OAAO,WAAW,UAAU,WAAW,MAAM,QAAQ;GACrD,CACD,KAAK,SAAS,KAAK,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../../src/config/version.ts"],"sourcesContent":["export const name = '@lifi/widget'\nexport const version = '4.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../../src/config/version.ts"],"sourcesContent":["export const name = '@lifi/widget'\nexport const version = '4.0.0-beta.20'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LanguageKey, LanguageResources } from "../providers/I18nProvider/types.js";
|
|
2
2
|
import { DefaultFieldValues } from "../stores/form/types.js";
|
|
3
|
-
import { BaseToken, ChainType, ContractCall, ExecutionOptions, ExtendedChain, Order, RouteExtended, RouteOptions, SDKConfig, StaticToken, Token } from "@lifi/sdk";
|
|
3
|
+
import { BaseToken, ChainType, ContractCall, ExecutionOptions, ExtendedChain, Order, Route, RouteExtended, RouteOptions, SDKConfig, StaticToken, Token } from "@lifi/sdk";
|
|
4
4
|
import { CSSProperties, FC, PropsWithChildren, ReactNode, RefObject } from "react";
|
|
5
5
|
import { Components, PaletteMode, PaletteOptions, Shape, SxProps, Theme } from "@mui/material";
|
|
6
6
|
import { WidgetProviderProps } from "@lifi/widget-provider";
|
|
@@ -215,6 +215,14 @@ interface RouteLabelRule {
|
|
|
215
215
|
toChainId?: number[];
|
|
216
216
|
fromTokenAddress?: string[];
|
|
217
217
|
toTokenAddress?: string[];
|
|
218
|
+
/**
|
|
219
|
+
* Custom match function evaluated against the route. When provided, its
|
|
220
|
+
* result is AND'd with the other matching criteria — all specified
|
|
221
|
+
* conditions must pass for the label to apply. Use this for matching logic
|
|
222
|
+
* that the built-in fields cannot express (gas costs, step count, route
|
|
223
|
+
* tags, etc.).
|
|
224
|
+
*/
|
|
225
|
+
match?: (route: Route) => boolean;
|
|
218
226
|
}
|
|
219
227
|
type ExplorerUrl = string | {
|
|
220
228
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","names":[],"sources":["../../../src/types/widget.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"widget.d.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;EAmLE,OAAA;AAAA;AAAA,aAGU,aAAA;EACV,MAAA;EACA,SAAA;EACA,OAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","names":[],"sources":["../../../src/types/widget.ts"],"sourcesContent":["import type {\n BaseToken,\n ChainType,\n ContractCall,\n ExecutionOptions,\n ExtendedChain,\n Order,\n RouteExtended,\n RouteOptions,\n SDKConfig,\n StaticToken,\n Token,\n} from '@lifi/sdk'\nimport type { WalletMenuOpenArgs } from '@lifi/wallet-management'\nimport type { WidgetProviderProps } from '@lifi/widget-provider'\nimport type {\n Components,\n PaletteMode,\n PaletteOptions,\n Shape,\n SxProps,\n Theme,\n} from '@mui/material'\nimport type { TypographyVariantsOptions } from '@mui/material/styles'\nimport type {\n CSSProperties,\n FC,\n PropsWithChildren,\n ReactNode,\n RefObject,\n} from 'react'\nimport type {\n LanguageKey,\n LanguageResources,\n} from '../providers/I18nProvider/types.js'\nimport type { DefaultFieldValues } from '../stores/form/types.js'\n\nexport type WidgetVariant = 'compact' | 'wide' | 'drawer'\nexport type WidgetSubvariant = 'default' | 'split' | 'custom' | 'refuel'\nexport type SplitSubvariant = 'bridge' | 'swap'\nexport type SplitSubvariantOptions = {\n defaultTab: SplitSubvariant\n}\nexport type CustomSubvariant = 'checkout' | 'deposit'\nexport type WideSubvariant = {\n disableChainSidebar?: boolean\n}\nexport interface SubvariantOptions {\n /**\n * Configure split subvariant behavior:\n * - 'bridge' | 'swap': Single mode without tabs\n * - { defaultTab: 'bridge' | 'swap' }: Tabs mode with configurable default tab\n */\n split?: SplitSubvariant | SplitSubvariantOptions\n custom?: CustomSubvariant\n wide?: WideSubvariant\n}\n\nexport type Appearance = PaletteMode | 'system'\nexport interface NavigationProps {\n /**\n * If given, uses a negative margin to counteract the padding on sides for navigation elements like icon buttons.\n * @default true\n */\n edge?: boolean\n}\nexport type WidgetThemeComponents = Partial<\n Pick<\n Components<Theme>,\n | 'MuiAppBar'\n | 'MuiAvatar'\n | 'MuiButton'\n | 'MuiCard'\n | 'MuiIconButton'\n | 'MuiInputCard'\n | 'MuiNavigationTabs'\n | 'MuiNavigationTab'\n | 'MuiTabs'\n | 'MuiCheckbox'\n >\n>\n\nexport type WidgetTheme = {\n colorSchemes?: {\n light?: {\n palette: PaletteOptions\n }\n dark?: {\n palette: PaletteOptions\n }\n }\n shape?: Partial<Shape>\n typography?: TypographyVariantsOptions\n components?: WidgetThemeComponents\n container?: CSSProperties\n routesContainer?: CSSProperties\n chainSidebarContainer?: CSSProperties\n header?: CSSProperties\n navigation?: NavigationProps\n}\n\nexport enum DisabledUI {\n FromAmount = 'fromAmount',\n FromToken = 'fromToken',\n ToAddress = 'toAddress',\n ToToken = 'toToken',\n}\nexport type DisabledUIType = `${DisabledUI}`\n\nexport enum HiddenUI {\n Appearance = 'appearance',\n DrawerCloseButton = 'drawerCloseButton',\n History = 'history',\n Language = 'language',\n PoweredBy = 'poweredBy',\n ToAddress = 'toAddress',\n FromToken = 'fromToken',\n ToToken = 'toToken',\n WalletMenu = 'walletMenu',\n IntegratorStepDetails = 'integratorStepDetails',\n ReverseTokensButton = 'reverseTokensButton',\n RouteTokenDescription = 'routeTokenDescription',\n RouteCardPriceImpact = 'routeCardPriceImpact',\n ChainSelect = 'chainSelect',\n BridgesSettings = 'bridgesSettings',\n AddressBookConnectedWallets = 'addressBookConnectedWallets',\n LowAddressActivityConfirmation = 'lowAddressActivityConfirmation',\n GasRefuelMessage = 'gasRefuelMessage',\n SearchTokenInput = 'searchTokenInput',\n InsufficientGasMessage = 'insufficientGasMessage',\n ContactSupport = 'contactSupport',\n HideSmallBalances = 'hideSmallBalances',\n AllNetworks = 'allNetworks',\n}\nexport type HiddenUIType = `${HiddenUI}`\n\nexport enum RequiredUI {\n ToAddress = 'toAddress',\n AccountDeployedMessage = 'accountDeployedMessage',\n}\nexport type RequiredUIType = `${RequiredUI}`\n\nexport type DefaultUI = {\n transactionDetailsExpanded?: boolean\n navigationHeaderTitleNoWrap?: boolean\n}\n\nexport interface WidgetWalletConfig {\n walletEcosystemsOrder?: Record<string, ChainType[]>\n onConnect?(args?: WalletMenuOpenArgs): void\n /**\n * Determines whether the widget should provide partial wallet management functionality.\n *\n * In partial mode, external wallet management will be used for \"opt-out\" providers,\n * while the internal management is applied for any remaining providers that do not opt out.\n * This allows a flexible balance between the integrator's custom wallet menu and the widget's native wallet menu.\n * @default false\n */\n usePartialWalletManagement?: boolean\n /**\n * This option forces the widget to always use internal wallet management ignoring external wallet management contexts\n * @default false\n */\n forceInternalWalletManagement?: boolean\n}\n\nexport interface WidgetSDKConfig\n extends Omit<\n SDKConfig,\n | 'apiKey'\n | 'disableVersionCheck'\n | 'integrator'\n | 'providers'\n | 'routeOptions'\n | 'widgetVersion'\n > {\n routeOptions?: Omit<RouteOptions, 'bridges' | 'exchanges'>\n executionOptions?: Pick<ExecutionOptions, 'updateTransactionRequestHook'>\n}\n\nexport interface WidgetContractTool {\n name: string\n logoURI: string\n}\n\nexport interface CalculateFeeParams {\n fromChain: ExtendedChain\n toChain: ExtendedChain\n fromToken: Token\n toToken: Token\n fromAddress?: string\n toAddress?: string\n fromAmount?: bigint\n toAmount?: bigint\n slippage?: number\n}\n\nexport interface WidgetFeeConfig {\n name?: string\n logoURI?: string\n fee?: number\n /**\n * Whether to show the fee percentage in the fee details.\n * @default false\n */\n showFeePercentage?: boolean\n /**\n * Whether to show a tooltip with the fee details. Requires `name` or `feeTooltipComponent` to be set.\n * @default false\n */\n showFeeTooltip?: boolean\n /**\n * Custom tooltip component to show with the fee details.\n */\n feeTooltipComponent?: ReactNode\n /**\n * Function to calculate fees before fetching quotes.\n * If provided, this function will be used instead of the `fee` parameter.\n * Only one of `fee` or `calculateFee` should be used.\n *\n * @param params Object containing the fee calculation parameters\n * @returns A promise that resolves to the calculated fee as a number (e.g., 0.03 represents a 3% fee)\n */\n calculateFee?(params: CalculateFeeParams): Promise<number | undefined>\n /**\n * @internal\n */\n _vcComponent?: FC<{ route: RouteExtended }>\n}\n\nexport interface ToAddress {\n name?: string\n address: string\n chainType: ChainType\n logoURI?: string\n}\n\nexport interface AllowDeny<T> {\n allow?: T[]\n deny?: T[]\n}\n\nexport type AllowDenySetItem = string | number\nexport interface AllowDenySet {\n allow?: Set<AllowDenySetItem>\n deny?: Set<AllowDenySetItem>\n}\n\nexport type AllowDenySets = {\n from?: AllowDenySet\n to?: AllowDenySet\n} & AllowDenySet\n\nexport type AllowDenyItems<T> = {\n from?: AllowDeny<T>\n to?: AllowDeny<T>\n} & AllowDeny<T>\n\nexport type WidgetChains = {\n types?: AllowDeny<ChainType>\n} & AllowDenyItems<number>\n\nexport type WidgetTokens = {\n featured?: StaticToken[]\n include?: Token[]\n popular?: StaticToken[]\n} & AllowDenyItems<BaseToken>\n\nexport type WidgetLanguages = {\n default?: LanguageKey\n} & AllowDeny<LanguageKey>\n\nexport type PoweredByType = 'default' | 'jumper'\n\nexport interface RouteLabel {\n text: string\n sx?: SxProps<Theme>\n}\n\nexport interface RouteLabelRule {\n label: RouteLabel\n // Matching criteria\n bridges?: AllowDeny<string>\n exchanges?: AllowDeny<string>\n fromChainId?: number[]\n toChainId?: number[]\n fromTokenAddress?: string[]\n toTokenAddress?: string[]\n}\n\nexport type ExplorerUrl =\n | string\n | {\n url: string\n txPath?: string\n addressPath?: string\n }\n\nexport type WidgetProvider = (\n props: PropsWithChildren<WidgetProviderProps>\n) => ReactNode\n\nexport interface WidgetConfig {\n fromChain?: number\n toChain?: number\n fromToken?: string\n toToken?: string\n toAddress?: ToAddress\n toAddresses?: ToAddress[]\n fromAmount?: number | string\n minFromAmountUSD?: number\n toAmount?: number | string\n formUpdateKey?: string\n\n providers?: WidgetProvider[]\n\n contractCalls?: ContractCall[]\n contractComponent?: ReactNode\n contractSecondaryComponent?: ReactNode\n contractCompactComponent?: ReactNode\n contractTool?: WidgetContractTool\n integrator: string\n apiKey?: string\n fee?: number\n feeConfig?: WidgetFeeConfig\n referrer?: string\n\n routePriority?: Order\n slippage?: number\n\n variant?: WidgetVariant\n subvariant?: WidgetSubvariant\n subvariantOptions?: SubvariantOptions\n\n appearance?: Appearance\n theme?: WidgetTheme\n\n disabledUI?: DisabledUIType[]\n hiddenUI?: HiddenUIType[]\n requiredUI?: RequiredUIType[]\n defaultUI?: DefaultUI\n useRecommendedRoute?: boolean\n useRelayerRoutes?: boolean\n\n walletConfig?: WidgetWalletConfig\n sdkConfig?: WidgetSDKConfig\n\n buildUrl?: boolean\n keyPrefix?: string\n\n bridges?: AllowDeny<string>\n exchanges?: AllowDeny<string>\n chains?: WidgetChains\n tokens?: WidgetTokens\n languages?: WidgetLanguages\n languageResources?: LanguageResources\n explorerUrls?: Record<number, ExplorerUrl[]> &\n Partial<Record<'internal', ExplorerUrl[]>>\n poweredBy?: PoweredByType\n\n /**\n * Custom labels/badges to show on routes based on specified rules\n */\n routeLabels?: RouteLabelRule[]\n}\n\nexport interface FormFieldOptions {\n setUrlSearchParam: boolean\n}\n\nexport interface FieldValues\n extends Omit<DefaultFieldValues, 'fromAmount' | 'toAmount' | 'toAddress'> {\n fromAmount?: number | string\n toAmount?: number | string\n toAddress?: ToAddress | string\n}\n\nexport type FieldNames = keyof FieldValues\n\nexport type SetFieldValueFunction = <K extends FieldNames>(\n key: K,\n value: FieldValues[K],\n options?: FormFieldOptions\n) => void\n\nexport type FormState = {\n setFieldValue: SetFieldValueFunction\n}\n\nexport type FormRef = RefObject<FormState | null>\n\nexport interface FormRefProps {\n formRef?: FormRef\n}\n\nexport interface WidgetConfigProps extends FormRefProps {\n config: WidgetConfig\n}\n\nexport interface WidgetConfigPartialProps {\n config?: Partial<WidgetConfig>\n}\n\nexport type WidgetProps = WidgetDrawerProps &\n WidgetConfig &\n WidgetConfigPartialProps &\n FormRefProps\n\nexport interface WidgetDrawerProps extends WidgetConfigPartialProps {\n elementRef?: RefObject<HTMLDivElement>\n open?: boolean\n /**\n * Make sure to make the onClose callback stable (e.g. using useCallback) to avoid causing re-renders of the entire widget\n */\n onClose?(): void\n}\n\nexport enum ExpansionType {\n Routes = 'routes',\n FromChain = 'fromChain',\n ToChain = 'toChain',\n}\n"],"mappings":";AAqGA,IAAY,aAAL,yBAAA,YAAA;CACL,WAAA,gBAAA;CACA,WAAA,eAAA;CACA,WAAA,eAAA;CACA,WAAA,aAAA;;KACD;AAGD,IAAY,WAAL,yBAAA,UAAA;CACL,SAAA,gBAAA;CACA,SAAA,uBAAA;CACA,SAAA,aAAA;CACA,SAAA,cAAA;CACA,SAAA,eAAA;CACA,SAAA,eAAA;CACA,SAAA,eAAA;CACA,SAAA,aAAA;CACA,SAAA,gBAAA;CACA,SAAA,2BAAA;CACA,SAAA,yBAAA;CACA,SAAA,2BAAA;CACA,SAAA,0BAAA;CACA,SAAA,iBAAA;CACA,SAAA,qBAAA;CACA,SAAA,iCAAA;CACA,SAAA,oCAAA;CACA,SAAA,sBAAA;CACA,SAAA,sBAAA;CACA,SAAA,4BAAA;CACA,SAAA,oBAAA;CACA,SAAA,uBAAA;CACA,SAAA,iBAAA;;KACD;AAGD,IAAY,aAAL,yBAAA,YAAA;CACL,WAAA,eAAA;CACA,WAAA,4BAAA;;KACD;AAsRD,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,YAAA;CACA,cAAA,eAAA;CACA,cAAA,aAAA;;KACD"}
|
|
1
|
+
{"version":3,"file":"widget.js","names":[],"sources":["../../../src/types/widget.ts"],"sourcesContent":["import type {\n BaseToken,\n ChainType,\n ContractCall,\n ExecutionOptions,\n ExtendedChain,\n Order,\n Route,\n RouteExtended,\n RouteOptions,\n SDKConfig,\n StaticToken,\n Token,\n} from '@lifi/sdk'\nimport type { WalletMenuOpenArgs } from '@lifi/wallet-management'\nimport type { WidgetProviderProps } from '@lifi/widget-provider'\nimport type {\n Components,\n PaletteMode,\n PaletteOptions,\n Shape,\n SxProps,\n Theme,\n} from '@mui/material'\nimport type { TypographyVariantsOptions } from '@mui/material/styles'\nimport type {\n CSSProperties,\n FC,\n PropsWithChildren,\n ReactNode,\n RefObject,\n} from 'react'\nimport type {\n LanguageKey,\n LanguageResources,\n} from '../providers/I18nProvider/types.js'\nimport type { DefaultFieldValues } from '../stores/form/types.js'\n\nexport type WidgetVariant = 'compact' | 'wide' | 'drawer'\nexport type WidgetSubvariant = 'default' | 'split' | 'custom' | 'refuel'\nexport type SplitSubvariant = 'bridge' | 'swap'\nexport type SplitSubvariantOptions = {\n defaultTab: SplitSubvariant\n}\nexport type CustomSubvariant = 'checkout' | 'deposit'\nexport type WideSubvariant = {\n disableChainSidebar?: boolean\n}\nexport interface SubvariantOptions {\n /**\n * Configure split subvariant behavior:\n * - 'bridge' | 'swap': Single mode without tabs\n * - { defaultTab: 'bridge' | 'swap' }: Tabs mode with configurable default tab\n */\n split?: SplitSubvariant | SplitSubvariantOptions\n custom?: CustomSubvariant\n wide?: WideSubvariant\n}\n\nexport type Appearance = PaletteMode | 'system'\nexport interface NavigationProps {\n /**\n * If given, uses a negative margin to counteract the padding on sides for navigation elements like icon buttons.\n * @default true\n */\n edge?: boolean\n}\nexport type WidgetThemeComponents = Partial<\n Pick<\n Components<Theme>,\n | 'MuiAppBar'\n | 'MuiAvatar'\n | 'MuiButton'\n | 'MuiCard'\n | 'MuiIconButton'\n | 'MuiInputCard'\n | 'MuiNavigationTabs'\n | 'MuiNavigationTab'\n | 'MuiTabs'\n | 'MuiCheckbox'\n >\n>\n\nexport type WidgetTheme = {\n colorSchemes?: {\n light?: {\n palette: PaletteOptions\n }\n dark?: {\n palette: PaletteOptions\n }\n }\n shape?: Partial<Shape>\n typography?: TypographyVariantsOptions\n components?: WidgetThemeComponents\n container?: CSSProperties\n routesContainer?: CSSProperties\n chainSidebarContainer?: CSSProperties\n header?: CSSProperties\n navigation?: NavigationProps\n}\n\nexport enum DisabledUI {\n FromAmount = 'fromAmount',\n FromToken = 'fromToken',\n ToAddress = 'toAddress',\n ToToken = 'toToken',\n}\nexport type DisabledUIType = `${DisabledUI}`\n\nexport enum HiddenUI {\n Appearance = 'appearance',\n DrawerCloseButton = 'drawerCloseButton',\n History = 'history',\n Language = 'language',\n PoweredBy = 'poweredBy',\n ToAddress = 'toAddress',\n FromToken = 'fromToken',\n ToToken = 'toToken',\n WalletMenu = 'walletMenu',\n IntegratorStepDetails = 'integratorStepDetails',\n ReverseTokensButton = 'reverseTokensButton',\n RouteTokenDescription = 'routeTokenDescription',\n RouteCardPriceImpact = 'routeCardPriceImpact',\n ChainSelect = 'chainSelect',\n BridgesSettings = 'bridgesSettings',\n AddressBookConnectedWallets = 'addressBookConnectedWallets',\n LowAddressActivityConfirmation = 'lowAddressActivityConfirmation',\n GasRefuelMessage = 'gasRefuelMessage',\n SearchTokenInput = 'searchTokenInput',\n InsufficientGasMessage = 'insufficientGasMessage',\n ContactSupport = 'contactSupport',\n HideSmallBalances = 'hideSmallBalances',\n AllNetworks = 'allNetworks',\n}\nexport type HiddenUIType = `${HiddenUI}`\n\nexport enum RequiredUI {\n ToAddress = 'toAddress',\n AccountDeployedMessage = 'accountDeployedMessage',\n}\nexport type RequiredUIType = `${RequiredUI}`\n\nexport type DefaultUI = {\n transactionDetailsExpanded?: boolean\n navigationHeaderTitleNoWrap?: boolean\n}\n\nexport interface WidgetWalletConfig {\n walletEcosystemsOrder?: Record<string, ChainType[]>\n onConnect?(args?: WalletMenuOpenArgs): void\n /**\n * Determines whether the widget should provide partial wallet management functionality.\n *\n * In partial mode, external wallet management will be used for \"opt-out\" providers,\n * while the internal management is applied for any remaining providers that do not opt out.\n * This allows a flexible balance between the integrator's custom wallet menu and the widget's native wallet menu.\n * @default false\n */\n usePartialWalletManagement?: boolean\n /**\n * This option forces the widget to always use internal wallet management ignoring external wallet management contexts\n * @default false\n */\n forceInternalWalletManagement?: boolean\n}\n\nexport interface WidgetSDKConfig\n extends Omit<\n SDKConfig,\n | 'apiKey'\n | 'disableVersionCheck'\n | 'integrator'\n | 'providers'\n | 'routeOptions'\n | 'widgetVersion'\n > {\n routeOptions?: Omit<RouteOptions, 'bridges' | 'exchanges'>\n executionOptions?: Pick<ExecutionOptions, 'updateTransactionRequestHook'>\n}\n\nexport interface WidgetContractTool {\n name: string\n logoURI: string\n}\n\nexport interface CalculateFeeParams {\n fromChain: ExtendedChain\n toChain: ExtendedChain\n fromToken: Token\n toToken: Token\n fromAddress?: string\n toAddress?: string\n fromAmount?: bigint\n toAmount?: bigint\n slippage?: number\n}\n\nexport interface WidgetFeeConfig {\n name?: string\n logoURI?: string\n fee?: number\n /**\n * Whether to show the fee percentage in the fee details.\n * @default false\n */\n showFeePercentage?: boolean\n /**\n * Whether to show a tooltip with the fee details. Requires `name` or `feeTooltipComponent` to be set.\n * @default false\n */\n showFeeTooltip?: boolean\n /**\n * Custom tooltip component to show with the fee details.\n */\n feeTooltipComponent?: ReactNode\n /**\n * Function to calculate fees before fetching quotes.\n * If provided, this function will be used instead of the `fee` parameter.\n * Only one of `fee` or `calculateFee` should be used.\n *\n * @param params Object containing the fee calculation parameters\n * @returns A promise that resolves to the calculated fee as a number (e.g., 0.03 represents a 3% fee)\n */\n calculateFee?(params: CalculateFeeParams): Promise<number | undefined>\n /**\n * @internal\n */\n _vcComponent?: FC<{ route: RouteExtended }>\n}\n\nexport interface ToAddress {\n name?: string\n address: string\n chainType: ChainType\n logoURI?: string\n}\n\nexport interface AllowDeny<T> {\n allow?: T[]\n deny?: T[]\n}\n\nexport type AllowDenySetItem = string | number\nexport interface AllowDenySet {\n allow?: Set<AllowDenySetItem>\n deny?: Set<AllowDenySetItem>\n}\n\nexport type AllowDenySets = {\n from?: AllowDenySet\n to?: AllowDenySet\n} & AllowDenySet\n\nexport type AllowDenyItems<T> = {\n from?: AllowDeny<T>\n to?: AllowDeny<T>\n} & AllowDeny<T>\n\nexport type WidgetChains = {\n types?: AllowDeny<ChainType>\n} & AllowDenyItems<number>\n\nexport type WidgetTokens = {\n featured?: StaticToken[]\n include?: Token[]\n popular?: StaticToken[]\n} & AllowDenyItems<BaseToken>\n\nexport type WidgetLanguages = {\n default?: LanguageKey\n} & AllowDeny<LanguageKey>\n\nexport type PoweredByType = 'default' | 'jumper'\n\nexport interface RouteLabel {\n text: string\n sx?: SxProps<Theme>\n}\n\nexport interface RouteLabelRule {\n label: RouteLabel\n // Matching criteria\n bridges?: AllowDeny<string>\n exchanges?: AllowDeny<string>\n fromChainId?: number[]\n toChainId?: number[]\n fromTokenAddress?: string[]\n toTokenAddress?: string[]\n /**\n * Custom match function evaluated against the route. When provided, its\n * result is AND'd with the other matching criteria — all specified\n * conditions must pass for the label to apply. Use this for matching logic\n * that the built-in fields cannot express (gas costs, step count, route\n * tags, etc.).\n */\n match?: (route: Route) => boolean\n}\n\nexport type ExplorerUrl =\n | string\n | {\n url: string\n txPath?: string\n addressPath?: string\n }\n\nexport type WidgetProvider = (\n props: PropsWithChildren<WidgetProviderProps>\n) => ReactNode\n\nexport interface WidgetConfig {\n fromChain?: number\n toChain?: number\n fromToken?: string\n toToken?: string\n toAddress?: ToAddress\n toAddresses?: ToAddress[]\n fromAmount?: number | string\n minFromAmountUSD?: number\n toAmount?: number | string\n formUpdateKey?: string\n\n providers?: WidgetProvider[]\n\n contractCalls?: ContractCall[]\n contractComponent?: ReactNode\n contractSecondaryComponent?: ReactNode\n contractCompactComponent?: ReactNode\n contractTool?: WidgetContractTool\n integrator: string\n apiKey?: string\n fee?: number\n feeConfig?: WidgetFeeConfig\n referrer?: string\n\n routePriority?: Order\n slippage?: number\n\n variant?: WidgetVariant\n subvariant?: WidgetSubvariant\n subvariantOptions?: SubvariantOptions\n\n appearance?: Appearance\n theme?: WidgetTheme\n\n disabledUI?: DisabledUIType[]\n hiddenUI?: HiddenUIType[]\n requiredUI?: RequiredUIType[]\n defaultUI?: DefaultUI\n useRecommendedRoute?: boolean\n useRelayerRoutes?: boolean\n\n walletConfig?: WidgetWalletConfig\n sdkConfig?: WidgetSDKConfig\n\n buildUrl?: boolean\n keyPrefix?: string\n\n bridges?: AllowDeny<string>\n exchanges?: AllowDeny<string>\n chains?: WidgetChains\n tokens?: WidgetTokens\n languages?: WidgetLanguages\n languageResources?: LanguageResources\n explorerUrls?: Record<number, ExplorerUrl[]> &\n Partial<Record<'internal', ExplorerUrl[]>>\n poweredBy?: PoweredByType\n\n /**\n * Custom labels/badges to show on routes based on specified rules\n */\n routeLabels?: RouteLabelRule[]\n}\n\nexport interface FormFieldOptions {\n setUrlSearchParam: boolean\n}\n\nexport interface FieldValues\n extends Omit<DefaultFieldValues, 'fromAmount' | 'toAmount' | 'toAddress'> {\n fromAmount?: number | string\n toAmount?: number | string\n toAddress?: ToAddress | string\n}\n\nexport type FieldNames = keyof FieldValues\n\nexport type SetFieldValueFunction = <K extends FieldNames>(\n key: K,\n value: FieldValues[K],\n options?: FormFieldOptions\n) => void\n\nexport type FormState = {\n setFieldValue: SetFieldValueFunction\n}\n\nexport type FormRef = RefObject<FormState | null>\n\nexport interface FormRefProps {\n formRef?: FormRef\n}\n\nexport interface WidgetConfigProps extends FormRefProps {\n config: WidgetConfig\n}\n\nexport interface WidgetConfigPartialProps {\n config?: Partial<WidgetConfig>\n}\n\nexport type WidgetProps = WidgetDrawerProps &\n WidgetConfig &\n WidgetConfigPartialProps &\n FormRefProps\n\nexport interface WidgetDrawerProps extends WidgetConfigPartialProps {\n elementRef?: RefObject<HTMLDivElement>\n open?: boolean\n /**\n * Make sure to make the onClose callback stable (e.g. using useCallback) to avoid causing re-renders of the entire widget\n */\n onClose?(): void\n}\n\nexport enum ExpansionType {\n Routes = 'routes',\n FromChain = 'fromChain',\n ToChain = 'toChain',\n}\n"],"mappings":";AAsGA,IAAY,aAAL,yBAAA,YAAA;CACL,WAAA,gBAAA;CACA,WAAA,eAAA;CACA,WAAA,eAAA;CACA,WAAA,aAAA;;KACD;AAGD,IAAY,WAAL,yBAAA,UAAA;CACL,SAAA,gBAAA;CACA,SAAA,uBAAA;CACA,SAAA,aAAA;CACA,SAAA,cAAA;CACA,SAAA,eAAA;CACA,SAAA,eAAA;CACA,SAAA,eAAA;CACA,SAAA,aAAA;CACA,SAAA,gBAAA;CACA,SAAA,2BAAA;CACA,SAAA,yBAAA;CACA,SAAA,2BAAA;CACA,SAAA,0BAAA;CACA,SAAA,iBAAA;CACA,SAAA,qBAAA;CACA,SAAA,iCAAA;CACA,SAAA,oCAAA;CACA,SAAA,sBAAA;CACA,SAAA,sBAAA;CACA,SAAA,4BAAA;CACA,SAAA,oBAAA;CACA,SAAA,uBAAA;CACA,SAAA,iBAAA;;KACD;AAGD,IAAY,aAAL,yBAAA,YAAA;CACL,WAAA,eAAA;CACA,WAAA,4BAAA;;KACD;AA8RD,IAAY,gBAAL,yBAAA,eAAA;CACL,cAAA,YAAA;CACA,cAAA,eAAA;CACA,cAAA,aAAA;;KACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.20",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11.14.0",
|
|
36
36
|
"@emotion/styled": "^11.14.1",
|
|
37
|
-
"@lifi/sdk": "^4.0.0-beta.
|
|
37
|
+
"@lifi/sdk": "^4.0.0-beta.11",
|
|
38
38
|
"@mui/icons-material": "^9.0.1",
|
|
39
39
|
"@mui/material": "^9.0.1",
|
|
40
40
|
"@mui/system": "^9.0.1",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"react-intersection-observer": "^10.0.3",
|
|
48
48
|
"react-transition-group": "^4.4.5",
|
|
49
49
|
"zustand": "^5.0.13",
|
|
50
|
-
"@lifi/wallet-management": "4.0.0-beta.
|
|
51
|
-
"@lifi/widget-provider": "4.0.0-beta.
|
|
50
|
+
"@lifi/wallet-management": "4.0.0-beta.20",
|
|
51
|
+
"@lifi/widget-provider": "4.0.0-beta.20"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tanstack/react-query": ">=5.90.0",
|
|
@@ -54,6 +54,11 @@ export const getMatchingLabels = (
|
|
|
54
54
|
conditions.push(rule.toChainId.includes(route.toChainId))
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// Evaluate custom match function if specified
|
|
58
|
+
if (rule.match) {
|
|
59
|
+
conditions.push(rule.match(route))
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
// Must have at least one condition and all conditions must be true
|
|
58
63
|
return conditions.length && conditions.every(Boolean)
|
|
59
64
|
})
|
package/src/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget'
|
|
2
|
-
export const version = '4.0.0-beta.
|
|
2
|
+
export const version = '4.0.0-beta.20'
|
package/src/types/widget.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
ExecutionOptions,
|
|
6
6
|
ExtendedChain,
|
|
7
7
|
Order,
|
|
8
|
+
Route,
|
|
8
9
|
RouteExtended,
|
|
9
10
|
RouteOptions,
|
|
10
11
|
SDKConfig,
|
|
@@ -286,6 +287,14 @@ export interface RouteLabelRule {
|
|
|
286
287
|
toChainId?: number[]
|
|
287
288
|
fromTokenAddress?: string[]
|
|
288
289
|
toTokenAddress?: string[]
|
|
290
|
+
/**
|
|
291
|
+
* Custom match function evaluated against the route. When provided, its
|
|
292
|
+
* result is AND'd with the other matching criteria — all specified
|
|
293
|
+
* conditions must pass for the label to apply. Use this for matching logic
|
|
294
|
+
* that the built-in fields cannot express (gas costs, step count, route
|
|
295
|
+
* tags, etc.).
|
|
296
|
+
*/
|
|
297
|
+
match?: (route: Route) => boolean
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
export type ExplorerUrl =
|