muffin-admin 9.0.0 → 9.1.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/filters/DateRangeFilter.d.ts +1 -2
- package/dist/filters/DateRangeFilter.js +1 -1
- package/dist/filters/Filter.d.ts +2 -1
- package/dist/filters/Filter.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/inputs/DateRangeInput.d.ts +3 -2
- package/dist/inputs/DateRangeInput.js +16 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/filters/DateRangeFilter.tsx +3 -3
- package/src/filters/Filter.tsx +7 -2
- package/src/index.tsx +1 -1
- package/src/inputs/DateRangeInput.tsx +13 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useInput } from "react-admin"
|
|
2
2
|
import { DateRangeInput } from "../inputs/DateRangeInput"
|
|
3
3
|
|
|
4
|
-
export function DateRangeFilter(props
|
|
4
|
+
export function DateRangeFilter(props) {
|
|
5
5
|
const { field } = useInput(props)
|
|
6
6
|
|
|
7
7
|
const onChange = (dates: [Date, Date]) => {
|
|
@@ -13,5 +13,5 @@ export function DateRangeFilter(props: InputProps) {
|
|
|
13
13
|
if (!Array.isArray(filterValue)) filterValue = [null, null]
|
|
14
14
|
const value = filterValue.map((d: string) => (d ? new Date(d) : d))
|
|
15
15
|
|
|
16
|
-
return <DateRangeInput value={value} onChange={onChange} />
|
|
16
|
+
return <DateRangeInput value={value} onChange={onChange} {...props} />
|
|
17
17
|
}
|
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 { useInput } from "react-admin"
|
|
7
|
+
import { FieldTitle, InputProps, useInput } from "react-admin"
|
|
8
8
|
|
|
9
9
|
const OPERATORS = {
|
|
10
10
|
$eq: "=",
|
|
@@ -15,7 +15,7 @@ const OPERATORS = {
|
|
|
15
15
|
$le: "≤",
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function Filter({ type = "text", ...props }:
|
|
18
|
+
export function Filter({ type = "text", ...props }: InputProps) {
|
|
19
19
|
const { field } = useInput({
|
|
20
20
|
format: (value: any) => (value ? value[Object.keys(value)[0]] : ""),
|
|
21
21
|
...props,
|
|
@@ -28,6 +28,8 @@ export function Filter({ type = "text", ...props }: any) {
|
|
|
28
28
|
|
|
29
29
|
const [menuEl, setMenuEl] = useState(null)
|
|
30
30
|
const open = Boolean(menuEl)
|
|
31
|
+
const { label, source, resource, isRequired } = props
|
|
32
|
+
|
|
31
33
|
return (
|
|
32
34
|
<>
|
|
33
35
|
<FormGroup row sx={{ flexWrap: "nowrap" }}>
|
|
@@ -45,6 +47,9 @@ export function Filter({ type = "text", ...props }: any) {
|
|
|
45
47
|
value={field.value}
|
|
46
48
|
variant="outlined"
|
|
47
49
|
type={type}
|
|
50
|
+
label={
|
|
51
|
+
<FieldTitle label={label} source={source} resource={resource} isRequired={isRequired} />
|
|
52
|
+
}
|
|
48
53
|
/>
|
|
49
54
|
</FormGroup>
|
|
50
55
|
<Menu open={open} onClose={() => setMenuEl(null)} anchorEl={menuEl}>
|
package/src/index.tsx
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import TextField from "@mui/material/TextField"
|
|
2
2
|
import { enGB, ru } from "date-fns/locale"
|
|
3
|
-
import { useLocale } from "react-admin"
|
|
3
|
+
import { FieldTitle, InputProps, useLocale } from "react-admin"
|
|
4
4
|
import DatePicker, { registerLocale } from "react-datepicker"
|
|
5
5
|
import "react-datepicker/dist/react-datepicker.css"
|
|
6
6
|
|
|
7
7
|
registerLocale("ru", ru)
|
|
8
8
|
registerLocale("en", enGB)
|
|
9
9
|
|
|
10
|
-
type TProps = {
|
|
10
|
+
type TProps = InputProps & {
|
|
11
11
|
value: [Date, Date]
|
|
12
12
|
onChange: (value: [Date, Date]) => void
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function DateRangeInput({ value, onChange }: TProps) {
|
|
15
|
+
export function DateRangeInput({ value, onChange, ...props }: TProps) {
|
|
16
16
|
const [startDate, endDate] = value
|
|
17
17
|
const locale = useLocale()
|
|
18
|
+
const { label, source, resource, isRequired } = props
|
|
19
|
+
|
|
18
20
|
return (
|
|
19
21
|
<DatePicker
|
|
20
22
|
withPortal
|
|
@@ -23,7 +25,14 @@ export function DateRangeInput({ value, onChange }: TProps) {
|
|
|
23
25
|
endDate={endDate}
|
|
24
26
|
onChange={onChange}
|
|
25
27
|
startDate={startDate}
|
|
26
|
-
customInput={
|
|
28
|
+
customInput={
|
|
29
|
+
<TextField
|
|
30
|
+
variant="outlined"
|
|
31
|
+
label={
|
|
32
|
+
<FieldTitle label={label} source={source} resource={resource} isRequired={isRequired} />
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
}
|
|
27
36
|
/>
|
|
28
37
|
)
|
|
29
38
|
}
|