@openocean.finance/widget 1.0.9 → 1.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openocean.finance/widget",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
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
6
  "main": "./dist/esm/index.js",
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,7 @@ 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
- // const splitSubvariant = subvariant === 'split' && !hasPath
33
-
32
+ const splitSubvariant = subvariant === 'split' && !hasPath
34
33
  return (
35
34
  <>
36
35
  <HeaderAppBar elevation={0}>
@@ -80,7 +79,14 @@ export const NavigationHeader: React.FC = () => {
80
79
  />
81
80
  </Routes>
82
81
  </HeaderAppBar>
83
- <Box sx={{ display: pathname === navigationRoutes.home ? 'block' : 'none' }}>
82
+ <Box
83
+ sx={{
84
+ display:
85
+ pathname === navigationRoutes.home && splitSubvariant
86
+ ? 'block'
87
+ : 'none',
88
+ }}
89
+ >
84
90
  <NavigationTabs />
85
91
  </Box>
86
92
  </>
@@ -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,19 @@ export const NavigationTabs = () => {
17
20
 
18
21
  useEffect(() => {
19
22
  if (
20
- fromChain !== undefined && fromChain !== null &&
21
- toChain !== undefined && toChain !== null &&
23
+ fromChain !== undefined &&
24
+ fromChain !== null &&
25
+ toChain !== undefined &&
26
+ toChain !== null &&
22
27
  !initialLoadDoneRef.current
23
28
  ) {
24
- const newState: 'swap' | 'bridge' = fromChain === toChain ? 'swap' : 'bridge'
25
- setState(newState)
29
+ if (subvariant === 'bridge') {
30
+ setState('bridge')
31
+ } else {
32
+ const newState: 'swap' | 'bridge' =
33
+ fromChain === toChain ? 'swap' : 'bridge'
34
+ setState(newState)
35
+ }
26
36
  initialLoadDoneRef.current = true
27
37
  }
28
38
  }, [fromChain, toChain, setState])
@@ -49,4 +59,6 @@ export const NavigationTabs = () => {
49
59
  </Tabs>
50
60
  </HeaderAppBar>
51
61
  )
62
+
63
+ // return null
52
64
  }
@@ -1,2 +1,2 @@
1
1
  export const name = '@openocean.finance/widget'
2
- export const version = '1.0.9'
2
+ export const version = '1.0.11'
@@ -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
- : t('header.swap')
37
+ : subvariant === 'bridge'
38
+ ? t('header.bridge')
39
+ : t('header.swap')
37
40
 
38
41
  useHeader(title)
39
42
 
@@ -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 = 'default' | 'split' | 'custom' | 'refuel'
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 {