muffin-admin 12.0.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 +1 -1
- package/dist/MuffinResourceList.d.ts +2 -2
- package/dist/MuffinResourceList.js +3 -4
- package/dist/MuffinResourceShow.d.ts +5 -5
- package/dist/MuffinResourceShow.js +1 -1
- 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/common/AdminModal.d.ts +4 -4
- 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 +1 -1
- 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 +1 -1
- package/src/MuffinResourceList.tsx +2 -5
- package/src/MuffinResourceShow.tsx +1 -1
- 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 +1 -1
- package/src/common/AdminModal.tsx +3 -3
- 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 +1 -1
- 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
package/src/buildRA.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ElementType } from "react"
|
|
1
2
|
import {
|
|
2
3
|
ArrayField,
|
|
3
4
|
ArrayInput,
|
|
@@ -25,8 +26,8 @@ import {
|
|
|
25
26
|
ReferenceField,
|
|
26
27
|
ReferenceInput,
|
|
27
28
|
ReferenceManyField,
|
|
28
|
-
required,
|
|
29
29
|
RichTextField,
|
|
30
|
+
required,
|
|
30
31
|
SearchInput,
|
|
31
32
|
SelectArrayInput,
|
|
32
33
|
SelectField,
|
|
@@ -40,7 +41,7 @@ import { AvatarField, CopyField, EditableBooleanField, FKField, JsonField } from
|
|
|
40
41
|
import { DateRangeFilter, Filter, SearchFilter } from "./filters"
|
|
41
42
|
import { FKInput, ImgInput, JsonInput, TimestampInput } from "./inputs"
|
|
42
43
|
|
|
43
|
-
const UI: Record<string,
|
|
44
|
+
const UI: Record<string, ElementType> = {
|
|
44
45
|
// Fields
|
|
45
46
|
BooleanField,
|
|
46
47
|
ChipField,
|
|
@@ -112,6 +113,6 @@ export function buildRA(items: [string, Record<string, any>][]) {
|
|
|
112
113
|
return items.map((item) => buildRAComponent(item[0], item[1]))
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
export function registerUI(name: string, component:
|
|
116
|
+
export function registerUI(name: string, component: ElementType) {
|
|
116
117
|
UI[name] = component
|
|
117
118
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Link, Stack } from "@mui/material"
|
|
2
|
+
import { useState } from "react"
|
|
1
3
|
import {
|
|
2
4
|
Button,
|
|
3
5
|
FormGroupsProvider,
|
|
@@ -8,15 +10,12 @@ import {
|
|
|
8
10
|
useTranslate,
|
|
9
11
|
} from "react-admin"
|
|
10
12
|
import { FormProvider } from "react-hook-form"
|
|
11
|
-
|
|
12
|
-
import { Link, Stack } from "@mui/material"
|
|
13
|
-
import { useState } from "react"
|
|
14
13
|
import { buildRA } from "../buildRA"
|
|
15
14
|
import { AdminModal, PayloadButtons, useConfirmation } from "../common"
|
|
16
15
|
import { HelpLink } from "../common/HelpLink"
|
|
17
16
|
import { useMuffinAdminOpts } from "../hooks"
|
|
18
17
|
import { useAction } from "../hooks/useAction"
|
|
19
|
-
import { AdminAction, AdminPayloadProps } from "../types"
|
|
18
|
+
import type { AdminAction, AdminPayloadProps } from "../types"
|
|
20
19
|
import { buildIcon, findBuilder, prepareFilters, requestHeaders } from "../utils"
|
|
21
20
|
|
|
22
21
|
export type ActionPayloadProps = {
|
|
@@ -160,11 +159,11 @@ export function CommonPayload({
|
|
|
160
159
|
title={
|
|
161
160
|
help
|
|
162
161
|
? ((
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
<Stack sx={{ alignItems: "flex-start" }}>
|
|
163
|
+
<span>{translate(title, { _: title })}</span>
|
|
164
|
+
<HelpLink href={help} style={{ alignSelf: "flex-end" }} />
|
|
165
|
+
</Stack>
|
|
166
|
+
) as any)
|
|
168
167
|
: translate(title, { _: title })
|
|
169
168
|
}
|
|
170
169
|
actions={
|
|
@@ -198,7 +197,7 @@ function FileButton({
|
|
|
198
197
|
const { apiUrl } = useMuffinAdminOpts()
|
|
199
198
|
let url = `${apiUrl}${path}?f`
|
|
200
199
|
if (record) url = url.replace("{id}", record.id as string)
|
|
201
|
-
const authorization = requestHeaders
|
|
200
|
+
const authorization = requestHeaders.Authorization
|
|
202
201
|
if (authorization) url += `&t=${authorization}`
|
|
203
202
|
if (Object.keys(filterValues).length) url += `&where=${prepareFilters(filterValues)}`
|
|
204
203
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dialog, DialogActions, DialogContent, DialogProps, DialogTitle } from "@mui/material"
|
|
2
|
-
import {
|
|
3
|
-
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"
|
|
4
4
|
|
|
5
5
|
interface IProps extends Omit<DialogProps, "title" | "open" | "onClose"> {
|
|
6
6
|
open: boolean
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import { ReferenceField, TextField,
|
|
1
|
+
import { ReferenceField, TextField, type UseFieldValueOptions, useFieldValue } from "react-admin"
|
|
2
2
|
import { useLocation } from "react-router-dom"
|
|
3
3
|
|
|
4
4
|
export function FKField({ reference, refSource, refKey, link, source, ...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