muffin-admin 9.0.0 → 9.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "9.0.0",
3
+ "version": "9.1.1",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -37,6 +37,7 @@ export function MuffinDashboard() {
37
37
  }
38
38
 
39
39
  setupAdmin(["dashboard"], MuffinDashboard)
40
+ setupAdmin(["dashboard-actions"], () => null)
40
41
 
41
42
  function AdminCards({ src }: { src: AdminDashboardBlock | AdminDashboardBlock[] }) {
42
43
  if (Array.isArray(src))
@@ -1,7 +1,7 @@
1
- import { InputProps, useInput } from "react-admin"
1
+ import { useInput } from "react-admin"
2
2
  import { DateRangeInput } from "../inputs/DateRangeInput"
3
3
 
4
- export function DateRangeFilter(props: InputProps) {
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
  }
@@ -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 }: any) {
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
@@ -36,4 +36,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
36
36
  )
37
37
  }
38
38
 
39
- export const VERSION = "9.0.0"
39
+ export const VERSION = "9.1.1"
@@ -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={<TextField variant="outlined" />}
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
  }