muffin-admin 9.1.1 → 9.2.1
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/MuffinDashboard.js +1 -0
- package/dist/buildRA.js +4 -2
- package/dist/filters/SearchFilter.d.ts +2 -0
- package/dist/filters/SearchFilter.js +34 -0
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/MuffinDashboard.tsx +1 -0
- package/src/buildRA.tsx +4 -1
- package/src/filters/SearchFilter.tsx +40 -0
- package/src/filters/index.ts +1 -0
- package/src/index.tsx +1 -1
package/package.json
CHANGED
package/src/MuffinDashboard.tsx
CHANGED
|
@@ -38,6 +38,7 @@ export function MuffinDashboard() {
|
|
|
38
38
|
|
|
39
39
|
setupAdmin(["dashboard"], MuffinDashboard)
|
|
40
40
|
setupAdmin(["dashboard-actions"], () => null)
|
|
41
|
+
setupAdmin(["dashboard-content"], () => null)
|
|
41
42
|
|
|
42
43
|
function AdminCards({ src }: { src: AdminDashboardBlock | AdminDashboardBlock[] }) {
|
|
43
44
|
if (Array.isArray(src))
|
package/src/buildRA.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
ReferenceManyField,
|
|
28
28
|
required,
|
|
29
29
|
RichTextField,
|
|
30
|
+
SearchInput,
|
|
30
31
|
SelectArrayInput,
|
|
31
32
|
SelectField,
|
|
32
33
|
SelectInput,
|
|
@@ -36,7 +37,7 @@ import {
|
|
|
36
37
|
} from "react-admin"
|
|
37
38
|
|
|
38
39
|
import { AvatarField, CopyField, EditableBooleanField, FKField, JsonField } from "./fields"
|
|
39
|
-
import { DateRangeFilter, Filter } from "./filters"
|
|
40
|
+
import { DateRangeFilter, Filter, SearchFilter } from "./filters"
|
|
40
41
|
import { FKInput, JsonInput, TimestampInput } from "./inputs"
|
|
41
42
|
|
|
42
43
|
const UI: Record<string, JSX.ElementType> = {
|
|
@@ -84,10 +85,12 @@ const UI: Record<string, JSX.ElementType> = {
|
|
|
84
85
|
SelectInput,
|
|
85
86
|
TextInput,
|
|
86
87
|
TimestampInput,
|
|
88
|
+
SearchInput,
|
|
87
89
|
|
|
88
90
|
// Filters
|
|
89
91
|
Filter,
|
|
90
92
|
DateRangeFilter,
|
|
93
|
+
SearchFilter,
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
export function buildRAComponent(name: string, props: any) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import SearchIcon from "@mui/icons-material/Search"
|
|
2
|
+
import { InputAdornment } from "@mui/material"
|
|
3
|
+
import clsx from "clsx"
|
|
4
|
+
import debounce from "lodash/debounce"
|
|
5
|
+
import { useTranslate } from "ra-core"
|
|
6
|
+
import { useState } from "react"
|
|
7
|
+
import { ResettableTextField, SearchInputProps, useInput, useResourceContext } from "react-admin"
|
|
8
|
+
|
|
9
|
+
export function SearchFilter({ source, className, ...props }: SearchInputProps) {
|
|
10
|
+
const translate = useTranslate()
|
|
11
|
+
const { field } = useInput({ source, ...props })
|
|
12
|
+
const [searchValue, setSearchValue] = useState(field.value || "")
|
|
13
|
+
const resource = useResourceContext()
|
|
14
|
+
|
|
15
|
+
const onBlur = () => field.onChange(searchValue)
|
|
16
|
+
const label = translate(`resources.${resource}.fields.${source}`)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ResettableTextField
|
|
20
|
+
resettable
|
|
21
|
+
ref={field.ref}
|
|
22
|
+
value={searchValue}
|
|
23
|
+
onBlur={debounce(onBlur, 500)}
|
|
24
|
+
onChange={(e) => setSearchValue(e.target?.value || e)}
|
|
25
|
+
onKeyUp={(e) => {
|
|
26
|
+
if (e.key === "Enter") field.onChange(searchValue)
|
|
27
|
+
}}
|
|
28
|
+
placeholder={label}
|
|
29
|
+
{...props}
|
|
30
|
+
className={clsx("ra-input", `ra-input-${source}`, className)}
|
|
31
|
+
InputProps={{
|
|
32
|
+
endAdornment: (
|
|
33
|
+
<InputAdornment position="end">
|
|
34
|
+
<SearchIcon color="disabled" />
|
|
35
|
+
</InputAdornment>
|
|
36
|
+
),
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
package/src/filters/index.ts
CHANGED
package/src/index.tsx
CHANGED