@openocean.finance/widget 1.0.9 → 1.0.10
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/App.js +5 -0
- package/dist/esm/App.js.map +1 -1
- package/dist/esm/components/Header/NavigationHeader.js +8 -3
- package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
- package/dist/esm/components/Header/NavigationTabs.js +16 -5
- package/dist/esm/components/Header/NavigationTabs.js.map +1 -1
- package/dist/esm/pages/MainPage/MainPage.js +3 -1
- package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
- package/dist/esm/types/widget.d.ts +1 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/App.tsx +7 -1
- package/src/components/Header/NavigationHeader.tsx +11 -4
- package/src/components/Header/NavigationTabs.tsx +18 -5
- package/src/pages/MainPage/MainPage.tsx +4 -1
- package/src/types/widget.ts +6 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openocean.finance/widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Openocean 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
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
10
|
"watch": "tsc -w -p ./tsconfig.json",
|
package/src/App.tsx
CHANGED
|
@@ -18,6 +18,13 @@ export const App = forwardRef<WidgetDrawer, WidgetProps>((props, ref) => {
|
|
|
18
18
|
},
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
// config.subvariant = 'bridge'
|
|
23
|
+
// config.subvariantOptions = {
|
|
24
|
+
// custom: 'checkout',
|
|
25
|
+
// split: 'bridge',
|
|
26
|
+
// }
|
|
27
|
+
|
|
21
28
|
return config
|
|
22
29
|
}, [props])
|
|
23
30
|
|
|
@@ -36,7 +43,6 @@ export const App = forwardRef<WidgetDrawer, WidgetProps>((props, ref) => {
|
|
|
36
43
|
</AppProvider>
|
|
37
44
|
)
|
|
38
45
|
}
|
|
39
|
-
|
|
40
46
|
return (
|
|
41
47
|
<AppProvider config={config} formRef={props.formRef}>
|
|
42
48
|
<AppDefault />
|
|
@@ -18,7 +18,7 @@ import { SettingsButton } from './SettingsButton.js'
|
|
|
18
18
|
// import { SplitWalletMenuButton } from './WalletHeader.js'
|
|
19
19
|
|
|
20
20
|
export const NavigationHeader: React.FC = () => {
|
|
21
|
-
const { hiddenUI, variant } = useWidgetConfig()
|
|
21
|
+
const { hiddenUI, variant, subvariant } = useWidgetConfig()
|
|
22
22
|
const { navigateBack } = useNavigateBack()
|
|
23
23
|
// const { account } = useAccount()
|
|
24
24
|
const { element, title } = useHeaderStore((state) => state)
|
|
@@ -29,8 +29,8 @@ export const NavigationHeader: React.FC = () => {
|
|
|
29
29
|
: pathname
|
|
30
30
|
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1)
|
|
31
31
|
const hasPath = navigationRoutesValues.includes(path)
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const splitSubvariant = subvariant === 'split' && !hasPath
|
|
33
|
+
debugger
|
|
34
34
|
return (
|
|
35
35
|
<>
|
|
36
36
|
<HeaderAppBar elevation={0}>
|
|
@@ -80,7 +80,14 @@ export const NavigationHeader: React.FC = () => {
|
|
|
80
80
|
/>
|
|
81
81
|
</Routes>
|
|
82
82
|
</HeaderAppBar>
|
|
83
|
-
<Box
|
|
83
|
+
<Box
|
|
84
|
+
sx={{
|
|
85
|
+
display:
|
|
86
|
+
pathname === navigationRoutes.home && splitSubvariant
|
|
87
|
+
? 'block'
|
|
88
|
+
: 'none',
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
84
91
|
<NavigationTabs />
|
|
85
92
|
</Box>
|
|
86
93
|
</>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
|
+
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
|
|
3
4
|
import { useFieldActions } from '../../stores/form/useFieldActions.js'
|
|
4
5
|
import { useFieldValues } from '../../stores/form/useFieldValues.js'
|
|
5
6
|
import { useSplitSubvariantStore } from '../../stores/settings/useSplitSubvariantStore.js'
|
|
7
|
+
import { HeaderAppBar } from '../Header/Header.style.js'
|
|
6
8
|
import { Tab, Tabs } from '../Tabs/Tabs.style.js'
|
|
7
|
-
import { HeaderAppBar } from './Header.style.js'
|
|
8
9
|
|
|
9
10
|
export const NavigationTabs = () => {
|
|
11
|
+
const { subvariant } = useWidgetConfig()
|
|
12
|
+
|
|
10
13
|
const { t } = useTranslation()
|
|
11
14
|
const [state, setState] = useSplitSubvariantStore((storeState) => [
|
|
12
15
|
storeState.state,
|
|
@@ -17,12 +20,20 @@ export const NavigationTabs = () => {
|
|
|
17
20
|
|
|
18
21
|
useEffect(() => {
|
|
19
22
|
if (
|
|
20
|
-
fromChain !== undefined &&
|
|
21
|
-
|
|
23
|
+
fromChain !== undefined &&
|
|
24
|
+
fromChain !== null &&
|
|
25
|
+
toChain !== undefined &&
|
|
26
|
+
toChain !== null &&
|
|
22
27
|
!initialLoadDoneRef.current
|
|
23
28
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
if (subvariant === 'bridge') {
|
|
30
|
+
debugger
|
|
31
|
+
setState('bridge')
|
|
32
|
+
} else {
|
|
33
|
+
const newState: 'swap' | 'bridge' =
|
|
34
|
+
fromChain === toChain ? 'swap' : 'bridge'
|
|
35
|
+
setState(newState)
|
|
36
|
+
}
|
|
26
37
|
initialLoadDoneRef.current = true
|
|
27
38
|
}
|
|
28
39
|
}, [fromChain, toChain, setState])
|
|
@@ -49,4 +60,6 @@ export const NavigationTabs = () => {
|
|
|
49
60
|
</Tabs>
|
|
50
61
|
</HeaderAppBar>
|
|
51
62
|
)
|
|
63
|
+
|
|
64
|
+
// return null
|
|
52
65
|
}
|
|
@@ -28,12 +28,15 @@ export const MainPage: React.FC = () => {
|
|
|
28
28
|
const subvariantState = useSplitSubvariantStore((store) => store.state)
|
|
29
29
|
const custom = subvariant === 'custom'
|
|
30
30
|
const showPoweredBy = !hiddenUI?.includes(HiddenUI.PoweredBy)
|
|
31
|
+
|
|
31
32
|
const title =
|
|
32
33
|
subvariant === 'custom'
|
|
33
34
|
? t(`header.${subvariantOptions?.custom ?? 'checkout'}`)
|
|
34
35
|
: subvariant === 'refuel'
|
|
35
36
|
? t('header.gas')
|
|
36
|
-
:
|
|
37
|
+
: subvariant === 'bridge'
|
|
38
|
+
? t('header.bridge')
|
|
39
|
+
: t('header.swap')
|
|
37
40
|
|
|
38
41
|
useHeader(title)
|
|
39
42
|
|
package/src/types/widget.ts
CHANGED
|
@@ -35,7 +35,12 @@ import type {
|
|
|
35
35
|
import type { DefaultFieldValues } from '../stores/form/types.js'
|
|
36
36
|
|
|
37
37
|
export type WidgetVariant = 'compact' | 'wide' | 'drawer'
|
|
38
|
-
export type WidgetSubvariant =
|
|
38
|
+
export type WidgetSubvariant =
|
|
39
|
+
| 'default'
|
|
40
|
+
| 'bridge'
|
|
41
|
+
| 'split'
|
|
42
|
+
| 'custom'
|
|
43
|
+
| 'refuel'
|
|
39
44
|
export type SplitSubvariant = 'bridge' | 'swap'
|
|
40
45
|
export type CustomSubvariant = 'checkout' | 'deposit'
|
|
41
46
|
export interface SubvariantOptions {
|