muffin-admin 11.8.0 → 13.0.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.d.ts +5 -5
- package/dist/MuffinAdmin.js +1 -1
- package/dist/MuffinDashboard.d.ts +1 -1
- package/dist/MuffinDashboard.js +3 -3
- package/dist/MuffinMenu.d.ts +2 -2
- package/dist/MuffinMenu.js +2 -2
- package/dist/MuffinRecordList.d.ts +2 -2
- package/dist/MuffinRecordList.js +1 -1
- package/dist/MuffinResource.d.ts +2 -2
- package/dist/MuffinResourceCreate.d.ts +3 -3
- package/dist/MuffinResourceEdit.d.ts +6 -6
- package/dist/MuffinResourceEdit.js +36 -4
- package/dist/MuffinResourceList.d.ts +2 -2
- package/dist/MuffinResourceList.js +10 -5
- package/dist/MuffinResourceShow.d.ts +5 -5
- package/dist/MuffinResourceShow.js +43 -6
- package/dist/actions/LinkAction.d.ts +2 -2
- package/dist/authprovider.js +7 -9
- package/dist/buildRA.d.ts +4 -3
- package/dist/buildRA.js +1 -1
- package/dist/buttons/ActionButton.d.ts +5 -5
- package/dist/buttons/ActionButton.js +5 -5
- package/dist/buttons/CopyButton.d.ts +1 -1
- package/dist/buttons/LinkButton.d.ts +2 -2
- package/dist/buttons/LinkButton.js +8 -2
- package/dist/common/AdminModal.d.ts +6 -4
- package/dist/common/AdminModal.js +2 -2
- package/dist/common/ConfirmationProvider.d.ts +2 -2
- package/dist/common/ConfirmationProvider.js +1 -1
- package/dist/common/HelpLink.d.ts +1 -1
- package/dist/common/PayloadButtons.d.ts +1 -1
- package/dist/common/PayloadButtons.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dataprovider.d.ts +7 -7
- package/dist/fields/AvatarField.d.ts +3 -3
- package/dist/fields/AvatarField.js +2 -2
- package/dist/fields/CopyField.d.ts +1 -1
- package/dist/fields/EditableBooleanField.d.ts +1 -1
- package/dist/fields/FKField.d.ts +4 -4
- package/dist/fields/FKField.js +12 -2
- package/dist/fields/JsonField.d.ts +1 -1
- package/dist/filters/DateRangeFilter.d.ts +1 -1
- package/dist/filters/Filter.d.ts +2 -2
- package/dist/filters/Filter.js +2 -2
- package/dist/filters/SearchFilter.d.ts +2 -2
- package/dist/filters/SearchFilter.js +6 -4
- package/dist/hooks/useAction.d.ts +2 -2
- package/dist/hooks/useAction.js +2 -2
- package/dist/i18n/en.d.ts +1 -1
- package/dist/i18n/provider.d.ts +3 -3
- package/dist/i18n/ru.d.ts +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -12
- package/dist/inputs/DateRangeInput.d.ts +2 -2
- package/dist/inputs/FKInput.d.ts +2 -2
- package/dist/inputs/ImgInput.d.ts +2 -2
- package/dist/inputs/JsonInput.d.ts +1 -1
- package/dist/inputs/JsonInput.js +1 -1
- package/dist/inputs/TimestampInput.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/web.js +0 -1
- package/package.json +15 -29
- package/src/MuffinAdmin.tsx +6 -7
- package/src/MuffinDashboard.tsx +6 -6
- package/src/MuffinMenu.tsx +3 -5
- package/src/MuffinRecordList.tsx +2 -2
- package/src/MuffinResource.tsx +1 -1
- package/src/MuffinResourceCreate.tsx +1 -1
- package/src/MuffinResourceEdit.tsx +73 -12
- package/src/MuffinResourceList.tsx +17 -6
- package/src/MuffinResourceShow.tsx +93 -15
- package/src/actions/LinkAction.tsx +1 -1
- package/src/authprovider.ts +88 -101
- package/src/buildRA.tsx +4 -3
- package/src/buttons/ActionButton.tsx +9 -10
- package/src/buttons/LinkButton.tsx +11 -3
- package/src/common/AdminModal.tsx +8 -5
- package/src/common/ConfirmationProvider.tsx +1 -1
- package/src/common/PayloadButtons.tsx +1 -1
- package/src/context.ts +1 -1
- package/src/dataprovider.ts +2 -2
- package/src/fields/AvatarField.tsx +8 -10
- package/src/fields/FKField.tsx +14 -2
- package/src/filters/Filter.tsx +2 -2
- package/src/filters/SearchFilter.tsx +14 -7
- package/src/globals.d.ts +1 -0
- package/src/hooks/useAction.ts +4 -4
- package/src/i18n/en.ts +1 -1
- package/src/i18n/ru.ts +1 -1
- package/src/index.tsx +12 -13
- package/src/inputs/DateRangeInput.tsx +1 -1
- package/src/inputs/JsonInput.tsx +1 -1
- package/src/utils.tsx +2 -1
- package/src/version.ts +1 -0
- package/src/web.ts +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Dialog, DialogActions, DialogContent, DialogProps, DialogTitle } from "@mui/material"
|
|
2
|
-
import {
|
|
1
|
+
import { Dialog, DialogActions, DialogContent, type DialogProps, DialogTitle } from "@mui/material"
|
|
2
|
+
import type { SxProps, Theme } from "@mui/material/styles"
|
|
3
|
+
import type { PropsWithChildren } from "react"
|
|
3
4
|
|
|
4
|
-
interface IProps {
|
|
5
|
+
interface IProps extends Omit<DialogProps, "title" | "open" | "onClose"> {
|
|
5
6
|
open: boolean
|
|
6
7
|
onClose: () => void
|
|
7
8
|
title?: React.ReactNode
|
|
8
9
|
actions?: React.ReactNode
|
|
10
|
+
contentSx?: SxProps<Theme>
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export function AdminModal({
|
|
@@ -14,12 +16,13 @@ export function AdminModal({
|
|
|
14
16
|
children,
|
|
15
17
|
title,
|
|
16
18
|
actions,
|
|
19
|
+
contentSx,
|
|
17
20
|
...props
|
|
18
|
-
}: PropsWithChildren<IProps
|
|
21
|
+
}: PropsWithChildren<IProps>) {
|
|
19
22
|
return (
|
|
20
23
|
<Dialog open={open} onClose={onClose} fullWidth maxWidth="md" {...props}>
|
|
21
24
|
{title && <DialogTitle>{title}</DialogTitle>}
|
|
22
|
-
<DialogContent>{children}</DialogContent>
|
|
25
|
+
<DialogContent sx={contentSx}>{children}</DialogContent>
|
|
23
26
|
{actions && <DialogActions>{actions}</DialogActions>}
|
|
24
27
|
</Dialog>
|
|
25
28
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, Typography } from "@mui/material"
|
|
2
|
-
import { createContext, PropsWithChildren, useContext, useState } from "react"
|
|
2
|
+
import { createContext, type PropsWithChildren, useContext, useState } from "react"
|
|
3
3
|
import { useTranslate } from "react-admin"
|
|
4
4
|
import { AdminModal } from "./AdminModal"
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ export function PayloadButtons({
|
|
|
11
11
|
isValid: boolean
|
|
12
12
|
}) {
|
|
13
13
|
return (
|
|
14
|
-
<Stack direction="row" alignItems
|
|
14
|
+
<Stack direction="row" spacing={1} sx={{ alignItems: "center", justifyContent: "flex-end" }}>
|
|
15
15
|
<Button
|
|
16
16
|
label="ra.action.confirm"
|
|
17
17
|
variant="contained"
|
package/src/context.ts
CHANGED
package/src/dataprovider.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TID } from "./types"
|
|
2
|
-
import { APIParams, makeRequest, prepareFilters, setupAdmin } from "./utils"
|
|
1
|
+
import type { TID } from "./types"
|
|
2
|
+
import { type APIParams, makeRequest, prepareFilters, setupAdmin } from "./utils"
|
|
3
3
|
|
|
4
4
|
type TQueryMeta = {
|
|
5
5
|
key?: string
|
|
@@ -5,28 +5,26 @@ import { useRecordContext } from "ra-core"
|
|
|
5
5
|
|
|
6
6
|
export function AvatarField({ source, alt, style, nameProp, ...props }) {
|
|
7
7
|
const record = useRecordContext(props)
|
|
8
|
-
|
|
8
|
+
const value = get(record, source),
|
|
9
9
|
name = record[nameProp]
|
|
10
10
|
|
|
11
11
|
// Check value is a valid URL
|
|
12
12
|
if (value) {
|
|
13
13
|
try {
|
|
14
|
-
new URL(value)
|
|
14
|
+
new URL(value)
|
|
15
15
|
} catch {
|
|
16
16
|
// Not a valid URL, return loader
|
|
17
|
-
return
|
|
18
|
-
<CircularProgress size={24} />
|
|
19
|
-
)
|
|
17
|
+
return <CircularProgress size={24} />
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
const letters = name
|
|
24
22
|
? name
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
.trim(" ")
|
|
24
|
+
.split(/\s+/)
|
|
25
|
+
.slice(0, 2)
|
|
26
|
+
.map((n: string) => n[0]?.toUpperCase())
|
|
27
|
+
.join("")
|
|
30
28
|
: ""
|
|
31
29
|
|
|
32
30
|
return (
|
package/src/fields/FKField.tsx
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import { ReferenceField, TextField,
|
|
1
|
+
import { ReferenceField, TextField, type UseFieldValueOptions, useFieldValue } from "react-admin"
|
|
2
|
+
import { useLocation } from "react-router-dom"
|
|
2
3
|
|
|
3
4
|
export function FKField({ reference, refSource, refKey, link, source, ...props }) {
|
|
5
|
+
const location = useLocation()
|
|
4
6
|
refKey = refKey || "id"
|
|
7
|
+
const returnTo = `${location.pathname}${location.search}`
|
|
8
|
+
|
|
9
|
+
const resolveLink =
|
|
10
|
+
link ||
|
|
11
|
+
((record) => {
|
|
12
|
+
const id = record?.[refKey]
|
|
13
|
+
if (id === undefined || id === null) return false
|
|
14
|
+
return `/${reference}/${id}/show?returnTo=${encodeURIComponent(returnTo)}`
|
|
15
|
+
})
|
|
16
|
+
|
|
5
17
|
return (
|
|
6
18
|
<ReferenceField
|
|
7
19
|
source={source}
|
|
8
|
-
link={
|
|
20
|
+
link={resolveLink}
|
|
9
21
|
reference={reference}
|
|
10
22
|
queryOptions={{ meta: { key: refKey } }}
|
|
11
23
|
{...props}
|
package/src/filters/Filter.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import Menu from "@mui/material/Menu"
|
|
|
4
4
|
import MenuItem from "@mui/material/MenuItem"
|
|
5
5
|
import TextField from "@mui/material/TextField"
|
|
6
6
|
import { useState } from "react"
|
|
7
|
-
import { FieldTitle, InputProps, useInput } from "react-admin"
|
|
7
|
+
import { FieldTitle, type InputProps, useInput } from "react-admin"
|
|
8
8
|
|
|
9
9
|
const OPERATORS = {
|
|
10
10
|
$eq: "=",
|
|
@@ -22,7 +22,7 @@ export function Filter({ type = "text", ...props }: InputProps) {
|
|
|
22
22
|
})
|
|
23
23
|
const [op, setOp] = useState((field.value && Object.keys(field.value)[0]) || "$eq")
|
|
24
24
|
|
|
25
|
-
const onChange =
|
|
25
|
+
const onChange = (e: any) => {
|
|
26
26
|
field.onChange({ [op]: e.target.value })
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -4,7 +4,12 @@ import clsx from "clsx"
|
|
|
4
4
|
import debounce from "lodash/debounce"
|
|
5
5
|
import { useTranslate } from "ra-core"
|
|
6
6
|
import { useState } from "react"
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ResettableTextField,
|
|
9
|
+
type SearchInputProps,
|
|
10
|
+
useInput,
|
|
11
|
+
useResourceContext,
|
|
12
|
+
} from "react-admin"
|
|
8
13
|
|
|
9
14
|
export function SearchFilter({ source, className, ...props }: SearchInputProps) {
|
|
10
15
|
const translate = useTranslate()
|
|
@@ -29,12 +34,14 @@ export function SearchFilter({ source, className, ...props }: SearchInputProps)
|
|
|
29
34
|
}}
|
|
30
35
|
{...props}
|
|
31
36
|
className={clsx("ra-input", `ra-input-${source}`, className)}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
slotProps={{
|
|
38
|
+
input: {
|
|
39
|
+
endAdornment: (
|
|
40
|
+
<InputAdornment position="end">
|
|
41
|
+
<SearchIcon color="disabled" />
|
|
42
|
+
</InputAdornment>
|
|
43
|
+
),
|
|
44
|
+
},
|
|
38
45
|
}}
|
|
39
46
|
/>
|
|
40
47
|
)
|
package/src/globals.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css"
|
package/src/hooks/useAction.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseMutationOptions, useMutation } from "@tanstack/react-query"
|
|
1
|
+
import { type UseMutationOptions, useMutation } from "@tanstack/react-query"
|
|
2
2
|
import {
|
|
3
3
|
useDataProvider,
|
|
4
4
|
useNotify,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useResourceContext,
|
|
7
7
|
useUnselectAll,
|
|
8
8
|
} from "react-admin"
|
|
9
|
-
import { MuffinDataprovider, TActionProps } from "../dataprovider"
|
|
9
|
+
import type { MuffinDataprovider, TActionProps } from "../dataprovider"
|
|
10
10
|
|
|
11
11
|
export function useAction(
|
|
12
12
|
action: string,
|
|
@@ -21,8 +21,8 @@ export function useAction(
|
|
|
21
21
|
return useMutation({
|
|
22
22
|
mutationFn: (params: TActionProps) => dataProvider.runAction(resource, action, params),
|
|
23
23
|
onSuccess: ({ data }) => {
|
|
24
|
-
if (data
|
|
25
|
-
if (data
|
|
24
|
+
if (data?.message) notify(data.message, { type: "success" })
|
|
25
|
+
if (data?.redirectTo) window.location = data.redirectTo
|
|
26
26
|
else {
|
|
27
27
|
unselectAll()
|
|
28
28
|
refresh()
|
package/src/i18n/en.ts
CHANGED
package/src/i18n/ru.ts
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client"
|
|
2
|
-
import { MuffinAdmin } from "./MuffinAdmin"
|
|
3
2
|
import { MuffinAdminContext } from "./context"
|
|
3
|
+
import { MuffinAdmin } from "./MuffinAdmin"
|
|
4
4
|
|
|
5
|
-
export * from "./utils"
|
|
6
|
-
|
|
7
|
-
export * from "./MuffinAdmin"
|
|
8
|
-
export * from "./MuffinDashboard"
|
|
9
|
-
export * from "./MuffinMenu"
|
|
10
|
-
export * from "./MuffinRecordList"
|
|
11
|
-
export * from "./MuffinResource"
|
|
12
|
-
export * from "./MuffinResourceCreate"
|
|
13
|
-
export * from "./MuffinResourceEdit"
|
|
14
|
-
export * from "./MuffinResourceList"
|
|
15
|
-
export * from "./MuffinResourceShow"
|
|
16
5
|
export * from "./actions"
|
|
17
6
|
export * from "./authprovider"
|
|
18
7
|
export * from "./buildRA"
|
|
@@ -22,7 +11,17 @@ export * from "./context"
|
|
|
22
11
|
export * from "./dataprovider"
|
|
23
12
|
export * from "./fields"
|
|
24
13
|
export * from "./hooks"
|
|
14
|
+
export * from "./MuffinAdmin"
|
|
15
|
+
export * from "./MuffinDashboard"
|
|
16
|
+
export * from "./MuffinMenu"
|
|
17
|
+
export * from "./MuffinRecordList"
|
|
18
|
+
export * from "./MuffinResource"
|
|
19
|
+
export * from "./MuffinResourceCreate"
|
|
20
|
+
export * from "./MuffinResourceEdit"
|
|
21
|
+
export * from "./MuffinResourceList"
|
|
22
|
+
export * from "./MuffinResourceShow"
|
|
25
23
|
export * from "./types"
|
|
24
|
+
export * from "./utils"
|
|
26
25
|
|
|
27
26
|
export async function initAdmin(prefix = "", containerId: string = "root") {
|
|
28
27
|
const response = await fetch(`${prefix}/ra.json`)
|
|
@@ -37,4 +36,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
|
|
|
37
36
|
)
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
export
|
|
39
|
+
export { VERSION } from "./version"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TextField from "@mui/material/TextField"
|
|
2
2
|
import { enGB, ru } from "date-fns/locale"
|
|
3
|
-
import { FieldTitle, InputProps, useLocale } from "react-admin"
|
|
3
|
+
import { FieldTitle, type InputProps, useLocale } from "react-admin"
|
|
4
4
|
import DatePicker, { registerLocale } from "react-datepicker"
|
|
5
5
|
import "react-datepicker/dist/react-datepicker.css"
|
|
6
6
|
|
package/src/inputs/JsonInput.tsx
CHANGED
|
@@ -8,7 +8,7 @@ const parseFunction = (json) => {
|
|
|
8
8
|
try {
|
|
9
9
|
retval = JSON.parse(json)
|
|
10
10
|
} finally {
|
|
11
|
-
//
|
|
11
|
+
// biome-ignore lint/correctness/noUnsafeFinally: intentional - return parsed value or original on error
|
|
12
12
|
return retval
|
|
13
13
|
}
|
|
14
14
|
}
|
package/src/utils.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as icons from "@mui/icons-material"
|
|
2
2
|
import { stringify } from "query-string"
|
|
3
3
|
import { fetchUtils } from "ra-core"
|
|
4
|
-
import { TAdminPath } from "./types"
|
|
4
|
+
import type { TAdminPath } from "./types"
|
|
5
5
|
|
|
6
6
|
const builders = new Map<string, (props: any) => any>()
|
|
7
7
|
|
|
@@ -58,6 +58,7 @@ export function makeRequest(url: string, params: APIParams = {}) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function findIcon(icon?: string) {
|
|
61
|
+
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: icons are looked up by name from admin config
|
|
61
62
|
return icon ? icons[icon] : undefined
|
|
62
63
|
}
|
|
63
64
|
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "13.0.0"
|
package/src/web.ts
CHANGED