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/dist/buildRA.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/inputs/TimestampInput.d.ts +5 -0
- package/dist/inputs/TimestampInput.js +27 -0
- package/dist/inputs/index.d.ts +1 -0
- package/dist/inputs/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/buildRA.tsx +3 -2
- package/src/index.tsx +1 -1
- package/src/inputs/TimestampInput.tsx +20 -0
- package/src/inputs/index.ts +1 -0
package/package.json
CHANGED
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
|
-
|
|
85
|
+
TimestampInput,
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
export function buildRAComponent(name: string, props: any) {
|
package/src/index.tsx
CHANGED
|
@@ -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
|
+
}
|
package/src/inputs/index.ts
CHANGED