@xylabs/sdk-react 2.9.24 → 2.9.28
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/cjs5/components/MenuEx.d.ts +7 -0
- package/dist/cjs5/components/RedirectWithQuery.d.ts +2 -1
- package/dist/cjs5/components/SelectEx.d.ts +7 -0
- package/dist/cjs5/components/index.d.ts +2 -0
- package/dist/cjs5/index.js +29 -6
- package/dist/cjs5/index.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js +2 -2
- package/dist/components/InvertableThemeProvider/InvertableThemeProvider.js.map +1 -1
- package/dist/components/MenuEx.d.ts +7 -0
- package/dist/components/MenuEx.js +11 -0
- package/dist/components/MenuEx.js.map +1 -0
- package/dist/components/RedirectWithQuery.d.ts +2 -1
- package/dist/components/RedirectWithQuery.js +8 -3
- package/dist/components/RedirectWithQuery.js.map +1 -1
- package/dist/components/SelectEx.d.ts +7 -0
- package/dist/components/SelectEx.js +13 -0
- package/dist/components/SelectEx.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/esm2015/components/MenuEx.d.ts +7 -0
- package/dist/esm2015/components/RedirectWithQuery.d.ts +2 -1
- package/dist/esm2015/components/SelectEx.d.ts +7 -0
- package/dist/esm2015/components/index.d.ts +2 -0
- package/dist/esm2015/index.js +28 -7
- package/dist/esm2015/index.js.map +1 -1
- package/dist/esm2017/components/MenuEx.d.ts +7 -0
- package/dist/esm2017/components/RedirectWithQuery.d.ts +2 -1
- package/dist/esm2017/components/SelectEx.d.ts +7 -0
- package/dist/esm2017/components/index.d.ts +2 -0
- package/dist/esm2017/index.js +28 -7
- package/dist/esm2017/index.js.map +1 -1
- package/dist/esm5/components/MenuEx.d.ts +7 -0
- package/dist/esm5/components/RedirectWithQuery.d.ts +2 -1
- package/dist/esm5/components/SelectEx.d.ts +7 -0
- package/dist/esm5/components/index.d.ts +2 -0
- package/dist/esm5/index.js +28 -7
- package/dist/esm5/index.js.map +1 -1
- package/dist/node/components/MenuEx.d.ts +7 -0
- package/dist/node/components/RedirectWithQuery.d.ts +2 -1
- package/dist/node/components/SelectEx.d.ts +7 -0
- package/dist/node/components/index.d.ts +2 -0
- package/dist/node/index.js +29 -6
- package/dist/node/index.js.map +1 -1
- package/dist/node-esm/components/MenuEx.d.ts +7 -0
- package/dist/node-esm/components/RedirectWithQuery.d.ts +2 -1
- package/dist/node-esm/components/SelectEx.d.ts +7 -0
- package/dist/node-esm/components/index.d.ts +2 -0
- package/dist/node-esm/index.js +28 -7
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/InvertableThemeProvider/InvertableThemeProvider.tsx +2 -2
- package/src/components/MenuEx.tsx +13 -0
- package/src/components/RedirectWithQuery.tsx +9 -4
- package/src/components/SelectEx.tsx +21 -0
- package/src/components/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { responsiveFontSizes, ScopedCssBaseline, Theme, ThemeProvider } from '@mui/material'
|
|
2
2
|
import { createTheme, ThemeOptions } from '@mui/material/styles'
|
|
3
|
-
import
|
|
3
|
+
import cloneDeep from 'lodash/cloneDeep'
|
|
4
4
|
import merge from 'lodash/merge'
|
|
5
5
|
import React, { useContext } from 'react'
|
|
6
6
|
|
|
@@ -31,7 +31,7 @@ export const InvertableThemeProvider: React.FC<InvertableThemeProviderProps> = (
|
|
|
31
31
|
}) => {
|
|
32
32
|
let internalDarkTheme = {}
|
|
33
33
|
const contextInvertableTheme = useContext(InvertableThemeContext)
|
|
34
|
-
const clonedOptions =
|
|
34
|
+
const clonedOptions = cloneDeep(options ?? contextInvertableTheme.options ?? {})
|
|
35
35
|
|
|
36
36
|
clonedOptions.palette = clonedOptions.palette ?? {}
|
|
37
37
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Menu, MenuProps, PaletteMode, useTheme } from '@mui/material'
|
|
2
|
+
import merge from 'lodash/merge'
|
|
3
|
+
|
|
4
|
+
export interface MenuExProps extends MenuProps {
|
|
5
|
+
colorize?: 'primary' | 'secondary'
|
|
6
|
+
mode?: PaletteMode
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MenuEx: React.FC<MenuExProps> = ({ MenuListProps = {}, mode = 'light', colorize, ...props }) => {
|
|
10
|
+
const theme = useTheme()
|
|
11
|
+
const colorizeMenuListProps = colorize ? { sx: { backgroundColor: theme.palette[colorize][mode] } } : {}
|
|
12
|
+
return <Menu MenuListProps={merge(MenuListProps, colorizeMenuListProps)} {...props} />
|
|
13
|
+
}
|
|
@@ -2,18 +2,23 @@ import React, { useEffect } from 'react'
|
|
|
2
2
|
import { NavigateOptions, To, useLocation, useNavigate } from 'react-router-dom'
|
|
3
3
|
|
|
4
4
|
interface RedirectProps {
|
|
5
|
-
to
|
|
5
|
+
to?: To
|
|
6
6
|
toOptions?: NavigateOptions
|
|
7
|
+
href?: string
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
const RedirectWithQuery: React.ComponentType<RedirectProps> = ({ to, toOptions }) => {
|
|
10
|
+
const RedirectWithQuery: React.ComponentType<RedirectProps> = ({ href, to, toOptions }) => {
|
|
10
11
|
const newPath = `${to}${document.location.search}`
|
|
11
12
|
const navigate = useNavigate()
|
|
12
13
|
const { pathname } = useLocation()
|
|
13
14
|
|
|
14
15
|
useEffect(() => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
16
|
+
if (href) {
|
|
17
|
+
window.location.href = href
|
|
18
|
+
} else {
|
|
19
|
+
if (newPath !== pathname) {
|
|
20
|
+
navigate(newPath, { replace: true, ...toOptions })
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
})
|
|
19
24
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PaletteMode, Select, SelectProps, useTheme } from '@mui/material'
|
|
2
|
+
import merge from 'lodash/merge'
|
|
3
|
+
|
|
4
|
+
export interface SelectExProps<T> extends SelectProps<T> {
|
|
5
|
+
colorize?: 'primary' | 'secondary'
|
|
6
|
+
mode?: PaletteMode
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SelectEx: <T>(props: SelectExProps<T>) => JSX.Element = ({
|
|
10
|
+
MenuProps,
|
|
11
|
+
mode = 'light',
|
|
12
|
+
colorize,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
const theme = useTheme()
|
|
16
|
+
const colorizeMenuProps = colorize
|
|
17
|
+
? { MenuListProps: { sx: { backgroundColor: theme.palette[colorize][mode] } } }
|
|
18
|
+
: {}
|
|
19
|
+
|
|
20
|
+
return <Select MenuProps={merge(MenuProps, colorizeMenuProps)} {...props} />
|
|
21
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -16,12 +16,14 @@ export * from './Experiments'
|
|
|
16
16
|
export * from './FlexBox'
|
|
17
17
|
export * from './InvertableThemeProvider'
|
|
18
18
|
export * from './LinkEx'
|
|
19
|
+
export * from './MenuEx'
|
|
19
20
|
export * from './NumberStatus'
|
|
20
21
|
export * from './Pixel'
|
|
21
22
|
export * from './Portal'
|
|
22
23
|
export * from './QuickTipButton'
|
|
23
24
|
export * from './RichResult'
|
|
24
25
|
export * from './ScrollToTop'
|
|
26
|
+
export * from './SelectEx'
|
|
25
27
|
export * from './TokenAmount'
|
|
26
28
|
|
|
27
29
|
export { Background, CoverProgress, HoverScale, Identicon, RedirectWithQuery, ScrollToTopButton }
|