@lifi/widget 1.28.3 → 1.29.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/AppDrawer.style.d.ts +1 -1
- package/AppProvider.js +2 -2
- package/cjs/AppDrawer.style.d.ts +1 -1
- package/cjs/AppProvider.js +2 -2
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/cjs/components/AppContainer.d.ts +2 -2
- package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/cjs/components/Card/Card.d.ts +5 -3
- package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +7 -5
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +2 -2
- package/cjs/components/Header/Header.style.d.ts +3 -3
- package/cjs/components/Header/useHeaderActionStore.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/cjs/components/Select.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/cjs/components/SmallAvatar.d.ts +2 -2
- package/cjs/components/Step/CircularProgress.d.ts +0 -1
- package/cjs/components/Step/CircularProgress.style.d.ts +2 -2
- package/cjs/components/Step/StepList.d.ts +0 -1
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +6 -6
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/cjs/components/Switch.js +1 -1
- package/cjs/components/Token/Token.style.d.ts +4 -4
- package/cjs/components/Token/Token.style.js +3 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.d.ts +4 -4
- package/cjs/config/theme.js +22 -27
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +2 -3
- package/cjs/hooks/useRouteExecution.js +5 -4
- package/cjs/hooks/useTools.js +2 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +1 -1
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +1 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +4 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +1 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +3 -2
- package/cjs/stores/StoreProvider.d.ts +3 -0
- package/cjs/stores/StoreProvider.js +13 -0
- package/cjs/stores/chains/ChainOrderStore.d.ts +9 -0
- package/cjs/stores/chains/ChainOrderStore.js +44 -0
- package/cjs/stores/chains/createChainOrderStore.d.ts +4 -0
- package/cjs/stores/chains/{useChainOrderStore.js → createChainOrderStore.js} +4 -4
- package/cjs/stores/chains/index.d.ts +2 -1
- package/cjs/stores/chains/index.js +2 -1
- package/cjs/stores/chains/types.d.ts +2 -2
- package/cjs/stores/chains/useChainOrder.js +2 -2
- package/cjs/stores/index.d.ts +1 -0
- package/cjs/stores/index.js +1 -0
- package/cjs/stores/routes/RouteExecutionStore.d.ts +9 -0
- package/cjs/stores/routes/RouteExecutionStore.js +44 -0
- package/cjs/stores/routes/createRouteExecutionStore.d.ts +3 -0
- package/cjs/stores/routes/{useRouteExecutionStore.js → createRouteExecutionStore.js} +6 -4
- package/cjs/stores/routes/index.d.ts +1 -1
- package/cjs/stores/routes/index.js +1 -1
- package/cjs/stores/routes/types.d.ts +5 -5
- package/cjs/stores/routes/useExecutingRoutesIds.js +3 -3
- package/cjs/stores/routes/useRecommendedRouteStore.js +1 -1
- package/cjs/stores/routes/useSetExecutableRoute.js +2 -2
- package/cjs/stores/routes/useSwapHistory.js +3 -3
- package/cjs/stores/settings/SettingsStore.d.ts +11 -0
- package/cjs/stores/settings/SettingsStore.js +58 -0
- package/cjs/stores/settings/createSettingsStore.d.ts +5 -0
- package/cjs/stores/settings/{useSettingsStore.js → createSettingsStore.js} +4 -19
- package/cjs/stores/settings/index.d.ts +1 -1
- package/cjs/stores/settings/index.js +1 -1
- package/cjs/stores/settings/types.d.ts +4 -4
- package/cjs/stores/settings/useAppearance.js +2 -2
- package/cjs/stores/settings/useSendToWalletStore.js +1 -1
- package/cjs/stores/settings/useSettings.js +3 -3
- package/cjs/stores/types.d.ts +5 -0
- package/cjs/stores/types.js +2 -0
- package/cjs/types/widget.d.ts +1 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/components/AppContainer.d.ts +2 -2
- package/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/components/Card/Card.d.ts +5 -3
- package/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/components/ChainSelect/ChainSelect.style.d.ts +7 -5
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts +2 -2
- package/components/Header/Header.style.d.ts +3 -3
- package/components/Header/useHeaderActionStore.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/Select.d.ts +1 -1
- package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/components/SmallAvatar.d.ts +2 -2
- package/components/Step/CircularProgress.d.ts +0 -1
- package/components/Step/CircularProgress.style.d.ts +2 -2
- package/components/Step/StepList.d.ts +0 -1
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCard.style.js +1 -1
- package/components/SwapRoutes/SwapRoutes.style.d.ts +6 -6
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/components/Switch.js +1 -1
- package/components/Token/Token.style.d.ts +4 -4
- package/components/Token/Token.style.js +4 -2
- package/components/TokenAvatar/TokenAvatar.style.d.ts +4 -4
- package/config/theme.js +22 -27
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +3 -4
- package/hooks/useRouteExecution.js +6 -5
- package/hooks/useTools.js +3 -2
- package/package.json +13 -13
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +1 -1
- package/pages/SettingsPage/EnabledExchangesSelect.js +1 -1
- package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +3 -3
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +4 -4
- package/providers/WalletProvider/WalletProvider.js +1 -1
- package/providers/WidgetProvider/WidgetProvider.js +4 -3
- package/stores/StoreProvider.d.ts +3 -0
- package/stores/StoreProvider.js +9 -0
- package/stores/chains/ChainOrderStore.d.ts +9 -0
- package/stores/chains/ChainOrderStore.js +38 -0
- package/stores/chains/createChainOrderStore.d.ts +4 -0
- package/stores/chains/{useChainOrderStore.js → createChainOrderStore.js} +3 -4
- package/stores/chains/index.d.ts +2 -1
- package/stores/chains/index.js +2 -1
- package/stores/chains/types.d.ts +2 -2
- package/stores/chains/useChainOrder.js +2 -2
- package/stores/index.d.ts +1 -0
- package/stores/index.js +1 -0
- package/stores/routes/RouteExecutionStore.d.ts +9 -0
- package/stores/routes/RouteExecutionStore.js +38 -0
- package/stores/routes/createRouteExecutionStore.d.ts +3 -0
- package/stores/routes/{useRouteExecutionStore.js → createRouteExecutionStore.js} +5 -4
- package/stores/routes/index.d.ts +1 -1
- package/stores/routes/index.js +1 -1
- package/stores/routes/types.d.ts +5 -5
- package/stores/routes/useExecutingRoutesIds.js +2 -2
- package/stores/routes/useRecommendedRouteStore.js +1 -1
- package/stores/routes/useSetExecutableRoute.js +1 -1
- package/stores/routes/useSwapHistory.js +2 -2
- package/stores/settings/SettingsStore.d.ts +11 -0
- package/stores/settings/SettingsStore.js +51 -0
- package/stores/settings/createSettingsStore.d.ts +5 -0
- package/stores/settings/{useSettingsStore.js → createSettingsStore.js} +3 -18
- package/stores/settings/index.d.ts +1 -1
- package/stores/settings/index.js +1 -1
- package/stores/settings/types.d.ts +4 -4
- package/stores/settings/useAppearance.js +2 -2
- package/stores/settings/useSendToWalletStore.js +1 -1
- package/stores/settings/useSettings.js +2 -2
- package/stores/types.d.ts +5 -0
- package/stores/types.js +1 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +0 -17
- package/cjs/stores/routes/useRouteExecutionStore.d.ts +0 -16
- package/cjs/stores/settings/useSettingsStore.d.ts +0 -44
- package/stores/chains/useChainOrderStore.d.ts +0 -17
- package/stores/routes/useRouteExecutionStore.d.ts +0 -16
- package/stores/settings/useSettingsStore.d.ts +0 -44
|
@@ -5,14 +5,14 @@ export declare const AvatarDefault: import("@emotion/styled").StyledComponent<im
|
|
|
5
5
|
component?: import("react").ElementType<any> | undefined;
|
|
6
6
|
ref?: import("react").Ref<unknown> | undefined;
|
|
7
7
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
-
} &
|
|
8
|
+
} & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
9
9
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
10
|
-
},
|
|
10
|
+
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
11
11
|
export declare const AvatarDefaultContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
12
12
|
children?: import("react").ReactNode;
|
|
13
13
|
component?: import("react").ElementType<any> | undefined;
|
|
14
14
|
ref?: import("react").Ref<unknown> | undefined;
|
|
15
15
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
16
|
-
} &
|
|
16
|
+
} & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
17
17
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
18
|
-
},
|
|
18
|
+
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
package/cjs/config/theme.js
CHANGED
|
@@ -52,6 +52,9 @@ const createTheme = (mode, theme = {}) => {
|
|
|
52
52
|
const contrastButtonColor = (0, styles_1.getContrastRatio)(colors_1.common.white, primaryMainColor) >= 3
|
|
53
53
|
? colors_1.common.white
|
|
54
54
|
: colors_1.common.black;
|
|
55
|
+
const contrastTextButtonColor = (0, styles_1.getContrastRatio)(colors_1.common.white, (0, styles_1.alpha)(primaryMainColor, 0.08)) >= 3
|
|
56
|
+
? colors_1.common.white
|
|
57
|
+
: colors_1.common.black;
|
|
55
58
|
return (0, styles_1.createTheme)({
|
|
56
59
|
typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
|
|
57
60
|
palette: Object.assign(Object.assign(Object.assign(Object.assign({ mode }, palette), (mode === 'light' ? paletteLight : paletteDark)), theme.palette), { primary: {
|
|
@@ -83,14 +86,15 @@ const createTheme = (mode, theme = {}) => {
|
|
|
83
86
|
defaultProps: {
|
|
84
87
|
disableElevation: true,
|
|
85
88
|
},
|
|
86
|
-
styleOverrides:
|
|
89
|
+
styleOverrides: {
|
|
90
|
+
root: {
|
|
87
91
|
borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
|
|
88
92
|
textTransform: 'none',
|
|
89
93
|
fontSize: '1rem',
|
|
90
94
|
[`&.Mui-disabled, &.Mui-disabled:hover`]: {
|
|
91
95
|
color: mode === 'light'
|
|
92
|
-
?
|
|
93
|
-
:
|
|
96
|
+
? (0, styles_1.alpha)(colors_1.common.black, 0.56)
|
|
97
|
+
: (0, styles_1.alpha)(colors_1.common.white, 0.56),
|
|
94
98
|
cursor: 'not-allowed',
|
|
95
99
|
pointerEvents: 'auto',
|
|
96
100
|
},
|
|
@@ -106,39 +110,30 @@ const createTheme = (mode, theme = {}) => {
|
|
|
106
110
|
[`&.${LoadingButton_1.loadingButtonClasses.root}.${LoadingButton_1.loadingButtonClasses.loading}`]: {
|
|
107
111
|
color: 'transparent',
|
|
108
112
|
},
|
|
109
|
-
},
|
|
110
|
-
|
|
113
|
+
},
|
|
114
|
+
text: {
|
|
115
|
+
backgroundColor: mode === 'light'
|
|
116
|
+
? (0, styles_1.alpha)(primaryMainColor, 0.08)
|
|
117
|
+
: (0, styles_1.alpha)(primaryMainColor, 0.42),
|
|
111
118
|
'&:hover': {
|
|
112
|
-
backgroundColor:
|
|
119
|
+
backgroundColor: mode === 'light'
|
|
120
|
+
? (0, styles_1.alpha)(primaryMainColor, 0.12)
|
|
121
|
+
: (0, styles_1.alpha)(primaryMainColor, 0.56),
|
|
113
122
|
},
|
|
114
|
-
|
|
123
|
+
color: mode === 'light' ? primaryMainColor : contrastTextButtonColor,
|
|
124
|
+
},
|
|
125
|
+
contained: {
|
|
115
126
|
'&:hover': {
|
|
116
127
|
color: contrastButtonColor,
|
|
117
128
|
},
|
|
118
|
-
},
|
|
129
|
+
},
|
|
130
|
+
sizeMedium: {
|
|
119
131
|
padding: '10px 14px',
|
|
120
132
|
[`.${DialogActions_1.dialogActionsClasses.root} &`]: {
|
|
121
133
|
padding: '6px 12px',
|
|
122
134
|
},
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
outlined: {
|
|
126
|
-
color: primaryLightColor,
|
|
127
|
-
borderColor: primaryLightColor,
|
|
128
|
-
'&:hover': {
|
|
129
|
-
backgroundColor: (0, styles_1.alpha)(primaryLightColor, 0.08),
|
|
130
|
-
borderColor: primaryLightColor,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
text: {
|
|
134
|
-
backgroundColor: (0, styles_1.lighten)(paletteDark.background.paper, 0.08),
|
|
135
|
-
color: colors_1.common.white,
|
|
136
|
-
'&:hover': {
|
|
137
|
-
backgroundColor: (0, styles_1.lighten)(paletteDark.background.paper, 0.12),
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
}
|
|
141
|
-
: {})),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
142
137
|
},
|
|
143
138
|
MuiIconButton: {
|
|
144
139
|
styleOverrides: {
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.29.0";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/useChains.js
CHANGED
|
@@ -19,12 +19,11 @@ const useChains = () => {
|
|
|
19
19
|
const { disabledChains, chains } = (0, providers_1.useWidgetConfig)();
|
|
20
20
|
const lifi = (0, providers_1.useLiFi)();
|
|
21
21
|
const { getValues, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
22
|
+
const initializeChains = (0, stores_1.useChainOrderStore)((state) => state.initializeChains);
|
|
22
23
|
const { data, isLoading } = (0, react_query_1.useQuery)(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
24
|
const availableChains = yield lifi.getChains();
|
|
24
25
|
const filteredChains = availableChains.filter((chain) => (0, providers_1.isItemAllowed)(chain.id, chains, disabledChains));
|
|
25
|
-
const chainOrder =
|
|
26
|
-
.getState()
|
|
27
|
-
.initializeChains(filteredChains.map((chain) => chain.id));
|
|
26
|
+
const chainOrder = initializeChains(filteredChains.map((chain) => chain.id));
|
|
28
27
|
const [fromChainValue, toChainValue] = getValues([
|
|
29
28
|
providers_1.SwapFormKey.FromChain,
|
|
30
29
|
providers_1.SwapFormKey.ToChain,
|
|
@@ -24,10 +24,11 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
24
24
|
const { account, switchChain } = (0, providers_1.useWallet)();
|
|
25
25
|
const resumedAfterMount = (0, react_1.useRef)(false);
|
|
26
26
|
const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
|
|
27
|
+
const routeExecutionStoreContext = (0, stores_1.useRouteExecutionStoreContext)();
|
|
27
28
|
const routeExecution = (0, stores_1.useRouteExecutionStore)((state) => state.routes[routeId]);
|
|
28
|
-
const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteExecutionStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.
|
|
29
|
+
const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteExecutionStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.shallow);
|
|
29
30
|
const updateCallback = (updatedRoute) => {
|
|
30
|
-
const routeExecution =
|
|
31
|
+
const routeExecution = routeExecutionStoreContext.getState().routes[updatedRoute.id];
|
|
31
32
|
if (!routeExecution) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
@@ -158,7 +159,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
158
159
|
(0, react_1.useEffect)(() => {
|
|
159
160
|
return () => {
|
|
160
161
|
var _a;
|
|
161
|
-
const route = (_a =
|
|
162
|
+
const route = (_a = routeExecutionStoreContext.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
162
163
|
if (!route || !(0, stores_1.isRouteActive)(route)) {
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
@@ -166,7 +167,7 @@ const useRouteExecution = ({ routeId, executeInBackground, onAcceptExchangeRateU
|
|
|
166
167
|
console.log('Move route execution to background.', routeId);
|
|
167
168
|
resumedAfterMount.current = false;
|
|
168
169
|
};
|
|
169
|
-
}, [lifi, routeId]);
|
|
170
|
+
}, [lifi, routeExecutionStoreContext, routeId]);
|
|
170
171
|
return {
|
|
171
172
|
executeRoute,
|
|
172
173
|
restartRoute: restartRouteMutation,
|
package/cjs/hooks/useTools.js
CHANGED
|
@@ -8,9 +8,10 @@ const stores_1 = require("../stores");
|
|
|
8
8
|
const useTools = () => {
|
|
9
9
|
const lifi = (0, providers_1.useLiFi)();
|
|
10
10
|
const { bridges, exchanges } = (0, providers_1.useWidgetConfig)();
|
|
11
|
+
const settingsStoreContext = (0, stores_1.useSettingsStoreContext)();
|
|
11
12
|
const { data } = (0, react_query_1.useQuery)(['tools'], () => lifi.getTools(), {
|
|
12
13
|
onSuccess(data) {
|
|
13
|
-
const { initializeTools } =
|
|
14
|
+
const { initializeTools } = settingsStoreContext.getState();
|
|
14
15
|
initializeTools('Bridges', data.bridges
|
|
15
16
|
.filter((bridge) => (0, providers_1.isItemAllowed)(bridge.key, bridges))
|
|
16
17
|
.map((bridge) => bridge.key));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "success" | "warning" | "error" | "
|
|
5
|
+
color?: "success" | "warning" | "error" | "info" | "primary" | "secondary" | "standard" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -13,7 +13,7 @@ const stores_1 = require("../../stores");
|
|
|
13
13
|
const EnabledBridgesSelect = () => {
|
|
14
14
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
15
15
|
const { tools, formattedTools } = (0, hooks_1.useTools)();
|
|
16
|
-
const [enabledBridges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledBridges, state.setTools], shallow_1.
|
|
16
|
+
const [enabledBridges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledBridges, state.setTools], shallow_1.shallow);
|
|
17
17
|
return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.enabledBridges`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: icons_material_1.KeyboardArrowDown, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
|
|
18
18
|
setTools('Bridges', event.target.value, tools.bridges);
|
|
19
19
|
}, renderValue: (selected) => ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
@@ -13,7 +13,7 @@ const stores_1 = require("../../stores");
|
|
|
13
13
|
const EnabledExchangesSelect = () => {
|
|
14
14
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
15
15
|
const { tools, formattedTools } = (0, hooks_1.useTools)();
|
|
16
|
-
const [enabledExchanges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledExchanges, state.setTools], shallow_1.
|
|
16
|
+
const [enabledExchanges, setTools] = (0, stores_1.useSettingsStore)((state) => [state.enabledExchanges, state.setTools], shallow_1.shallow);
|
|
17
17
|
return (tools === null || tools === void 0 ? void 0 : tools.exchanges.length) ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.enabledExchanges`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledExchanges`), value: enabledExchanges !== null && enabledExchanges !== void 0 ? enabledExchanges : [], onChange: (event) => {
|
|
18
18
|
setTools('Exchanges', event.target.value, tools.exchanges);
|
|
19
19
|
}, MenuProps: { elevation: 2, PaperProps: { sx: { maxHeight: 320 } } }, IconComponent: icons_material_1.KeyboardArrowDown, renderValue: (selected) => ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
@@ -29,7 +29,7 @@ const SwapDetailsPage = () => {
|
|
|
29
29
|
const { t, i18n } = (0, react_i18next_1.useTranslation)();
|
|
30
30
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
31
31
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
32
|
-
const [routeExecution, deleteRoute] = (0, stores_1.useRouteExecutionStore)((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow_1.
|
|
32
|
+
const [routeExecution, deleteRoute] = (0, stores_1.useRouteExecutionStore)((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow_1.shallow);
|
|
33
33
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
34
34
|
const toggleDialog = (0, react_1.useCallback)(() => {
|
|
35
35
|
setOpen((open) => !open);
|
|
@@ -7,17 +7,17 @@ export declare const IconContainer: import("@emotion/styled").StyledComponent<im
|
|
|
7
7
|
component?: import("react").ElementType<any> | undefined;
|
|
8
8
|
ref?: import("react").Ref<unknown> | undefined;
|
|
9
9
|
sx?: import("@mui/material").SxProps<Theme> | undefined;
|
|
10
|
-
} &
|
|
10
|
+
} & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
11
11
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
12
|
-
},
|
|
12
|
+
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
13
13
|
export declare const IconCircle: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
14
14
|
children?: import("react").ReactNode;
|
|
15
15
|
component?: import("react").ElementType<any> | undefined;
|
|
16
16
|
ref?: import("react").Ref<unknown> | undefined;
|
|
17
17
|
sx?: import("@mui/material").SxProps<Theme> | undefined;
|
|
18
|
-
} &
|
|
18
|
+
} & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
19
19
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
-
},
|
|
20
|
+
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
21
21
|
status: StatusColor;
|
|
22
22
|
}, {}, {}>;
|
|
23
23
|
export {};
|
|
@@ -15,7 +15,7 @@ const wallet_management_1 = require("@lifi/wallet-management");
|
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const WidgetProvider_1 = require("../WidgetProvider");
|
|
17
17
|
const stub = () => {
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error(`You forgot to wrap your component in <${exports.WalletProvider.name}>.`);
|
|
19
19
|
};
|
|
20
20
|
const initialContext = {
|
|
21
21
|
connect: stub,
|
|
@@ -25,6 +25,7 @@ const useWidgetConfig = () => (0, react_1.useContext)(WidgetContext);
|
|
|
25
25
|
exports.useWidgetConfig = useWidgetConfig;
|
|
26
26
|
const WidgetProvider = (_a) => {
|
|
27
27
|
var { children } = _a, _b = _a.config, _c = _b === void 0 ? {} : _b, { fromChain, fromToken, toChain, toToken, fromAmount } = _c, config = __rest(_c, ["fromChain", "fromToken", "toChain", "toToken", "fromAmount"]);
|
|
28
|
+
const settingsStoreContext = (0, stores_1.useSettingsStoreContext)();
|
|
28
29
|
const value = (0, react_1.useMemo)(() => {
|
|
29
30
|
var _a, _b, _c, _d, _e, _f;
|
|
30
31
|
try {
|
|
@@ -61,8 +62,8 @@ const WidgetProvider = (_a) => {
|
|
|
61
62
|
}
|
|
62
63
|
}, [config, fromAmount, fromChain, fromToken, toChain, toToken]);
|
|
63
64
|
(0, react_1.useEffect)(() => {
|
|
64
|
-
(0, stores_1.setDefaultSettings)(value);
|
|
65
|
-
}, [value]);
|
|
65
|
+
(0, stores_1.setDefaultSettings)(settingsStoreContext, value);
|
|
66
|
+
}, [settingsStoreContext, value]);
|
|
66
67
|
return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
|
|
67
68
|
};
|
|
68
69
|
exports.WidgetProvider = WidgetProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StoreProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const chains_1 = require("./chains");
|
|
6
|
+
const routes_1 = require("./routes");
|
|
7
|
+
const settings_1 = require("./settings");
|
|
8
|
+
const StoreProvider = ({ children, namePrefix }) => {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(routes_1.RouteExecutionStoreProvider, Object.assign({ namePrefix: namePrefix }, { children: (0, jsx_runtime_1.jsx)(settings_1.SettingsStoreProvider
|
|
10
|
+
// namePrefix={namePrefix}
|
|
11
|
+
, { children: (0, jsx_runtime_1.jsx)(chains_1.ChainOrderStoreProvider, Object.assign({ namePrefix: namePrefix }, { children: children })) }) })));
|
|
12
|
+
};
|
|
13
|
+
exports.StoreProvider = StoreProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand';
|
|
3
|
+
import type { PersistStoreProviderProps } from '../types';
|
|
4
|
+
import type { ChainOrderState } from './types';
|
|
5
|
+
export type ChainOrderStore = UseBoundStore<StoreApi<ChainOrderState>>;
|
|
6
|
+
export declare const ChainOrderStoreContext: import("react").Context<ChainOrderStore | null>;
|
|
7
|
+
export declare function ChainOrderStoreProvider({ children, ...props }: PersistStoreProviderProps): JSX.Element;
|
|
8
|
+
export declare function useChainOrderStore<T>(selector: (state: ChainOrderState) => T, equalityFn?: (left: T, right: T) => boolean): T;
|
|
9
|
+
export declare function useChainOrderStoreContext(): ChainOrderStore;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useChainOrderStoreContext = exports.useChainOrderStore = exports.ChainOrderStoreProvider = exports.ChainOrderStoreContext = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
/* eslint-disable no-underscore-dangle */
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const createChainOrderStore_1 = require("./createChainOrderStore");
|
|
19
|
+
exports.ChainOrderStoreContext = (0, react_1.createContext)(null);
|
|
20
|
+
function ChainOrderStoreProvider(_a) {
|
|
21
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
22
|
+
const storeRef = (0, react_1.useRef)();
|
|
23
|
+
if (!storeRef.current) {
|
|
24
|
+
storeRef.current = (0, createChainOrderStore_1.createChainOrderStore)(props);
|
|
25
|
+
}
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(exports.ChainOrderStoreContext.Provider, Object.assign({ value: storeRef.current }, { children: children })));
|
|
27
|
+
}
|
|
28
|
+
exports.ChainOrderStoreProvider = ChainOrderStoreProvider;
|
|
29
|
+
function useChainOrderStore(selector, equalityFn) {
|
|
30
|
+
const useStore = (0, react_1.useContext)(exports.ChainOrderStoreContext);
|
|
31
|
+
if (!useStore) {
|
|
32
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
33
|
+
}
|
|
34
|
+
return useStore(selector, equalityFn);
|
|
35
|
+
}
|
|
36
|
+
exports.useChainOrderStore = useChainOrderStore;
|
|
37
|
+
function useChainOrderStoreContext() {
|
|
38
|
+
const useStore = (0, react_1.useContext)(exports.ChainOrderStoreContext);
|
|
39
|
+
if (!useStore) {
|
|
40
|
+
throw new Error(`You forgot to wrap your component in <${ChainOrderStoreProvider.name}>.`);
|
|
41
|
+
}
|
|
42
|
+
return useStore;
|
|
43
|
+
}
|
|
44
|
+
exports.useChainOrderStoreContext = useChainOrderStoreContext;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PersistStoreProps } from '../types';
|
|
2
|
+
import type { ChainOrderState } from './types';
|
|
3
|
+
export declare const maxChainToOrder = 9;
|
|
4
|
+
export declare const createChainOrderStore: ({ namePrefix }: PersistStoreProps) => import("zustand").UseBoundStore<import("zustand").StoreApi<ChainOrderState>>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/* eslint-disable no-underscore-dangle */
|
|
3
|
+
exports.createChainOrderStore = exports.maxChainToOrder = void 0;
|
|
5
4
|
const zustand_1 = require("zustand");
|
|
6
5
|
const middleware_1 = require("zustand/middleware");
|
|
7
6
|
exports.maxChainToOrder = 9;
|
|
8
|
-
|
|
7
|
+
const createChainOrderStore = ({ namePrefix }) => (0, zustand_1.create)((0, middleware_1.persist)((set, get) => ({
|
|
9
8
|
chainOrder: [],
|
|
10
9
|
availableChains: [],
|
|
11
10
|
initializeChains: (chainIds) => {
|
|
@@ -47,7 +46,8 @@ exports.useChainOrderStore = (0, zustand_1.default)()((0, middleware_1.persist)(
|
|
|
47
46
|
});
|
|
48
47
|
},
|
|
49
48
|
}), {
|
|
50
|
-
name: 'li.fi-widget-chains-order
|
|
49
|
+
name: `${namePrefix || 'li.fi'}-widget-chains-order`,
|
|
51
50
|
version: 0,
|
|
52
51
|
partialize: (state) => ({ chainOrder: state.chainOrder }),
|
|
53
52
|
}));
|
|
53
|
+
exports.createChainOrderStore = createChainOrderStore;
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ChainOrderStore"), exports);
|
|
18
|
+
__exportStar(require("./createChainOrderStore"), exports);
|
|
17
19
|
__exportStar(require("./types"), exports);
|
|
18
20
|
__exportStar(require("./useChainOrder"), exports);
|
|
19
|
-
__exportStar(require("./useChainOrderStore"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface ChainOrderProps {
|
|
2
2
|
chainOrder: number[];
|
|
3
3
|
availableChains: number[];
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface ChainOrderState extends ChainOrderProps {
|
|
6
6
|
initializeChains(chainIds: number[]): number[];
|
|
7
7
|
setChain(chainId: number): void;
|
|
8
8
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useChainOrder = void 0;
|
|
4
4
|
const shallow_1 = require("zustand/shallow");
|
|
5
|
-
const
|
|
5
|
+
const ChainOrderStore_1 = require("./ChainOrderStore");
|
|
6
6
|
const useChainOrder = () => {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, ChainOrderStore_1.useChainOrderStore)((state) => [state.chainOrder, state.setChain], shallow_1.shallow);
|
|
8
8
|
};
|
|
9
9
|
exports.useChainOrder = useChainOrder;
|
package/cjs/stores/index.d.ts
CHANGED
package/cjs/stores/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand';
|
|
3
|
+
import type { PersistStoreProviderProps } from '../types';
|
|
4
|
+
import type { RouteExecutionState } from './types';
|
|
5
|
+
export type RouteExecutionStore = UseBoundStore<StoreApi<RouteExecutionState>>;
|
|
6
|
+
export declare const RouteExecutionStoreContext: import("react").Context<RouteExecutionStore | null>;
|
|
7
|
+
export declare function RouteExecutionStoreProvider({ children, ...props }: PersistStoreProviderProps): JSX.Element;
|
|
8
|
+
export declare function useRouteExecutionStore<T>(selector: (state: RouteExecutionState) => T, equalityFn?: (left: T, right: T) => boolean): T;
|
|
9
|
+
export declare function useRouteExecutionStoreContext(): RouteExecutionStore;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useRouteExecutionStoreContext = exports.useRouteExecutionStore = exports.RouteExecutionStoreProvider = exports.RouteExecutionStoreContext = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
/* eslint-disable no-underscore-dangle */
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const createRouteExecutionStore_1 = require("./createRouteExecutionStore");
|
|
19
|
+
exports.RouteExecutionStoreContext = (0, react_1.createContext)(null);
|
|
20
|
+
function RouteExecutionStoreProvider(_a) {
|
|
21
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
22
|
+
const storeRef = (0, react_1.useRef)();
|
|
23
|
+
if (!storeRef.current) {
|
|
24
|
+
storeRef.current = (0, createRouteExecutionStore_1.createRouteExecutionStore)(props);
|
|
25
|
+
}
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(exports.RouteExecutionStoreContext.Provider, Object.assign({ value: storeRef.current }, { children: children })));
|
|
27
|
+
}
|
|
28
|
+
exports.RouteExecutionStoreProvider = RouteExecutionStoreProvider;
|
|
29
|
+
function useRouteExecutionStore(selector, equalityFn) {
|
|
30
|
+
const useStore = (0, react_1.useContext)(exports.RouteExecutionStoreContext);
|
|
31
|
+
if (!useStore) {
|
|
32
|
+
throw new Error(`You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`);
|
|
33
|
+
}
|
|
34
|
+
return useStore(selector, equalityFn);
|
|
35
|
+
}
|
|
36
|
+
exports.useRouteExecutionStore = useRouteExecutionStore;
|
|
37
|
+
function useRouteExecutionStoreContext() {
|
|
38
|
+
const useStore = (0, react_1.useContext)(exports.RouteExecutionStoreContext);
|
|
39
|
+
if (!useStore) {
|
|
40
|
+
throw new Error(`You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`);
|
|
41
|
+
}
|
|
42
|
+
return useStore;
|
|
43
|
+
}
|
|
44
|
+
exports.useRouteExecutionStoreContext = useRouteExecutionStoreContext;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createRouteExecutionStore = void 0;
|
|
4
4
|
const zustand_1 = require("zustand");
|
|
5
5
|
const middleware_1 = require("zustand/middleware");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
|
-
|
|
9
|
+
const createRouteExecutionStore = ({ namePrefix }) => (0, zustand_1.create)((0, middleware_1.persist)((set, get) => ({
|
|
10
10
|
routes: {},
|
|
11
11
|
setExecutableRoute: (route) => {
|
|
12
12
|
if (!get().routes[route.id]) {
|
|
@@ -40,7 +40,8 @@ exports.useRouteExecutionStore = (0, zustand_1.default)()((0, middleware_1.persi
|
|
|
40
40
|
}
|
|
41
41
|
const isDone = (0, utils_2.isRouteDone)(route);
|
|
42
42
|
if (isDone) {
|
|
43
|
-
updatedState.routes[route.id].status =
|
|
43
|
+
updatedState.routes[route.id].status =
|
|
44
|
+
types_1.RouteExecutionStatus.Done;
|
|
44
45
|
if ((0, utils_2.isRoutePartiallyDone)(route)) {
|
|
45
46
|
updatedState.routes[route.id].status |=
|
|
46
47
|
types_1.RouteExecutionStatus.Partial;
|
|
@@ -93,7 +94,7 @@ exports.useRouteExecutionStore = (0, zustand_1.default)()((0, middleware_1.persi
|
|
|
93
94
|
};
|
|
94
95
|
}),
|
|
95
96
|
}), {
|
|
96
|
-
name: 'li.fi-widget-routes
|
|
97
|
+
name: `${namePrefix || 'li.fi'}-widget-routes`,
|
|
97
98
|
version: 1,
|
|
98
99
|
partialize: (state) => ({ routes: state.routes }),
|
|
99
100
|
merge: (persistedState, currentState) => {
|
|
@@ -172,3 +173,4 @@ exports.useRouteExecutionStore = (0, zustand_1.default)()((0, middleware_1.persi
|
|
|
172
173
|
return persistedState;
|
|
173
174
|
},
|
|
174
175
|
}));
|
|
176
|
+
exports.createRouteExecutionStore = createRouteExecutionStore;
|