@firecms/collection_editor 3.0.0-canary.279 → 3.0.0-canary.280

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.
@@ -2,4 +2,4 @@ import { EntityCollection } from "@firecms/core";
2
2
  /**
3
3
  * This function is used to infer the configuration of a collection given its path.
4
4
  */
5
- export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionPaths: string[]) => Promise<Partial<EntityCollection> | null>;
5
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionPaths: string[], databaseId?: string) => Promise<Partial<EntityCollection> | null>;
@@ -1,5 +1,5 @@
1
1
  export declare function StringPropertyField({ widgetId, disabled, showErrors }: {
2
- widgetId: "text_field" | "multiline" | "email";
2
+ widgetId: "text_field" | "multiline" | "email" | "user_select";
3
3
  disabled: boolean;
4
4
  showErrors: boolean;
5
5
  }): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.279",
4
+ "version": "3.0.0-canary.280",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
- "@firecms/data_export": "^3.0.0-canary.279",
11
- "@firecms/data_import": "^3.0.0-canary.279",
12
- "@firecms/data_import_export": "^3.0.0-canary.279",
13
- "@firecms/formex": "^3.0.0-canary.279",
14
- "@firecms/schema_inference": "^3.0.0-canary.279",
15
- "@firecms/ui": "^3.0.0-canary.279",
10
+ "@firecms/data_export": "^3.0.0-canary.280",
11
+ "@firecms/data_import": "^3.0.0-canary.280",
12
+ "@firecms/data_import_export": "^3.0.0-canary.280",
13
+ "@firecms/formex": "^3.0.0-canary.280",
14
+ "@firecms/schema_inference": "^3.0.0-canary.280",
15
+ "@firecms/ui": "^3.0.0-canary.280",
16
16
  "json5": "^2.2.3",
17
17
  "prism-react-renderer": "^2.4.1"
18
18
  },
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "43a93dc4d64d13ff6b146cb8e42d483e36253df3"
72
+ "gitHead": "4c511808713ad163340dd67cb07f4bbba3d15c56"
73
73
  }
@@ -49,7 +49,7 @@ export interface ConfigControllerProviderProps {
49
49
  icon: React.ReactNode
50
50
  };
51
51
 
52
- getUser?: (uid: string) => User | null
52
+ getUser?: (uid: string) => User | null;
53
53
 
54
54
  getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
55
55
 
@@ -3,4 +3,4 @@ import { EntityCollection } from "@firecms/core";
3
3
  /**
4
4
  * This function is used to infer the configuration of a collection given its path.
5
5
  */
6
- export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionPaths: string[]) => Promise<Partial<EntityCollection> | null>;
6
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionPaths: string[], databaseId?:string) => Promise<Partial<EntityCollection> | null>;
@@ -329,7 +329,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
329
329
 
330
330
  const doCollectionInference = collectionInference ? (collection: PersistedCollection<any>) => {
331
331
  if (!collectionInference) return undefined;
332
- return collectionInference?.(collection.path, collection.collectionGroup ?? false, parentPaths ?? []);
332
+ return collectionInference?.(collection.path, collection.collectionGroup ?? false, parentPaths ?? [], collection.databaseId);
333
333
  } : undefined;
334
334
 
