mirror of
https://github.com/zhigang1992/firecms.git
synced 2026-06-19 18:03:20 +08:00
Typescript 4.5
This commit is contained in:
@@ -115,6 +115,7 @@ function SampleApp() {
|
||||
schema: testEntitySchema,
|
||||
callbacks: testCallbacks,
|
||||
name: "Test entity",
|
||||
properties: ["subcollection_test_subcollection", "gallery"],
|
||||
subcollections: [{
|
||||
path: "test_subcollection",
|
||||
schema: testEntitySchema,
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
"react-router-dom": "^6.0.0",
|
||||
"react-scripts": "^4.0.3",
|
||||
"tsd": "0.17.0",
|
||||
"typescript": "^4.4.3"
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -161,6 +161,8 @@ export function buildColumnsFromSchema<M, AdditionalKey extends string, UserType
|
||||
: {};
|
||||
}, [additionalColumns]);
|
||||
|
||||
console.log("additionalColumns", additionalColumns)
|
||||
|
||||
// on ESC key press
|
||||
useEffect(() => {
|
||||
const escFunction = (event: any) => {
|
||||
|
||||
@@ -329,7 +329,7 @@ export function EntityForm<M>({
|
||||
const formFields = (
|
||||
<Grid container spacing={4}>
|
||||
|
||||
{Object.entries<Property>(schemaProperties)
|
||||
{Object.entries<Property>(schemaProperties as Record<string, Property<any>>)
|
||||
.filter(([key, property]) => !isHidden(property))
|
||||
.map(([key, property]) => {
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ export interface EnumValueConfig {
|
||||
* Record of properties of an entity or a map property
|
||||
* @category Entity properties
|
||||
*/
|
||||
export type Properties<M extends { [Key: string]: any }> = {
|
||||
export type Properties<M extends { [Key: string]: any } = any> = {
|
||||
[k in keyof M]: Property<M[k]>;
|
||||
};
|
||||
|
||||
@@ -337,7 +337,7 @@ export interface MapProperty<T extends { [Key: string]: any } = any> extends Bas
|
||||
/**
|
||||
* Record of properties included in this map.
|
||||
*/
|
||||
properties?: Properties<any>; // TODO: this should be Properties<T> but it breaks if building properties without `buildProperties`
|
||||
properties?: Properties<Partial<T>>; // TODO: this should be Properties<T> but it breaks if building properties without `buildProperties`
|
||||
|
||||
/**
|
||||
* Rules for validating this property
|
||||
|
||||
@@ -278,5 +278,67 @@ export const siteConfig: FirebaseCMSAppProps = {
|
||||
]
|
||||
};
|
||||
|
||||
export const usersSchema = buildSchema({
|
||||
name: "User",
|
||||
properties: {
|
||||
first_name: {
|
||||
title: "First name",
|
||||
dataType: "string"
|
||||
},
|
||||
last_name: {
|
||||
title: "Last name",
|
||||
dataType: "string"
|
||||
},
|
||||
email: {
|
||||
title: "Email",
|
||||
dataType: "string",
|
||||
validation: {
|
||||
email: true
|
||||
}
|
||||
},
|
||||
phone: {
|
||||
title: "Phone",
|
||||
dataType: "string"
|
||||
},
|
||||
liked_products: {
|
||||
dataType: "array",
|
||||
title: "Liked products",
|
||||
description: "Products this user has liked",
|
||||
of: {
|
||||
dataType: "reference",
|
||||
path: "products"
|
||||
}
|
||||
},
|
||||
picture: {
|
||||
title: "Picture",
|
||||
dataType: "map",
|
||||
properties: {
|
||||
large: {
|
||||
title: "Large",
|
||||
dataType: "string",
|
||||
config: {
|
||||
url: "image"
|
||||
},
|
||||
validation: {
|
||||
url: true
|
||||
}
|
||||
},
|
||||
thumbnail: {
|
||||
title: "Thumbnail",
|
||||
dataType: "string",
|
||||
config: {
|
||||
url: "image"
|
||||
},
|
||||
validation: {
|
||||
url: true
|
||||
}
|
||||
}
|
||||
},
|
||||
previewProperties: ["large"]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user