@applica-software-guru/react-admin 1.4.219 → 1.4.220
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/components/Layout/Header/Buttons/LocaleButton.d.ts +4 -0
- package/dist/components/Layout/Header/Buttons/LocaleButton.d.ts.map +1 -0
- package/dist/components/Layout/Header/Buttons/index.d.ts +1 -0
- package/dist/components/Layout/Header/Buttons/index.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +58 -58
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +5629 -5609
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +56 -56
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Header/Buttons/LocaleButton.tsx +37 -0
- package/src/components/Layout/Header/Buttons/index.ts +1 -0
- package/src/components/Layout/Layout.tsx +2 -1
- package/src/index.jsx +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HeaderButton } from './HeaderButton';
|
|
2
|
+
import { usePopoverState } from '../../../../hooks';
|
|
3
|
+
import { Menu, MenuItem, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { useLocaleState, useLocales } from 'ra-core';
|
|
6
|
+
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
|
|
7
|
+
export function LocaleButton(): JSX.Element | null {
|
|
8
|
+
const { open, anchorEl, handleClose, handleToggle } = usePopoverState();
|
|
9
|
+
const [locale, setLocale] = useLocaleState();
|
|
10
|
+
const locales = useLocales();
|
|
11
|
+
if (locales.length === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const handleChooseLocale = (locale: string) => {
|
|
15
|
+
setLocale(locale);
|
|
16
|
+
handleClose();
|
|
17
|
+
};
|
|
18
|
+
return (
|
|
19
|
+
<Fragment>
|
|
20
|
+
<HeaderButton value="locale" onClick={handleToggle} sx={{ minWidth: 'auto' }}>
|
|
21
|
+
<Stack direction="row" spacing={0.5}>
|
|
22
|
+
<Typography variant="body1">{locale.toUpperCase()}</Typography>
|
|
23
|
+
{open ? <CaretUpOutlined /> : <CaretDownOutlined />}
|
|
24
|
+
</Stack>
|
|
25
|
+
</HeaderButton>
|
|
26
|
+
<Menu id="menu-appbar" anchorEl={anchorEl} keepMounted open={open} onClose={handleClose}>
|
|
27
|
+
{locales.map((locale, index) => (
|
|
28
|
+
<MenuItem key={index} onClick={() => handleChooseLocale(locale.locale)}>
|
|
29
|
+
{locale.name}
|
|
30
|
+
</MenuItem>
|
|
31
|
+
))}
|
|
32
|
+
</Menu>
|
|
33
|
+
</Fragment>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default LocaleButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Header, HeaderNotification, HeaderProfile, HeaderSpacer, ResponsiveSection } from './Header';
|
|
1
|
+
import { Header, HeaderNotification, HeaderProfile, HeaderSpacer, LocaleButton, ResponsiveSection } from './Header';
|
|
2
2
|
|
|
3
3
|
import { Breadcrumbs } from '../@extended';
|
|
4
4
|
import { Footer } from './Footer';
|
|
@@ -28,6 +28,7 @@ const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
|
|
|
28
28
|
<LayoutWrapper>
|
|
29
29
|
<Header>
|
|
30
30
|
<HeaderSpacer />
|
|
31
|
+
<LocaleButton />
|
|
31
32
|
{enableThemeToggler && <ThemeToggler />}
|
|
32
33
|
<LoadingIndicator />
|
|
33
34
|
<HeaderNotification />
|
package/src/index.jsx
CHANGED
|
@@ -9,6 +9,7 @@ export * from './utils';
|
|
|
9
9
|
export * from './i18n';
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
|
+
ArrayField,
|
|
12
13
|
ArrayInputContext,
|
|
13
14
|
BooleanField,
|
|
14
15
|
BulkDeleteWithConfirmButton,
|
|
@@ -72,6 +73,7 @@ export {
|
|
|
72
73
|
useInput,
|
|
73
74
|
useListContext,
|
|
74
75
|
useListController,
|
|
76
|
+
useLocales,
|
|
75
77
|
useLocaleState,
|
|
76
78
|
useNotify,
|
|
77
79
|
usePermissions,
|