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 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 { FilterInput, FKInput, JsonInput, TimestampInput } from "./inputs";
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,2 @@
1
+ import { InputProps } from "react-admin";
2
+ export declare function DateRangeFilter(props: InputProps): import("react/jsx-runtime").JSX.Element;
@@ -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 FilterInput(_a) {
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");
@@ -0,0 +1,2 @@
1
+ export * from "./DateRangeFilter";
2
+ export * from "./Filter";
@@ -0,0 +1,2 @@
1
+ export * from "./DateRangeFilter";
2
+ export * from "./Filter";
package/dist/index.d.ts CHANGED
@@ -18,4 +18,4 @@ export * from "./fields";
18
18
  export * from "./hooks";
19
19
  export * from "./types";
20
20
  export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
21
- export declare const VERSION = "8.5.6";
21
+ export declare const VERSION = "9.0.0";
package/dist/index.js CHANGED
@@ -41,4 +41,4 @@ export function initAdmin() {
41
41
  root.render(_jsx(MuffinAdminContext.Provider, { value: adminOpts, children: _jsx(MuffinAdmin, {}) }));
42
42
  });
43
43
  }
44
- export const VERSION = "8.5.6";
44
+ export const VERSION = "9.0.0";
@@ -0,0 +1,7 @@
1
+ import "react-datepicker/dist/react-datepicker.css";
2
+ type TProps = {
3
+ value: [Date, Date];
4
+ onChange: (value: [Date, Date]) => void;
5
+ };
6
+ export declare function DateRangeInput({ value, onChange }: TProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -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
+ }
@@ -1,4 +1,3 @@
1
- export * from "./FilterInput";
2
1
  export * from "./FKInput";
3
2
  export * from "./JsonInput";
4
3
  export * from "./TimestampInput";
@@ -1,4 +1,3 @@
1
- export * from "./FilterInput";
2
1
  export * from "./FKInput";
3
2
  export * from "./JsonInput";
4
3
  export * from "./TimestampInput";