muffin-admin 3.10.1 → 3.11.0
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/MuffinAdmin.js +9 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useForceUpdate.d.ts +1 -0
- package/dist/hooks/useForceUpdate.js +5 -0
- package/dist/i18n/en.d.ts +2 -6
- package/dist/i18n/en.js +3 -4
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/provider.d.ts +5 -1
- package/dist/i18n/provider.js +10 -9
- package/dist/i18n/ru.d.ts +2 -6
- package/dist/i18n/ru.js +3 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/MuffinAdmin.tsx +14 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useForceUpdate.ts +6 -0
- package/src/i18n/en.ts +5 -1
- package/src/i18n/index.ts +2 -0
- package/src/i18n/provider.ts +16 -14
- package/src/i18n/ru.ts +5 -1
- package/src/types.ts +7 -6
package/dist/MuffinAdmin.js
CHANGED
|
@@ -6,12 +6,19 @@ import Typography from "@mui/material/Typography";
|
|
|
6
6
|
import { AdminContext, AdminUI, AppBar, Layout, localStorageStore, Login, } from "react-admin";
|
|
7
7
|
import { ConfirmationProvider } from "./common";
|
|
8
8
|
import { useMuffinAdminOpts } from "./hooks";
|
|
9
|
-
import {
|
|
9
|
+
import { buildProvider, muffinTranslations } from "./i18n";
|
|
10
10
|
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils";
|
|
11
11
|
export function MuffinAdmin(props) {
|
|
12
12
|
const opts = useMuffinAdminOpts();
|
|
13
|
-
const { resources = [], auth, adminProps, apiUrl } = opts;
|
|
13
|
+
const { resources = [], auth, adminProps, apiUrl, locales } = opts;
|
|
14
14
|
document.title = (adminProps === null || adminProps === void 0 ? void 0 : adminProps.title) || "Muffin Admin";
|
|
15
|
+
const muffinI18nProvider = buildProvider(locales
|
|
16
|
+
? Object.fromEntries(Object.entries(muffinTranslations).map(([locale, messages]) => [
|
|
17
|
+
locale,
|
|
18
|
+
Object.assign(Object.assign({}, messages), locales[locale]),
|
|
19
|
+
]))
|
|
20
|
+
: muffinTranslations);
|
|
21
|
+
console.log(999, muffinI18nProvider.getLocale());
|
|
15
22
|
const { basename, authProvider = findBuilder(["authprovider"])(auth), dataProvider = findBuilder(["dataprovider"])(apiUrl), catchAll, dashboard = findBuilder(["dashboard"]), disableTelemetry, error, i18nProvider = muffinI18nProvider, layout = findBuilder(["layout"]), loading, loginPage = findBuilder(["loginpage"]), authCallbackPage, notification, queryClient, requireAuth = auth.required, store = localStorageStore(), ready, theme, lightTheme, darkTheme, defaultTheme, title = "React Admin", } = props;
|
|
16
23
|
return (_jsx(AdminContext, { authProvider: authProvider, basename: basename, dataProvider: dataProvider, i18nProvider: i18nProvider, store: store, queryClient: queryClient, theme: theme, lightTheme: lightTheme, darkTheme: darkTheme, defaultTheme: defaultTheme, children: _jsx(ConfirmationProvider, { children: _jsx(AdminUI, { layout: layout, dashboard: dashboard, disableTelemetry: disableTelemetry, catchAll: catchAll, error: error, title: title, loading: loading, loginPage: loginPage, authCallbackPage: authCallbackPage, notification: notification, requireAuth: requireAuth, ready: ready, children: resources === null || resources === void 0 ? void 0 : resources.map(({ name }) => buildAdmin(["resource", name], { name })) }) }) }));
|
|
17
24
|
}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useForceUpdate(): () => void;
|
package/dist/i18n/en.d.ts
CHANGED
package/dist/i18n/en.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import raEnglishMessages from "ra-language-english";
|
|
2
|
+
const muffinEnglishMessages = Object.assign(Object.assign({}, raEnglishMessages), { muffin: {
|
|
3
3
|
instructions: "Instructions",
|
|
4
4
|
how_to_use_admin: "How to use Admin?",
|
|
5
|
-
}
|
|
6
|
-
};
|
|
5
|
+
} });
|
|
7
6
|
export default muffinEnglishMessages;
|
package/dist/i18n/index.d.ts
CHANGED
package/dist/i18n/index.js
CHANGED
package/dist/i18n/provider.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const muffinTranslations: {
|
|
2
|
+
en: import("react-admin").TranslationMessages;
|
|
3
|
+
ru: import("react-admin").TranslationMessages;
|
|
4
|
+
};
|
|
5
|
+
export declare const buildProvider: (translations: any) => import("react-admin").I18nProvider;
|
package/dist/i18n/provider.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import polyglotI18nProvider from "ra-i18n-polyglot";
|
|
2
|
-
import raEnglishMessages from "ra-language-english";
|
|
3
|
-
import raRussianMessages from "ra-language-russian";
|
|
4
2
|
import { resolveBrowserLocale } from "react-admin";
|
|
5
3
|
import muffinEnglishMessages from "./en";
|
|
6
4
|
import muffinRussianMessages from "./ru";
|
|
7
|
-
const
|
|
8
|
-
en:
|
|
9
|
-
ru:
|
|
5
|
+
export const muffinTranslations = {
|
|
6
|
+
en: muffinEnglishMessages,
|
|
7
|
+
ru: muffinRussianMessages,
|
|
8
|
+
};
|
|
9
|
+
const defaultLocale = "en";
|
|
10
|
+
export const buildProvider = (translations) => {
|
|
11
|
+
return polyglotI18nProvider((locale) => (translations[locale] ? translations[locale] : translations[defaultLocale]), resolveBrowserLocale(), [
|
|
12
|
+
{ locale: "en", name: "English" },
|
|
13
|
+
{ locale: "ru", name: "Русский" },
|
|
14
|
+
], { allowMissing: true });
|
|
10
15
|
};
|
|
11
|
-
export const muffinI18nProvider = polyglotI18nProvider((locale) => (translations[locale] ? translations[locale] : translations.en), resolveBrowserLocale(), [
|
|
12
|
-
{ locale: "en", name: "English" },
|
|
13
|
-
{ locale: "ru", name: "Русский" },
|
|
14
|
-
], { allowMissing: true });
|
package/dist/i18n/ru.d.ts
CHANGED
package/dist/i18n/ru.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import raRussianMessages from "ra-language-russian";
|
|
2
|
+
const muffinRussianMessages = Object.assign(Object.assign({}, raRussianMessages), { muffin: {
|
|
3
3
|
instructions: "Инструкции",
|
|
4
4
|
how_to_use_admin: "Как использовать админку?",
|
|
5
|
-
}
|
|
6
|
-
};
|
|
5
|
+
} });
|
|
7
6
|
export default muffinRussianMessages;
|