335
335
  const inferCollectionFromData = async (newCollection: PersistedCollection<M>) => {
@@ -150,7 +150,6 @@ export const PropertyForm = React.memo(
150
150
  validateOnChange: true,
151
151
  validateOnInitialRender: true,
152
152
  onSubmit: (newPropertyWithId, controller) => {
153
- console.debug("onSubmit", newPropertyWithId);
154
153
  const {
155
154
  id,
156
155
  ...property
@@ -401,6 +400,7 @@ function PropertyEditFormFields({
401
400
  let childComponent;
402
401
  if (selectedFieldConfigId === "text_field" ||
403
402
  selectedFieldConfigId === "multiline" ||
403
+ selectedFieldConfigId === "user_select" ||
404
404
  selectedFieldConfigId === "email") {
405
405
  childComponent =
406
406
  <StringPropertyField widgetId={selectedFieldConfigId}
@@ -607,6 +607,7 @@ const WIDGET_TYPE_MAP: Record<PropertyConfigId, string> = {
607
607
  switch: "Boolean",
608
608
  select: "Select",
609
609
  multi_select: "Select",
610
+ user_select: "Select",
610
611
  number_input: "Number",
611
612
  number_select: "Select",
612
613
  multi_number_select: "Select",
@@ -4,6 +4,7 @@ import {
4
4
  EntityCollectionTable,
5
5
  Properties,
6
6
  useAuthController,
7
+ useNavigationController,
7
8
  useSelectionController
8
9
  } from "@firecms/core";
9
10
  import { useEffect, useState } from "react";
@@ -20,11 +21,18 @@ export function CollectionEditorImportDataPreview({
20
21
  }) {
21
22
 
22
23
  const authController = useAuthController();
24
+ const navigation = useNavigationController();
23
25
  const [loading, setLoading] = useState<boolean>(false);
24
26
 
25
27
  async function loadEntities() {
26
- // const propertiesMapping = getPropertiesMapping(importConfig.originProperties, properties, importConfig.headersMapping);
27
- const mappedData = importConfig.importData.map(d => convertDataToEntity(authController, d, importConfig.idColumn, importConfig.headersMapping, properties, "TEMP_PATH", importConfig.defaultValues));
28
+ const mappedData = importConfig.importData.map(d => convertDataToEntity(authController,
29
+ navigation,
30
+ d,
31
+ importConfig.idColumn,
32
+ importConfig.headersMapping,
33
+ properties,
34
+ "TEMP_PATH",
35
+ importConfig.defaultValues));
28
36
  importConfig.setEntities(mappedData);
29
37
  }
30
38
 
@@ -10,7 +10,7 @@ export function StringPropertyField({
10
10
  disabled,
11
11
  showErrors
12
12
  }: {
13
- widgetId: "text_field" | "multiline" | "email";
13
+ widgetId: "text_field" | "multiline" | "email" | "user_select";
14
14
  disabled: boolean;
15
15
  showErrors: boolean;
16
16
  }) {
@@ -33,6 +33,10 @@ export function StringPropertyField({
33
33
  trim={true}
34
34
  uppercase={true}
35
35
  showErrors={showErrors}/>}
36
+ {widgetId === "user_select" &&
37
+ <StringPropertyValidation disabled={disabled}
38
+ showErrors={showErrors}/>}
39
+
36
40
  {widgetId === "multiline" &&
37
41
  <StringPropertyValidation disabled={disabled}
38
42
  length={true}
@@ -6,6 +6,7 @@ export const supportedFieldsIds: PropertyConfigId[] = [
6
6
  "markdown",
7
7
  "url",
8
8
  "email",
9
+ "user_select",
9
10
  "select",
10
11
  "multi_select",
11
12
  "number_input",
@@ -27,7 +27,24 @@ export function updatePropertyFromWidget(propertyData: any,
27
27
  markdown: undefined,
28
28
  email: undefined,
29
29
  url: undefined,
30
- enumValues: undefined
30
+ enumValues: undefined,
31
+ userSelect: undefined
32
+ } satisfies StringProperty
33
+ );
34
+ } else if (selectedWidgetId === "user_select") {
35
+ updatedProperty = mergeDeep(
36
+ propertyData,
37
+ {
38
+ dataType: "string",
39
+ propertyConfig: "text_field",
40
+ editable: propertyData.editable !== undefined ? propertyData.editable : true,
41
+ storage: undefined,
42
+ multiline: undefined,
43
+ markdown: undefined,
44
+ email: undefined,
45
+ url: undefined,
46
+ enumValues: undefined,
47
+ userSelect: true
31
48
  } satisfies StringProperty
32
49
  );
33
50
  } else if (selectedWidgetId === "multiline") {
@@ -42,7 +59,8 @@ export function updatePropertyFromWidget(propertyData: any,
42
59
  markdown: undefined,
43
60
  email: undefined,
44
61
  url: undefined,
45
- enumValues: undefined
62
+ enumValues: undefined,
63
+ userSelect: undefined
46
64
  } satisfies StringProperty
47
65
  );
48
66
  } else if (selectedWidgetId === "markdown") {
@@ -56,7 +74,8 @@ export function updatePropertyFromWidget(propertyData: any,
56
74
  multiline: undefined,
57
75
  markdown: true,
58
76
  email: undefined,
59
- url: undefined
77
+ url: undefined,
78
+ userSelect: undefined
60
79
  } satisfies StringProperty
61
80
  );
62
81
  } else if (selectedWidgetId === "url") {
@@ -71,7 +90,8 @@ export function updatePropertyFromWidget(propertyData: any,
71
90
  markdown: undefined,
72
91
  email: undefined,
73
92
  url: true,
74
- enumValues: undefined
93
+ enumValues: undefined,
94
+ userSelect: undefined
75
95
  } satisfies StringProperty
76
96
  );
77
97
  } else if (selectedWidgetId === "email") {
@@ -86,7 +106,8 @@ export function updatePropertyFromWidget(propertyData: any,
86
106
  markdown: undefined,
87
107
  email: true,
88
108
  url: undefined,
89
- enumValues: undefined
109
+ enumValues: undefined,
110
+ userSelect: undefined
90
111
  } satisfies StringProperty
91
112
  );
92
113
  } else if (selectedWidgetId === "select") {
@@ -101,7 +122,8 @@ export function updatePropertyFromWidget(propertyData: any,
101
122
  markdown: undefined,
102
123
  email: undefined,
103
124
  url: undefined,
104
- enumValues: propertyData.enumValues ?? []
125
+ enumValues: propertyData.enumValues ?? [],
126
+ userSelect: undefined
105
127
  } satisfies StringProperty
106
128
  );
107
129
  } else if (selectedWidgetId === "multi_select") {