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/dist/buildRA.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ArrayField, ArrayInput, AutocompleteArrayInput, AutocompleteInput, BooleanField, BooleanInput, CheckboxGroupInput, ChipField, DateField, DateInput, DateTimeInput, EmailField, FileField, FileInput, ImageField, ImageInput, NullableBooleanInput, NumberField, NumberInput, PasswordInput, RadioButtonGroupInput, ReferenceArrayField, ReferenceArrayInput, ReferenceField, ReferenceInput, ReferenceManyField, required, RichTextField, SelectArrayInput, SelectField, SelectInput, TextField, TextInput, UrlField, } from "react-admin";
|
|
3
3
|
import { AvatarField, CopyField, EditableBooleanField, FKField, JsonField } from "./fields";
|
|
4
|
-
import {
|
|
4
|
+
import { DateRangeFilter, Filter } from "./filters";
|
|
5
|
+
import { FKInput, JsonInput, TimestampInput } from "./inputs";
|
|
5
6
|
const UI = {
|
|
6
7
|
// Fields
|
|
7
8
|
BooleanField,
|
|
@@ -31,7 +32,6 @@ const UI = {
|
|
|
31
32
|
BooleanInput,
|
|
32
33
|
CheckboxGroupInput,
|
|
33
34
|
DateInput,
|
|
34
|
-
FilterInput,
|
|
35
35
|
DateTimeInput,
|
|
36
36
|
FKInput,
|
|
37
37
|
FileInput,
|
|
@@ -47,6 +47,9 @@ const UI = {
|
|
|
47
47
|
SelectInput,
|
|
48
48
|
TextInput,
|
|
49
49
|
TimestampInput,
|
|
50
|
+
// Filters
|
|
51
|
+
Filter,
|
|
52
|
+
DateRangeFilter,
|
|
50
53
|
};
|
|
51
54
|
export function buildRAComponent(name, props) {
|
|
52
55
|
const Item = UI[name];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useInput } from "react-admin";
|
|
3
|
+
import { DateRangeInput } from "../inputs/DateRangeInput";
|
|
4
|
+
export function DateRangeFilter(props) {
|
|
5
|
+
var _a;
|
|
6
|
+
const { field } = useInput(props);
|
|
7
|
+
const onChange = (dates) => {
|
|
8
|
+
field.onChange({
|
|
9
|
+
$between: dates.map((d) => (d === null || d === void 0 ? void 0 : d.toISOString()) || null),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
let filterValue = (_a = field.value.$between) !== null && _a !== void 0 ? _a : [null, null];
|
|
13
|
+
if (!Array.isArray(filterValue))
|
|
14
|
+
filterValue = [null, null];
|
|
15
|
+
const value = filterValue.map((d) => (d ? new Date(d) : d));
|
|
16
|
+
return _jsx(DateRangeInput, { value: value, onChange: onChange });
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Filter({ type, ...props }: any): import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,7 +25,7 @@ const OPERATORS = {
|
|
|
25
25
|
$lt: "<",
|
|
26
26
|
$le: "≤",
|
|
27
27
|
};
|
|
28
|
-
export function
|
|
28
|
+
export function Filter(_a) {
|
|
29
29
|
var { type = "text" } = _a, props = __rest(_a, ["type"]);
|
|
30
30
|
const { field } = useInput(Object.assign({ format: (value) => (value ? value[Object.keys(value)[0]] : "") }, props));
|
|
31
31
|
const [op, setOp] = useState((field.value && Object.keys(field.value)[0]) || "$eq");
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import TextField from "@mui/material/TextField";
|
|
3
|
+
import { enGB, ru } from "date-fns/locale";
|
|
4
|
+
import { useLocale } from "react-admin";
|
|
5
|
+
import DatePicker, { registerLocale } from "react-datepicker";
|
|
6
|
+
import "react-datepicker/dist/react-datepicker.css";
|
|
7
|
+
registerLocale("ru", ru);
|
|
8
|
+
registerLocale("en", enGB);
|
|
9
|
+
export function DateRangeInput({ value, onChange }) {
|
|
10
|
+
const [startDate, endDate] = value;
|
|
11
|
+
const locale = useLocale();
|
|
12
|
+
return (_jsx(DatePicker, { withPortal: true, locale: locale, selectsRange: true, endDate: endDate, onChange: onChange, startDate: startDate, customInput: _jsx(TextField, { variant: "outlined" }) }));
|
|
13
|
+
}
|
package/dist/inputs/index.d.ts
CHANGED
package/dist/inputs/index.js
CHANGED