muffin-admin 8.5.6 → 9.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/buildRA.js +5 -2
- package/dist/filters/DateRangeFilter.d.ts +2 -0
- package/dist/filters/DateRangeFilter.js +17 -0
- package/dist/filters/Filter.d.ts +1 -0
- package/dist/{inputs/FilterInput.js → filters/Filter.js} +1 -1
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/inputs/DateRangeInput.d.ts +7 -0
- package/dist/inputs/DateRangeInput.js +13 -0
- package/dist/inputs/index.d.ts +0 -1
- package/dist/inputs/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -1
- package/src/MuffinAdmin.tsx +6 -5
- package/src/buildRA.tsx +6 -2
- package/src/filters/DateRangeFilter.tsx +17 -0
- package/src/{inputs/FilterInput.tsx → filters/Filter.tsx} +1 -1
- package/src/filters/index.ts +2 -0
- package/src/index.tsx +1 -1
- package/src/inputs/DateRangeInput.tsx +29 -0
- package/src/inputs/index.ts +0 -1
- package/dist/inputs/FilterInput.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muffin-admin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "NPM package for https://github.com/klen/muffin-admin",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/klen/muffin-admin#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"date-fns": "^4.1.0",
|
|
26
27
|
"js-cookie": "^3.0.5",
|
|
27
28
|
"ra-language-russian": "^4.14.2",
|
|
28
29
|
"react": "^18.3.1",
|
|
29
30
|
"react-admin": "^5.4.0",
|
|
31
|
+
"react-datepicker": "^8.1.0",
|
|
30
32
|
"react-dom": "^18.3.1",
|
|
31
33
|
"validator": "^13.12.0"
|
|
32
34
|
},
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
"@types/react-window": "^1.8.8",
|
|
39
41
|
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
40
42
|
"@typescript-eslint/parser": "^7.12.0",
|
|
43
|
+
"css-loader": "^7.1.2",
|
|
41
44
|
"dotenv": "^16.4.5",
|
|
42
45
|
"eslint": "^8",
|
|
43
46
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
"husky": "^9.0.11",
|
|
48
51
|
"prettier": "^3.2",
|
|
49
52
|
"prettier-plugin-organize-imports": "^3.2",
|
|
53
|
+
"style-loader": "^4.0.0",
|
|
50
54
|
"ts-loader": "^9.5.1",
|
|
51
55
|
"typescript": "^5.4.5",
|
|
52
56
|
"webpack": "^5.91.0",
|
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import IconButton from "@mui/material/IconButton"
|
|
2
2
|
import SvgIcon from "@mui/material/SvgIcon"
|
|
3
3
|
import Tooltip from "@mui/material/Tooltip"
|
|
4
|
+
|
|
4
5
|
import Typography from "@mui/material/Typography"
|
|
5
6
|
import {
|
|
6
7
|
AdminContext,
|
|
@@ -27,11 +28,11 @@ export function MuffinAdmin(props: AdminProps) {
|
|
|
27
28
|
const muffinI18nProvider = buildProvider(
|
|
28
29
|
backendLocales
|
|
29
30
|
? Object.fromEntries(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
Object.entries(muffinTranslations).map(([locale, messages]) => [
|
|
32
|
+
locale,
|
|
33
|
+
deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
|
|
34
|
+
])
|
|
35
|
+
)
|
|
35
36
|
: muffinTranslations
|
|
36
37
|
)
|
|
37
38
|
|
package/src/buildRA.tsx
CHANGED
|
@@ -36,7 +36,8 @@ import {
|
|
|
36
36
|
} from "react-admin"
|
|
37
37
|
|
|
38
38
|
import { AvatarField, CopyField, EditableBooleanField, FKField, JsonField } from "./fields"
|
|
39
|
-
import {
|
|
39
|
+
import { DateRangeFilter, Filter } from "./filters"
|
|
40
|
+
import { FKInput, JsonInput, TimestampInput } from "./inputs"
|
|
40
41
|
|
|
41
42
|
const UI: Record<string, JSX.ElementType> = {
|
|
42
43
|
// Fields
|
|
@@ -68,7 +69,6 @@ const UI: Record<string, JSX.ElementType> = {
|
|
|
68
69
|
BooleanInput,
|
|
69
70
|
CheckboxGroupInput,
|
|
70
71
|
DateInput,
|
|
71
|
-
FilterInput,
|
|
72
72
|
DateTimeInput,
|
|
73
73
|
FKInput,
|
|
74
74
|
FileInput,
|
|
@@ -84,6 +84,10 @@ const UI: Record<string, JSX.ElementType> = {
|
|
|
84
84
|
SelectInput,
|
|
85
85
|
TextInput,
|
|
86
86
|
TimestampInput,
|
|
87
|
+
|
|
88
|
+
// Filters
|
|
89
|
+
Filter,
|
|
90
|
+
DateRangeFilter,
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
export function buildRAComponent(name: string, props: any) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InputProps, useInput } from "react-admin"
|
|
2
|
+
import { DateRangeInput } from "../inputs/DateRangeInput"
|
|
3
|
+
|
|
4
|
+
export function DateRangeFilter(props: InputProps) {
|
|
5
|
+
const { field } = useInput(props)
|
|
6
|
+
|
|
7
|
+
const onChange = (dates: [Date, Date]) => {
|
|
8
|
+
field.onChange({
|
|
9
|
+
$between: dates.map((d) => d?.toISOString() || null),
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
let filterValue = field.value.$between ?? [null, null]
|
|
13
|
+
if (!Array.isArray(filterValue)) filterValue = [null, null]
|
|
14
|
+
const value = filterValue.map((d: string) => (d ? new Date(d) : d))
|
|
15
|
+
|
|
16
|
+
return <DateRangeInput value={value} onChange={onChange} />
|
|
17
|
+
}
|
|
@@ -15,7 +15,7 @@ const OPERATORS = {
|
|
|
15
15
|
$le: "≤",
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function
|
|
18
|
+
export function Filter({ type = "text", ...props }: any) {
|
|
19
19
|
const { field } = useInput({
|
|
20
20
|
format: (value: any) => (value ? value[Object.keys(value)[0]] : ""),
|
|
21
21
|
...props,
|
package/src/index.tsx
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import TextField from "@mui/material/TextField"
|
|
2
|
+
import { enGB, ru } from "date-fns/locale"
|
|
3
|
+
import { useLocale } from "react-admin"
|
|
4
|
+
import DatePicker, { registerLocale } from "react-datepicker"
|
|
5
|
+
import "react-datepicker/dist/react-datepicker.css"
|
|
6
|
+
|
|
7
|
+
registerLocale("ru", ru)
|
|
8
|
+
registerLocale("en", enGB)
|
|
9
|
+
|
|
10
|
+
type TProps = {
|
|
11
|
+
value: [Date, Date]
|
|
12
|
+
onChange: (value: [Date, Date]) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function DateRangeInput({ value, onChange }: TProps) {
|
|
16
|
+
const [startDate, endDate] = value
|
|
17
|
+
const locale = useLocale()
|
|
18
|
+
return (
|
|
19
|
+
<DatePicker
|
|
20
|
+
withPortal
|
|
21
|
+
locale={locale}
|
|
22
|
+
selectsRange
|
|
23
|
+
endDate={endDate}
|
|
24
|
+
onChange={onChange}
|
|
25
|
+
startDate={startDate}
|
|
26
|
+
customInput={<TextField variant="outlined" />}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
package/src/inputs/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function FilterInput({ type, ...props }: any): import("react/jsx-runtime").JSX.Element;
|