muffin-admin 3.10.0 → 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/MuffinResourceList.js +1 -1
- 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/MuffinResourceList.tsx +1 -1
- 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/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -16,14 +16,26 @@ import {
|
|
|
16
16
|
|
|
17
17
|
import { ConfirmationProvider } from "./common"
|
|
18
18
|
import { useMuffinAdminOpts } from "./hooks"
|
|
19
|
-
import {
|
|
19
|
+
import { buildProvider, muffinTranslations } from "./i18n"
|
|
20
20
|
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils"
|
|
21
21
|
|
|
22
22
|
export function MuffinAdmin(props: AdminProps) {
|
|
23
23
|
const opts = useMuffinAdminOpts()
|
|
24
|
-
const { resources = [], auth, adminProps, apiUrl } = opts
|
|
24
|
+
const { resources = [], auth, adminProps, apiUrl, locales } = opts
|
|
25
25
|
|
|
26
26
|
document.title = adminProps?.title || "Muffin Admin"
|
|
27
|
+
const muffinI18nProvider = buildProvider(
|
|
28
|
+
locales
|
|
29
|
+
? Object.fromEntries(
|
|
30
|
+
Object.entries(muffinTranslations).map(([locale, messages]) => [
|
|
31
|
+
locale,
|
|
32
|
+
{ ...messages, ...locales[locale] },
|
|
33
|
+
])
|
|
34
|
+
)
|
|
35
|
+
: muffinTranslations
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
console.log(999, muffinI18nProvider.getLocale())
|
|
27
39
|
|
|
28
40
|
const {
|
|
29
41
|
basename,
|
|
@@ -80,8 +80,8 @@ function MuffinListToolbar() {
|
|
|
80
80
|
const actions = baseActions.filter((a) => a.view.includes("list"))
|
|
81
81
|
return (
|
|
82
82
|
<TopToolbar>
|
|
83
|
-
<SelectColumnsButton />
|
|
84
83
|
{help && <HelpLink href={help} />}
|
|
84
|
+
<SelectColumnsButton />
|
|
85
85
|
<FilterButton />
|
|
86
86
|
{actions.length ? actions.map((props) => <ActionButton key={props.id} {...props} />) : null}
|
|
87
87
|
{create && <CreateButton />}
|
package/src/hooks/index.ts
CHANGED
package/src/i18n/en.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationMessages } from "ra-core"
|
|
2
|
+
import raEnglishMessages from "ra-language-english"
|
|
3
|
+
|
|
4
|
+
const muffinEnglishMessages: TranslationMessages = {
|
|
5
|
+
...raEnglishMessages,
|
|
2
6
|
muffin: {
|
|
3
7
|
instructions: "Instructions",
|
|
4
8
|
how_to_use_admin: "How to use Admin?",
|
package/src/i18n/index.ts
CHANGED
package/src/i18n/provider.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
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
5
|
|
|
8
|
-
const
|
|
9
|
-
en:
|
|
10
|
-
ru:
|
|
6
|
+
export const muffinTranslations = {
|
|
7
|
+
en: muffinEnglishMessages,
|
|
8
|
+
ru: muffinRussianMessages,
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
const defaultLocale = "en"
|
|
12
|
+
|
|
13
|
+
export const buildProvider = (translations) => {
|
|
14
|
+
return polyglotI18nProvider(
|
|
15
|
+
(locale) => (translations[locale] ? translations[locale] : translations[defaultLocale]),
|
|
16
|
+
resolveBrowserLocale(),
|
|
17
|
+
[
|
|
18
|
+
{ locale: "en", name: "English" },
|
|
19
|
+
{ locale: "ru", name: "Русский" },
|
|
20
|
+
],
|
|
21
|
+
{ allowMissing: true }
|
|
22
|
+
)
|
|
23
|
+
}
|
package/src/i18n/ru.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { TranslationMessages } from "ra-core"
|
|
2
|
+
import raRussianMessages from "ra-language-russian"
|
|
3
|
+
|
|
4
|
+
const muffinRussianMessages: TranslationMessages = {
|
|
5
|
+
...raRussianMessages,
|
|
2
6
|
muffin: {
|
|
3
7
|
instructions: "Инструкции",
|
|
4
8
|
how_to_use_admin: "Как использовать админку?",
|
package/src/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type AdminAction = {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type AdminField = [string, { source: string }]
|
|
18
|
-
export type AdminInput = [string, { required: boolean; source: string;[key: string]: any }]
|
|
18
|
+
export type AdminInput = [string, { required: boolean; source: string; [key: string]: any }]
|
|
19
19
|
|
|
20
20
|
export type AdminShowLink = {
|
|
21
21
|
label: string
|
|
@@ -46,11 +46,11 @@ export type AdminResourceProps = {
|
|
|
46
46
|
actions: AdminAction[]
|
|
47
47
|
create: AdminInput[] | false
|
|
48
48
|
edit:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
| {
|
|
50
|
+
inputs: AdminInput[]
|
|
51
|
+
remove?: boolean
|
|
52
|
+
}
|
|
53
|
+
| false
|
|
54
54
|
list: {
|
|
55
55
|
limit: number
|
|
56
56
|
limitMax: number
|
|
@@ -96,5 +96,6 @@ export type AdminOpts = {
|
|
|
96
96
|
dashboard: AdminDashboardBlock[] | AdminDashboardBlock
|
|
97
97
|
resources: AdminResourceProps[]
|
|
98
98
|
help?: string
|
|
99
|
+
locales: Record<string, Record<string, any>>
|
|
99
100
|
version: string
|
|
100
101
|
}
|