muffin-admin 7.0.5 → 8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "7.0.5",
3
+ "version": "8.0.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
package/src/buildRA.tsx CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  } from "react-admin"
37
37
 
38
38
  import { AvatarField, EditableBooleanField, FKField, JsonField } from "./fields"
39
- import { FilterInput, FKInput, JsonInput } from "./inputs"
39
+ import { FilterInput, FKInput, JsonInput, TimestampInput } from "./inputs"
40
40
 
41
41
  const UI: Record<string, JSX.ElementType> = {
42
42
  // Fields
@@ -79,9 +79,10 @@ const UI: Record<string, JSX.ElementType> = {
79
79
  RadioButtonGroupInput,
80
80
  ReferenceArrayInput,
81
81
  ReferenceInput,
82
+ SelectArrayInput,
82
83
  SelectInput,
83
84
  TextInput,
84
- SelectArrayInput,
85
+ TimestampInput,
85
86
  }
86
87
 
87
88
  export function buildRAComponent(name: string, props: any) {
package/src/index.tsx CHANGED
@@ -35,4 +35,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
35
35
  )
36
36
  }
37
37
 
38
- export const VERSION = "7.0.5"
38
+ export const VERSION = "8.0.0"
@@ -0,0 +1,20 @@
1
+ import { format } from "date-fns"
2
+ import { DateTimeInput } from "react-admin"
3
+
4
+ export function TimestampInput({ source, ms, ...props }) {
5
+ return (
6
+ <DateTimeInput
7
+ source={source}
8
+ {...props}
9
+ format={(v) => {
10
+ if (!v) return ""
11
+ const value = new Date(ms ? v : v * 1000)
12
+ return format(value, "yyyy-MM-dd'T'HH:mm:ss")
13
+ }}
14
+ parse={(v) => {
15
+ if (!v) return null
16
+ return new Date(v).valueOf() / (ms ? 1 : 1000)
17
+ }}
18
+ />
19
+ )
20
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./FilterInput"
2
2
  export * from "./FKInput"
3
3
  export * from "./JsonInput"
4
+ export * from "./TimestampInput"