@lifi/widget 1.32.7 → 1.32.8
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/cjs/components/TextFitter/TextFitter.js +9 -3
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/cjs/stores/settings/types.d.ts +2 -2
- package/cjs/stores/settings/useSettingsStore.js +2 -1
- package/components/TextFitter/TextFitter.js +9 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/package.json +6 -5
- package/pages/SettingsPage/ResetSettingsButton.js +3 -1
- package/stores/settings/types.d.ts +2 -2
- package/stores/settings/useSettingsStore.js +2 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -4,6 +4,7 @@ exports.TextFitter = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
7
8
|
const initialState = {
|
|
8
9
|
x: 0,
|
|
9
10
|
y: 0,
|
|
@@ -14,7 +15,13 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
14
15
|
const theme = (0, styles_1.useTheme)();
|
|
15
16
|
const textRef = (0, react_1.useRef)(null);
|
|
16
17
|
const [viewBox, setViewBox] = (0, react_1.useState)(initialState);
|
|
17
|
-
|
|
18
|
+
const [ref] = (0, react_intersection_observer_1.useInView)({
|
|
19
|
+
onChange(inView) {
|
|
20
|
+
if (inView) {
|
|
21
|
+
calculateBox();
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
18
25
|
const calculateBox = (0, react_1.useCallback)(() => {
|
|
19
26
|
if (!textRef.current) {
|
|
20
27
|
return;
|
|
@@ -28,7 +35,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
28
35
|
box.height -= box.height * cropBottom;
|
|
29
36
|
}
|
|
30
37
|
setViewBox(box);
|
|
31
|
-
// setTextRect(textRef.current.getBoundingClientRect());
|
|
32
38
|
onFit?.();
|
|
33
39
|
}, [cropBottom, cropTop, onFit]);
|
|
34
40
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -47,6 +53,6 @@ const TextFitter = ({ children, width = '100%', height, maxHeight, preserveAspec
|
|
|
47
53
|
// ? maxHeight
|
|
48
54
|
// : height
|
|
49
55
|
// }
|
|
50
|
-
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
56
|
+
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, ref: ref, children: (0, jsx_runtime_1.jsx)("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
51
57
|
};
|
|
52
58
|
exports.TextFitter = TextFitter;
|
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.32.
|
|
2
|
+
export declare const version = "1.32.8";
|
package/cjs/config/version.js
CHANGED
|
@@ -7,10 +7,12 @@ const react_1 = require("react");
|
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const Dialog_1 = require("../../components/Dialog");
|
|
9
9
|
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
10
11
|
const stores_1 = require("../../stores");
|
|
11
12
|
const ResetSettingsButton = () => {
|
|
12
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
14
|
const { tools } = (0, hooks_1.useTools)();
|
|
15
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
14
16
|
const resetSettings = (0, stores_1.useSettingsStore)((state) => state.reset);
|
|
15
17
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
16
18
|
const toggleDialog = (0, react_1.useCallback)(() => {
|
|
@@ -18,7 +20,7 @@ const ResetSettingsButton = () => {
|
|
|
18
20
|
}, []);
|
|
19
21
|
const handleReset = () => {
|
|
20
22
|
if (tools) {
|
|
21
|
-
resetSettings(tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
23
|
+
resetSettings(config, tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
22
24
|
}
|
|
23
25
|
toggleDialog();
|
|
24
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Order } from '@lifi/sdk';
|
|
2
|
-
import type { Appearance } from '../../types';
|
|
2
|
+
import type { Appearance, WidgetConfig } from '../../types';
|
|
3
3
|
export type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
|
|
4
4
|
export type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
|
|
5
5
|
export type SettingsToolType = 'Bridges' | 'Exchanges';
|
|
@@ -21,7 +21,7 @@ export interface SettingsState extends SettingsProps {
|
|
|
21
21
|
setValues: ValuesSetter<SettingsProps>;
|
|
22
22
|
initializeTools(toolType: SettingsToolType, tools: string[], reset?: boolean): void;
|
|
23
23
|
setTools(toolType: SettingsToolType, tools: string[], availableTools: string[]): void;
|
|
24
|
-
reset(bridges: string[], exchanges: string[]): void;
|
|
24
|
+
reset(config: WidgetConfig, bridges: string[], exchanges: string[]): void;
|
|
25
25
|
}
|
|
26
26
|
export interface SendToWalletState {
|
|
27
27
|
showSendToWallet: boolean;
|
|
@@ -65,10 +65,11 @@ exports.useSettingsStore = (0, zustand_1.create)((0, middleware_1.persist)((set,
|
|
|
65
65
|
return values;
|
|
66
66
|
}, {}),
|
|
67
67
|
})),
|
|
68
|
-
reset: (bridges, exchanges) => {
|
|
68
|
+
reset: (config, bridges, exchanges) => {
|
|
69
69
|
set(() => ({
|
|
70
70
|
...exports.defaultSettings,
|
|
71
71
|
...exports.defaultConfigurableSettings,
|
|
72
|
+
appearance: config.appearance ?? exports.defaultSettings.appearance,
|
|
72
73
|
}));
|
|
73
74
|
get().initializeTools('Bridges', bridges, true);
|
|
74
75
|
get().initializeTools('Exchanges', exchanges, true);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme } from '@mui/material/styles';
|
|
3
3
|
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useInView } from 'react-intersection-observer';
|
|
4
5
|
const initialState = {
|
|
5
6
|
x: 0,
|
|
6
7
|
y: 0,
|
|
@@ -11,7 +12,13 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
11
12
|
const theme = useTheme();
|
|
12
13
|
const textRef = useRef(null);
|
|
13
14
|
const [viewBox, setViewBox] = useState(initialState);
|
|
14
|
-
|
|
15
|
+
const [ref] = useInView({
|
|
16
|
+
onChange(inView) {
|
|
17
|
+
if (inView) {
|
|
18
|
+
calculateBox();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
15
22
|
const calculateBox = useCallback(() => {
|
|
16
23
|
if (!textRef.current) {
|
|
17
24
|
return;
|
|
@@ -25,7 +32,6 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
25
32
|
box.height -= box.height * cropBottom;
|
|
26
33
|
}
|
|
27
34
|
setViewBox(box);
|
|
28
|
-
// setTextRect(textRef.current.getBoundingClientRect());
|
|
29
35
|
onFit?.();
|
|
30
36
|
}, [cropBottom, cropTop, onFit]);
|
|
31
37
|
useLayoutEffect(() => {
|
|
@@ -44,5 +50,5 @@ export const TextFitter = ({ children, width = '100%', height, maxHeight, preser
|
|
|
44
50
|
// ? maxHeight
|
|
45
51
|
// : height
|
|
46
52
|
// }
|
|
47
|
-
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, children: _jsx("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
53
|
+
preserveAspectRatio: preserveAspectRatio, fill: theme.palette.text.primary, ref: ref, children: _jsx("text", { x: 0, y: 0, style: textStyle, ref: textRef, children: children }) }));
|
|
48
54
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.32.
|
|
2
|
+
export declare const version = "1.32.8";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.32.
|
|
2
|
+
export const version = '1.32.8';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.8",
|
|
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
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@mui/icons-material": "^5.11.11",
|
|
49
49
|
"@mui/lab": "^5.0.0-alpha.121",
|
|
50
50
|
"@mui/material": "^5.11.11",
|
|
51
|
-
"@tanstack/react-query": "^4.
|
|
52
|
-
"@tanstack/react-virtual": "^3.0.0-beta.
|
|
51
|
+
"@tanstack/react-query": "^4.26.0",
|
|
52
|
+
"@tanstack/react-virtual": "^3.0.0-beta.53",
|
|
53
53
|
"big.js": "^6.2.1",
|
|
54
54
|
"i18next": "^22.4.10",
|
|
55
55
|
"i18next-browser-languagedetector": "^7.0.1",
|
|
@@ -57,12 +57,13 @@
|
|
|
57
57
|
"mitt": "^3.0.0",
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0",
|
|
60
|
-
"react-hook-form": "^7.43.
|
|
60
|
+
"react-hook-form": "^7.43.4",
|
|
61
61
|
"react-i18next": "^12.2.0",
|
|
62
|
+
"react-intersection-observer": "^9.4.3",
|
|
62
63
|
"react-router-dom": "^6.8.2",
|
|
63
64
|
"react-timer-hook": "^3.0.5",
|
|
64
65
|
"uuid": "^9.0.0",
|
|
65
|
-
"zustand": "^4.3.
|
|
66
|
+
"zustand": "^4.3.6"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
69
|
"@types/react": "^18.0.0",
|
|
@@ -4,10 +4,12 @@ import { useCallback, useState } from 'react';
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Dialog } from '../../components/Dialog';
|
|
6
6
|
import { useTools } from '../../hooks';
|
|
7
|
+
import { useWidgetConfig } from '../../providers';
|
|
7
8
|
import { useSettingsStore } from '../../stores';
|
|
8
9
|
export const ResetSettingsButton = () => {
|
|
9
10
|
const { t } = useTranslation();
|
|
10
11
|
const { tools } = useTools();
|
|
12
|
+
const config = useWidgetConfig();
|
|
11
13
|
const resetSettings = useSettingsStore((state) => state.reset);
|
|
12
14
|
const [open, setOpen] = useState(false);
|
|
13
15
|
const toggleDialog = useCallback(() => {
|
|
@@ -15,7 +17,7 @@ export const ResetSettingsButton = () => {
|
|
|
15
17
|
}, []);
|
|
16
18
|
const handleReset = () => {
|
|
17
19
|
if (tools) {
|
|
18
|
-
resetSettings(tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
20
|
+
resetSettings(config, tools.bridges.map((tool) => tool.key), tools.exchanges.map((tool) => tool.key));
|
|
19
21
|
}
|
|
20
22
|
toggleDialog();
|
|
21
23
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Order } from '@lifi/sdk';
|
|
2
|
-
import type { Appearance } from '../../types';
|
|
2
|
+
import type { Appearance, WidgetConfig } from '../../types';
|
|
3
3
|
export type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
|
|
4
4
|
export type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
|
|
5
5
|
export type SettingsToolType = 'Bridges' | 'Exchanges';
|
|
@@ -21,7 +21,7 @@ export interface SettingsState extends SettingsProps {
|
|
|
21
21
|
setValues: ValuesSetter<SettingsProps>;
|
|
22
22
|
initializeTools(toolType: SettingsToolType, tools: string[], reset?: boolean): void;
|
|
23
23
|
setTools(toolType: SettingsToolType, tools: string[], availableTools: string[]): void;
|
|
24
|
-
reset(bridges: string[], exchanges: string[]): void;
|
|
24
|
+
reset(config: WidgetConfig, bridges: string[], exchanges: string[]): void;
|
|
25
25
|
}
|
|
26
26
|
export interface SendToWalletState {
|
|
27
27
|
showSendToWallet: boolean;
|
|
@@ -62,10 +62,11 @@ export const useSettingsStore = create(persist((set, get) => ({
|
|
|
62
62
|
return values;
|
|
63
63
|
}, {}),
|
|
64
64
|
})),
|
|
65
|
-
reset: (bridges, exchanges) => {
|
|
65
|
+
reset: (config, bridges, exchanges) => {
|
|
66
66
|
set(() => ({
|
|
67
67
|
...defaultSettings,
|
|
68
68
|
...defaultConfigurableSettings,
|
|
69
|
+
appearance: config.appearance ?? defaultSettings.appearance,
|
|
69
70
|
}));
|
|
70
71
|
get().initializeTools('Bridges', bridges, true);
|
|
71
72
|
get().initializeTools('Exchanges', exchanges, true);
|