@firecms/collection_editor 3.0.0-alpha.9 → 3.0.0-beta.2-pre.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.
Files changed (145) hide show
  1. package/dist/ConfigControllerProvider.d.ts +3 -2
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.es.js +3128 -4094
  4. package/dist/index.es.js.map +1 -1
  5. package/dist/index.umd.js +3 -1
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/types/collection_editor_controller.d.ts +22 -7
  8. package/dist/types/collection_inference.d.ts +1 -1
  9. package/dist/types/config_controller.d.ts +32 -5
  10. package/dist/types/persisted_collection.d.ts +3 -1
  11. package/dist/ui/CollectionViewHeaderAction.d.ts +10 -0
  12. package/dist/{components → ui}/EditorCollectionAction.d.ts +1 -1
  13. package/dist/ui/MissingReferenceWidget.d.ts +3 -0
  14. package/dist/ui/NewCollectionButton.d.ts +1 -0
  15. package/dist/ui/PropertyAddColumnComponent.d.ts +6 -0
  16. package/dist/ui/RootCollectionSuggestions.d.ts +1 -0
  17. package/dist/{components → ui}/collection_editor/CollectionDetailsForm.d.ts +3 -2
  18. package/dist/{components → ui}/collection_editor/CollectionEditorDialog.d.ts +11 -6
  19. package/dist/{components → ui}/collection_editor/CollectionPropertiesEditorForm.d.ts +6 -3
  20. package/dist/{components → ui}/collection_editor/CollectionYupValidation.d.ts +3 -0
  21. package/dist/ui/collection_editor/EntityCustomViewsSelectDialog.d.ts +4 -0
  22. package/dist/ui/collection_editor/GetCodeDialog.d.ts +5 -0
  23. package/dist/{components → ui}/collection_editor/PropertyEditView.d.ts +8 -6
  24. package/dist/{components → ui}/collection_editor/PropertyFieldPreview.d.ts +4 -3
  25. package/dist/ui/collection_editor/PropertySelectItem.d.ts +8 -0
  26. package/dist/{components → ui}/collection_editor/PropertyTree.d.ts +8 -5
  27. package/dist/{components → ui}/collection_editor/SubcollectionsEditTab.d.ts +2 -2
  28. package/dist/{components → ui}/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  29. package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +7 -0
  30. package/dist/{components → ui}/collection_editor/import/clean_import_data.d.ts +1 -1
  31. package/dist/{components → ui}/collection_editor/properties/BlockPropertyField.d.ts +4 -1
  32. package/dist/{components → ui}/collection_editor/properties/CommonPropertyFields.d.ts +1 -0
  33. package/dist/{components → ui}/collection_editor/properties/MapPropertyField.d.ts +4 -1
  34. package/dist/{components → ui}/collection_editor/properties/RepeatPropertyField.d.ts +4 -1
  35. package/dist/{components → ui}/collection_editor/properties/StringPropertyField.d.ts +1 -1
  36. package/dist/ui/collection_editor/properties/UrlPropertyField.d.ts +4 -0
  37. package/dist/ui/collection_editor/templates/blog_template.d.ts +2 -0
  38. package/dist/ui/collection_editor/templates/pages_template.d.ts +2 -0
  39. package/dist/ui/collection_editor/templates/products_template.d.ts +2 -0
  40. package/dist/ui/collection_editor/templates/users_template.d.ts +2 -0
  41. package/dist/ui/collection_editor/utils/strings.d.ts +1 -0
  42. package/dist/ui/collection_editor/utils/supported_fields.d.ts +3 -0
  43. package/dist/ui/collection_editor/utils/update_property_for_widget.d.ts +2 -0
  44. package/dist/useCollectionEditorPlugin.d.ts +5 -3
  45. package/dist/utils/entities.d.ts +3 -4
  46. package/package.json +22 -19
  47. package/src/ConfigControllerProvider.tsx +336 -0
  48. package/src/index.ts +35 -0
  49. package/src/types/collection_editor_controller.tsx +42 -0
  50. package/src/types/collection_inference.ts +3 -0
  51. package/src/types/config_controller.tsx +60 -0
  52. package/src/types/config_permissions.ts +20 -0
  53. package/src/types/persisted_collection.ts +9 -0
  54. package/src/ui/CollectionViewHeaderAction.tsx +43 -0
  55. package/src/ui/EditorCollectionAction.tsx +109 -0
  56. package/src/ui/HomePageEditorCollectionAction.tsx +84 -0
  57. package/src/ui/MissingReferenceWidget.tsx +35 -0
  58. package/src/ui/NewCollectionButton.tsx +16 -0
  59. package/src/ui/NewCollectionCard.tsx +47 -0
  60. package/src/ui/PropertyAddColumnComponent.tsx +42 -0
  61. package/src/ui/RootCollectionSuggestions.tsx +55 -0
  62. package/src/ui/collection_editor/CollectionDetailsForm.tsx +366 -0
  63. package/src/ui/collection_editor/CollectionEditorDialog.tsx +754 -0
  64. package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +206 -0
  65. package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +481 -0
  66. package/src/ui/collection_editor/CollectionYupValidation.tsx +7 -0
  67. package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +37 -0
  68. package/src/ui/collection_editor/EnumForm.tsx +354 -0
  69. package/src/ui/collection_editor/GetCodeDialog.tsx +110 -0
  70. package/src/ui/collection_editor/PropertyEditView.tsx +558 -0
  71. package/src/ui/collection_editor/PropertyFieldPreview.tsx +203 -0
  72. package/src/ui/collection_editor/PropertySelectItem.tsx +32 -0
  73. package/src/ui/collection_editor/PropertyTree.tsx +233 -0
  74. package/src/ui/collection_editor/SubcollectionsEditTab.tsx +253 -0
  75. package/src/ui/collection_editor/UnsavedChangesDialog.tsx +47 -0
  76. package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +37 -0
  77. package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +260 -0
  78. package/src/ui/collection_editor/import/clean_import_data.ts +53 -0
  79. package/src/ui/collection_editor/properties/BlockPropertyField.tsx +135 -0
  80. package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +36 -0
  81. package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +137 -0
  82. package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +87 -0
  83. package/src/ui/collection_editor/properties/EnumPropertyField.tsx +117 -0
  84. package/src/ui/collection_editor/properties/FieldHelperView.tsx +13 -0
  85. package/src/ui/collection_editor/properties/KeyValuePropertyField.tsx +20 -0
  86. package/src/ui/collection_editor/properties/MapPropertyField.tsx +149 -0
  87. package/src/ui/collection_editor/properties/NumberPropertyField.tsx +38 -0
  88. package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +165 -0
  89. package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +108 -0
  90. package/src/ui/collection_editor/properties/StoragePropertyField.tsx +194 -0
  91. package/src/ui/collection_editor/properties/StringPropertyField.tsx +79 -0
  92. package/src/ui/collection_editor/properties/UrlPropertyField.tsx +89 -0
  93. package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +36 -0
  94. package/src/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +50 -0
  95. package/src/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +50 -0
  96. package/src/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +100 -0
  97. package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +132 -0
  98. package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +28 -0
  99. package/src/ui/collection_editor/templates/blog_template.ts +115 -0
  100. package/src/ui/collection_editor/templates/pages_template.ts +188 -0
  101. package/src/ui/collection_editor/templates/products_template.ts +88 -0
  102. package/src/ui/collection_editor/templates/users_template.ts +42 -0
  103. package/src/ui/collection_editor/util.ts +21 -0
  104. package/src/ui/collection_editor/utils/strings.ts +8 -0
  105. package/src/ui/collection_editor/utils/supported_fields.tsx +29 -0
  106. package/src/ui/collection_editor/utils/update_property_for_widget.ts +271 -0
  107. package/src/ui/collection_editor/utils/useTraceUpdate.tsx +23 -0
  108. package/src/useCollectionEditorController.tsx +9 -0
  109. package/src/useCollectionEditorPlugin.tsx +137 -0
  110. package/src/useCollectionsConfigController.tsx +9 -0
  111. package/src/utils/arrays.ts +3 -0
  112. package/src/utils/entities.ts +38 -0
  113. package/src/vite-env.d.ts +1 -0
  114. package/dist/components/collection_editor/PropertySelectItem.d.ts +0 -8
  115. package/dist/components/collection_editor/SelectIcons.d.ts +0 -6
  116. package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +0 -4
  117. package/dist/components/collection_editor/templates/blog_template.d.ts +0 -10
  118. package/dist/components/collection_editor/templates/products_template.d.ts +0 -12
  119. package/dist/components/collection_editor/templates/users_template.d.ts +0 -7
  120. package/dist/components/collection_editor/utils/supported_fields.d.ts +0 -3
  121. package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +0 -3
  122. package/dist/types/editable_properties.d.ts +0 -10
  123. package/dist/utils/icons.d.ts +0 -2
  124. package/dist/utils/synonyms.d.ts +0 -1951
  125. /package/dist/{components → ui}/HomePageEditorCollectionAction.d.ts +0 -0
  126. /package/dist/{components → ui}/NewCollectionCard.d.ts +0 -0
  127. /package/dist/{components → ui}/collection_editor/CollectionEditorWelcomeView.d.ts +0 -0
  128. /package/dist/{components → ui}/collection_editor/EnumForm.d.ts +0 -0
  129. /package/dist/{components → ui}/collection_editor/UnsavedChangesDialog.d.ts +0 -0
  130. /package/dist/{components → ui}/collection_editor/properties/BooleanPropertyField.d.ts +0 -0
  131. /package/dist/{components → ui}/collection_editor/properties/DateTimePropertyField.d.ts +0 -0
  132. /package/dist/{components → ui}/collection_editor/properties/EnumPropertyField.d.ts +0 -0
  133. /package/dist/{components → ui}/collection_editor/properties/FieldHelperView.d.ts +0 -0
  134. /package/dist/{components → ui}/collection_editor/properties/KeyValuePropertyField.d.ts +0 -0
  135. /package/dist/{components → ui}/collection_editor/properties/NumberPropertyField.d.ts +0 -0
  136. /package/dist/{components → ui}/collection_editor/properties/ReferencePropertyField.d.ts +0 -0
  137. /package/dist/{components → ui}/collection_editor/properties/StoragePropertyField.d.ts +0 -0
  138. /package/dist/{components → ui}/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +0 -0
  139. /package/dist/{components → ui}/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +0 -0
  140. /package/dist/{components → ui}/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +0 -0
  141. /package/dist/{components → ui}/collection_editor/properties/validation/NumberPropertyValidation.d.ts +0 -0
  142. /package/dist/{components → ui}/collection_editor/properties/validation/StringPropertyValidation.d.ts +0 -0
  143. /package/dist/{components → ui}/collection_editor/properties/validation/ValidationPanel.d.ts +0 -0
  144. /package/dist/{components → ui}/collection_editor/util.d.ts +0 -0
  145. /package/dist/{components → ui}/collection_editor/utils/useTraceUpdate.d.ts +0 -0
@@ -1,20 +1,35 @@
1
1
  import { CollectionEditorPermissionsBuilder } from "./config_permissions";
2
- import { EntityCollection } from "@firecms/core";
2
+ import { Property } from "@firecms/core";
3
+ import { PersistedCollection } from "./persisted_collection";
3
4
  /**
4
5
  * Controller to open the collection editor dialog.
5
- * @category Hooks and utilities
6
+ * @group Hooks and utilities
6
7
  */
7
8
  export interface CollectionEditorController {
8
9
  editCollection: (props: {
9
10
  path?: string;
10
11
  fullPath?: string;
11
- parentPathSegments: string[];
12
- parentCollection?: EntityCollection<any, any, any>;
12
+ parentCollectionIds: string[];
13
+ parentCollection?: PersistedCollection;
13
14
  }) => void;
14
15
  createCollection: (props: {
15
- group?: string;
16
- parentPathSegments: string[];
17
- parentCollection?: EntityCollection<any, any, any>;
16
+ initialValues?: {
17
+ group?: string;
18
+ path?: string;
19
+ name?: string;
20
+ };
21
+ parentCollectionIds: string[];
22
+ parentCollection?: PersistedCollection;
23
+ redirect: boolean;
24
+ }) => void;
25
+ editProperty: (props: {
26
+ propertyKey?: string;
27
+ property?: Property;
28
+ currentPropertiesOrder?: string[];
29
+ editedCollectionPath: string;
30
+ parentCollectionIds: string[];
31
+ collection: PersistedCollection;
18
32
  }) => void;
19
33
  configPermissions: CollectionEditorPermissionsBuilder;
34
+ rootPathSuggestions?: string[];
20
35
  }
@@ -1,2 +1,2 @@
1
1
  import { EntityCollection } from "@firecms/core";
2
- export type CollectionInference = (path: string, collectionGroup: boolean, parentPathSegments: string[]) => Promise<EntityCollection | null>;
2
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionIds: string[]) => Promise<Partial<EntityCollection> | null>;
@@ -1,4 +1,4 @@
1
- import { CMSType, EntityCollection } from "@firecms/core";
1
+ import { CMSType, Property } from "@firecms/core";
2
2
  import { PersistedCollection } from "./persisted_collection";
3
3
  /**
4
4
  * Use this controller to access the configuration that is stored externally,
@@ -7,18 +7,45 @@ import { PersistedCollection } from "./persisted_collection";
7
7
  export interface CollectionsConfigController {
8
8
  loading: boolean;
9
9
  collections?: PersistedCollection[];
10
+ getCollection: (id: string) => PersistedCollection;
10
11
  saveCollection: <M extends {
11
12
  [Key: string]: CMSType;
12
13
  }>(params: SaveCollectionParams<M>) => Promise<void>;
14
+ updateCollection: <M extends {
15
+ [Key: string]: CMSType;
16
+ }>(params: UpdateCollectionParams<M>) => Promise<void>;
17
+ saveProperty: (params: SavePropertyParams) => Promise<void>;
18
+ deleteProperty: (params: DeletePropertyParams) => Promise<void>;
13
19
  deleteCollection: (props: DeleteCollectionParams) => Promise<void>;
14
20
  }
21
+ export type UpdateCollectionParams<M extends Record<string, any>> = {
22
+ id: string;
23
+ collectionData: Partial<PersistedCollection<M>>;
24
+ previousPath?: string;
25
+ parentCollectionIds?: string[];
26
+ };
15
27
  export type SaveCollectionParams<M extends Record<string, any>> = {
16
- path: string;
17
- collectionData: EntityCollection<M>;
28
+ id: string;
29
+ collectionData: PersistedCollection<M>;
18
30
  previousPath?: string;
19
- parentPathSegments?: string[];
31
+ parentCollectionIds?: string[];
32
+ };
33
+ export type SavePropertyParams = {
34
+ path: string;
35
+ propertyKey: string;
36
+ namespace?: string;
37
+ newPropertiesOrder?: string[];
38
+ property: Property;
39
+ parentCollectionIds?: string[];
40
+ };
41
+ export type DeletePropertyParams = {
42
+ path: string;
43
+ propertyKey: string;
44
+ namespace?: string;
45
+ newPropertiesOrder?: string[];
46
+ parentCollectionIds?: string[];
20
47
  };
21
48
  export type DeleteCollectionParams = {
22
49
  path: string;
23
- parentPathSegments?: string[];
50
+ parentCollectionIds?: string[];
24
51
  };
@@ -1,4 +1,6 @@
1
1
  import { EntityCollection, User } from "@firecms/core";
2
- export type PersistedCollection<M extends Record<string, any> = any, AdditionalKey extends string = string, UserType extends User = User> = EntityCollection<M, AdditionalKey, UserType> & {
2
+ export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User> = Omit<EntityCollection<M, UserType>, "subcollections"> & {
3
3
  ownerId: string;
4
+ subcollections?: PersistedCollection<any, any>[];
5
+ editable?: boolean;
4
6
  };
@@ -0,0 +1,10 @@
1
+ import { ResolvedProperty } from "@firecms/core";
2
+ import { PersistedCollection } from "../types/persisted_collection";
3
+ export declare function CollectionViewHeaderAction({ propertyKey, onHover, property, fullPath, parentCollectionIds, collection }: {
4
+ property: ResolvedProperty;
5
+ propertyKey: string;
6
+ onHover: boolean;
7
+ fullPath: string;
8
+ parentCollectionIds: string[];
9
+ collection: PersistedCollection;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { CollectionActionsProps } from "@firecms/core";
2
- export declare function EditorCollectionAction({ path: fullPath, parentPathSegments, collection, tableController }: CollectionActionsProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function EditorCollectionAction({ path: fullPath, parentCollectionIds, collection, tableController }: CollectionActionsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function MissingReferenceWidget({ path: pathProp }: {
2
+ path: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function NewCollectionButton(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { PersistedCollection } from "../types/persisted_collection";
2
+ export declare function PropertyAddColumnComponent({ fullPath, parentCollectionIds, collection }: {
3
+ fullPath: string;
4
+ parentCollectionIds: string[];
5
+ collection: PersistedCollection;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function RootCollectionSuggestions(): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,10 @@
1
1
  import { EntityCollection } from "@firecms/core";
2
- export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingAliases, groups, parentCollection }: {
2
+ export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingIds, groups, parentCollection }: {
3
3
  isNewCollection: boolean;
4
4
  reservedGroups?: string[];
5
5
  existingPaths?: string[];
6
- existingAliases?: string[];
6
+ existingIds?: string[];
7
7
  groups: string[] | null;
8
8
  parentCollection?: EntityCollection;
9
+ parentCollectionIds?: string[];
9
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,13 +2,18 @@ import * as React from "react";
2
2
  import { CMSType, EntityCollection, User } from "@firecms/core";
3
3
  import { CollectionsConfigController } from "../../types/config_controller";
4
4
  import { CollectionInference } from "../../types/collection_inference";
5
+ import { PersistedCollection } from "../../types/persisted_collection";
5
6
  export interface CollectionEditorDialogProps {
6
7
  open: boolean;
7
8
  isNewCollection: boolean;
8
- group?: string;
9
+ initialValues?: {
10
+ group?: string;
11
+ path?: string;
12
+ name?: string;
13
+ };
9
14
  editedCollectionPath?: string;
10
15
  fullPath?: string;
11
- parentPathSegments?: string[];
16
+ parentCollectionIds?: string[];
12
17
  handleClose: (collection?: EntityCollection) => void;
13
18
  configController: CollectionsConfigController;
14
19
  reservedGroups?: string[];
@@ -19,15 +24,15 @@ export interface CollectionEditorDialogProps {
19
24
  }>;
20
25
  icon: React.ReactNode;
21
26
  };
22
- pathSuggestions?: (path: string) => Promise<string[]>;
27
+ pathSuggestions?: (path?: string) => Promise<string[]>;
23
28
  getUser: (uid: string) => User | null;
24
- getData?: (path: string) => Promise<object[]>;
25
- parentCollection?: EntityCollection;
29
+ getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
30
+ parentCollection?: PersistedCollection;
26
31
  }
27
32
  export declare function CollectionEditorDialog(props: CollectionEditorDialogProps): import("react/jsx-runtime").JSX.Element;
28
33
  export declare function CollectionEditorDialogInternal<M extends {
29
34
  [Key: string]: CMSType;
30
- }>({ isNewCollection, group, configController, editedCollectionPath, parentPathSegments, fullPath, collectionInference, handleClose, reservedGroups, extraView, handleCancel, setFormDirty, pathSuggestions, getUser, parentCollection, getData }: CollectionEditorDialogProps & {
35
+ }>({ isNewCollection, initialValues: initialValuesProp, configController, editedCollectionPath, parentCollectionIds, fullPath, collectionInference, handleClose, reservedGroups, extraView, handleCancel, setFormDirty, pathSuggestions, getUser, parentCollection, getData }: CollectionEditorDialogProps & {
31
36
  handleCancel: () => void;
32
37
  setFormDirty: (dirty: boolean) => void;
33
38
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { FormikErrors } from "formik";
3
- import { EntityCollection, User } from "@firecms/core";
3
+ import { EntityCollection, PropertyConfig, User } from "@firecms/core";
4
+ import { PersistedCollection } from "../../types/persisted_collection";
4
5
  type CollectionEditorFormProps = {
5
6
  showErrors: boolean;
6
7
  isNewCollection: boolean;
@@ -11,7 +12,9 @@ type CollectionEditorFormProps = {
11
12
  extraIcon: React.ReactNode;
12
13
  getUser: (uid: string) => User | null;
13
14
  getData?: () => Promise<object[]>;
14
- doCollectionInference: (collection: EntityCollection<any, string>) => Promise<EntityCollection | null> | undefined;
15
+ doCollectionInference: (collection: PersistedCollection) => Promise<Partial<EntityCollection> | null> | undefined;
16
+ propertyConfigs: Record<string, PropertyConfig>;
17
+ collectionEditable: boolean;
15
18
  };
16
- export declare function CollectionPropertiesEditorForm({ showErrors, isNewCollection, propertyErrorsRef, onPropertyError, setDirty, reservedGroups, extraIcon, getUser, getData, doCollectionInference }: CollectionEditorFormProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function CollectionPropertiesEditorForm({ showErrors, isNewCollection, propertyErrorsRef, onPropertyError, setDirty, reservedGroups, extraIcon, getUser, getData, doCollectionInference, propertyConfigs, collectionEditable }: CollectionEditorFormProps): import("react/jsx-runtime").JSX.Element;
17
20
  export {};
@@ -1,11 +1,14 @@
1
1
  import * as Yup from "yup";
2
2
  export declare const YupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
3
4
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
5
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
6
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
8
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
9
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
10
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
11
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
9
12
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
13
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
14
  }>>>;
@@ -0,0 +1,4 @@
1
+ export declare function EntityCustomViewsSelectDialog({ open, onClose }: {
2
+ open: boolean;
3
+ onClose: (selectedViewKey?: string) => void;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare function GetCodeDialog({ collection, onOpenChange, open }: {
2
+ onOpenChange: (open: boolean) => void;
3
+ collection: any;
4
+ open: any;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,24 @@
1
1
  import React from "react";
2
2
  import { FormikErrors, FormikProps } from "formik";
3
- import { EditableProperty } from "../../types/editable_properties";
4
- export type PropertyWithId = EditableProperty & {
3
+ import { Property, PropertyConfig } from "@firecms/core";
4
+ export type PropertyWithId = Property & {
5
5
  id?: string;
6
6
  };
7
7
  export type OnPropertyChangedParams = {
8
8
  id?: string;
9
- property: EditableProperty;
9
+ property: Property;
10
10
  namespace?: string;
11
11
  previousId?: string;
12
12
  };
13
13
  export type PropertyFormProps = {
14
14
  includeIdAndName?: boolean;
15
- existing: boolean;
15
+ existingProperty: boolean;
16
16
  autoUpdateId?: boolean;
17
17
  autoOpenTypeSelect: boolean;
18
18
  inArray: boolean;
19
19
  propertyKey?: string;
20
20
  propertyNamespace?: string;
21
- property?: EditableProperty;
21
+ property?: Property;
22
22
  onPropertyChanged?: (params: OnPropertyChangedParams) => void;
23
23
  onPropertyChangedImmediate?: boolean;
24
24
  onDelete?: (id?: string, namespace?: string) => void;
@@ -29,9 +29,11 @@ export type PropertyFormProps = {
29
29
  allowDataInference: boolean;
30
30
  getData?: () => Promise<object[]>;
31
31
  getHelpers?: (formikProps: FormikProps<PropertyWithId>) => void;
32
+ propertyConfigs: Record<string, PropertyConfig>;
33
+ collectionEditable: boolean;
32
34
  };
33
35
  export declare const PropertyForm: React.NamedExoticComponent<PropertyFormProps>;
34
- export declare function PropertyFormDialog({ open, onCancel, onOkClicked, onPropertyChanged, getData, ...formProps }: PropertyFormProps & {
36
+ export declare function PropertyFormDialog({ open, onCancel, onOkClicked, onPropertyChanged, getData, collectionEditable, ...formProps }: PropertyFormProps & {
35
37
  open?: boolean;
36
38
  onOkClicked?: () => void;
37
39
  onCancel?: () => void;
@@ -1,14 +1,15 @@
1
- import { EditableProperty } from "../../types/editable_properties";
1
+ import { Property, PropertyOrBuilder } from "@firecms/core";
2
2
  export declare function PropertyFieldPreview({ property, onClick, hasError, includeName, includeEditButton, selected }: {
3
- property: EditableProperty;
3
+ property: Property;
4
4
  hasError?: boolean;
5
5
  selected?: boolean;
6
6
  includeName?: boolean;
7
7
  includeEditButton?: boolean;
8
8
  onClick?: () => void;
9
9
  }): import("react/jsx-runtime").JSX.Element;
10
- export declare function PropertyBuilderPreview({ name, selected, onClick }: {
10
+ export declare function NonEditablePropertyPreview({ name, selected, onClick, property }: {
11
11
  name: string;
12
12
  selected: boolean;
13
13
  onClick?: () => void;
14
+ property?: PropertyOrBuilder;
14
15
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { PropertyConfig } from "@firecms/core";
2
+ export interface PropertySelectItemProps {
3
+ value: string;
4
+ optionDisabled: boolean;
5
+ propertyConfig: PropertyConfig;
6
+ existing: boolean;
7
+ }
8
+ export declare function PropertySelectItem({ value, optionDisabled, propertyConfig, existing }: PropertySelectItemProps): import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,26 @@
1
- import { CMSType, PropertiesOrBuilders } from "@firecms/core";
1
+ import { AdditionalFieldDelegate, CMSType, PropertiesOrBuilders, PropertyOrBuilder } from "@firecms/core";
2
2
  import { DraggableProvided } from "@hello-pangea/dnd";
3
- import { EditablePropertyOrBuilder } from "../../types/editable_properties";
4
3
  export declare function PropertyTree<M extends {
5
4
  [Key: string]: CMSType;
6
- }>({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys }: {
5
+ }>({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, additionalFields, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys, collectionEditable, }: {
7
6
  namespace?: string;
8
7
  selectedPropertyKey?: string;
9
8
  onPropertyClick?: (propertyKey: string, namespace?: string) => void;
10
9
  properties: PropertiesOrBuilders<M>;
11
10
  propertiesOrder?: string[];
11
+ additionalFields?: AdditionalFieldDelegate<M>[];
12
12
  errors: Record<string, any>;
13
13
  onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
14
14
  onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
15
15
  className?: string;
16
16
  inferredPropertyKeys?: string[];
17
+ collectionEditable: boolean;
17
18
  }): import("react/jsx-runtime").JSX.Element;
18
- export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBuilder, provided, selectedPropertyKey, errors, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys }: {
19
+ export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBuilder, additionalField, provided, selectedPropertyKey, errors, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys, collectionEditable, }: {
19
20
  propertyKey: string;
20
21
  namespace?: string;
21
- propertyOrBuilder: EditablePropertyOrBuilder;
22
+ propertyOrBuilder: PropertyOrBuilder;
23
+ additionalField?: AdditionalFieldDelegate<any>;
22
24
  selectedPropertyKey?: string;
23
25
  provided: DraggableProvided;
24
26
  errors: Record<string, any>;
@@ -26,4 +28,5 @@ export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBu
26
28
  onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
27
29
  onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
28
30
  inferredPropertyKeys?: string[];
31
+ collectionEditable: boolean;
29
32
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,11 +2,11 @@ import { EntityCollection, User } from "@firecms/core";
2
2
  import { CollectionsConfigController } from "../../types/config_controller";
3
3
  import { PersistedCollection } from "../../types/persisted_collection";
4
4
  import { CollectionInference } from "../../types/collection_inference";
5
- export declare function SubcollectionsEditTab({ collection, parentCollection, configController, collectionInference, getUser, parentPathSegments }: {
5
+ export declare function SubcollectionsEditTab({ collection, parentCollection, configController, collectionInference, getUser, parentCollectionIds }: {
6
6
  collection: PersistedCollection;
7
7
  parentCollection?: EntityCollection;
8
8
  configController: CollectionsConfigController;
9
9
  collectionInference?: CollectionInference;
10
10
  getUser: (uid: string) => User | null;
11
- parentPathSegments?: string[];
11
+ parentCollectionIds?: string[];
12
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ImportConfig } from "@firecms/data_import";
1
+ import { ImportConfig } from "@firecms/data_import_export";
2
2
  import { Properties } from "@firecms/core";
3
3
  export declare function CollectionEditorImportDataPreview({ importConfig, properties, propertiesOrder }: {
4
4
  importConfig: ImportConfig;
@@ -0,0 +1,7 @@
1
+ import { ImportConfig } from "@firecms/data_import_export";
2
+ import { PropertyConfig } from "@firecms/core";
3
+ export declare function CollectionEditorImportMapping({ importConfig, propertyConfigs, collectionEditable }: {
4
+ importConfig: ImportConfig;
5
+ propertyConfigs: Record<string, PropertyConfig>;
6
+ collectionEditable: boolean;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Properties } from "@firecms/core";
2
- import { ImportConfig } from "@firecms/data_import";
2
+ import { ImportConfig } from "@firecms/data_import_export";
3
3
  export declare function cleanPropertiesFromImport(properties: Properties, parentSlug?: string): {
4
4
  headersMapping: ImportConfig["headersMapping"];
5
5
  properties: Properties;
@@ -1,5 +1,8 @@
1
- export declare function BlockPropertyField({ disabled, getData, allowDataInference }: {
1
+ import { PropertyConfig } from "@firecms/core";
2
+ export declare function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
2
3
  disabled: boolean;
3
4
  getData?: () => Promise<object[]>;
4
5
  allowDataInference: boolean;
6
+ propertyConfigs: Record<string, PropertyConfig>;
7
+ collectionEditable: boolean;
5
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,7 @@ type CommonPropertyFieldsProps = {
5
5
  existingPropertyKeys?: string[];
6
6
  disabled: boolean;
7
7
  isNewProperty: boolean;
8
+ autoUpdateId: boolean;
8
9
  };
9
10
  export declare const CommonPropertyFields: React.ForwardRefExoticComponent<CommonPropertyFieldsProps & React.RefAttributes<HTMLDivElement>>;
10
11
  export {};
@@ -1,5 +1,8 @@
1
- export declare function MapPropertyField({ disabled, getData, allowDataInference }: {
1
+ import { PropertyConfig } from "@firecms/core";
2
+ export declare function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
2
3
  disabled: boolean;
3
4
  getData?: () => Promise<object[]>;
4
5
  allowDataInference: boolean;
6
+ propertyConfigs: Record<string, PropertyConfig>;
7
+ collectionEditable: boolean;
5
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,10 @@
1
- export declare function RepeatPropertyField({ showErrors, existing, disabled, getData, allowDataInference }: {
1
+ import { PropertyConfig } from "@firecms/core";
2
+ export declare function RepeatPropertyField({ showErrors, existing, disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
2
3
  showErrors: boolean;
3
4
  existing: boolean;
4
5
  disabled: boolean;
5
6
  getData?: () => Promise<object[]>;
6
7
  allowDataInference: boolean;
8
+ propertyConfigs: Record<string, PropertyConfig>;
9
+ collectionEditable: boolean;
7
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  export declare function StringPropertyField({ widgetId, disabled, showErrors }: {
2
- widgetId: "text_field" | "multiline" | "markdown" | "url" | "email";
2
+ widgetId: "text_field" | "multiline" | "markdown" | "email";
3
3
  disabled: boolean;
4
4
  showErrors: boolean;
5
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function UrlPropertyField({ disabled, showErrors }: {
2
+ disabled: boolean;
3
+ showErrors: boolean;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export declare const blogCollectionTemplate: EntityCollection;
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export declare const pagesCollectionTemplate: EntityCollection;
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export declare const productsCollectionTemplate: EntityCollection;
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export declare const usersCollectionTemplate: EntityCollection;
@@ -0,0 +1 @@
1
+ export declare function camelCase(str: string): string;
@@ -0,0 +1,3 @@
1
+ import { FieldConfigId, PropertyConfig } from "@firecms/core";
2
+ export declare const supportedFieldsIds: FieldConfigId[];
3
+ export declare const supportedFields: Record<string, PropertyConfig>;
@@ -0,0 +1,2 @@
1
+ import { Property, PropertyConfig } from "@firecms/core";
2
+ export declare function updatePropertyFromWidget(propertyData: any, selectedWidgetId: string | undefined, propertyConfigs: Record<string, PropertyConfig>): Property;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { FireCMSPlugin, User } from "@firecms/core";
2
+ import { EntityCollection, FireCMSPlugin, ModifyCollectionProps, User } from "@firecms/core";
3
3
  import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
4
4
  import { PersistedCollection } from "./types/persisted_collection";
5
5
  import { CollectionInference } from "./types/collection_inference";
@@ -9,6 +9,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
9
9
  * Firebase app where the configuration is saved.
10
10
  */
11
11
  collectionConfigController: CollectionsConfigController;
12
+ modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | void;
12
13
  /**
13
14
  * Define what actions can be performed on the configuration.
14
15
  */
@@ -27,8 +28,9 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
27
28
  };
28
29
  pathSuggestions?: (path: string) => Promise<string[]>;
29
30
  collectionInference?: CollectionInference;
30
- getData?: (path: string) => Promise<object[]>;
31
+ getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
31
32
  getUser: (uid: string) => UserType | null;
33
+ onAnalyticsEvent?: (event: string, params?: object) => void;
32
34
  }
33
35
  /**
34
36
  * Use this hook to initialise the Collection Editor plugin.
@@ -41,4 +43,4 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
41
43
  * @param getUser
42
44
  * @param collectionInference
43
45
  */
44
- export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, configPermissions, reservedGroups, extraView, pathSuggestions, getUser, collectionInference, getData }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin;
46
+ export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, modifyCollection, configPermissions, reservedGroups, extraView, pathSuggestions, getUser, collectionInference, getData, onAnalyticsEvent }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection>;
@@ -1,4 +1,3 @@
1
- import { Properties, PropertyOrBuilder } from "@firecms/core";
2
- import { EditablePropertiesOrBuilders, EditablePropertyOrBuilder } from "../types/editable_properties";
3
- export declare function editableProperty(property: EditablePropertyOrBuilder | PropertyOrBuilder): boolean;
4
- export declare function removeNonEditableProperties(properties: EditablePropertiesOrBuilders<any>): Properties;
1
+ import { Properties, PropertiesOrBuilders, PropertyOrBuilder } from "@firecms/core";
2
+ export declare function editableProperty(property: PropertyOrBuilder | PropertyOrBuilder): boolean;
3
+ export declare function removeNonEditableProperties(properties: PropertiesOrBuilders<any>): Properties;
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
- "version": "3.0.0-alpha.9",
3
+ "type": "module",
4
+ "version": "3.0.0-beta.2-pre.1",
4
5
  "main": "./dist/index.umd.js",
5
6
  "module": "./dist/index.es.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "source": "src/index.ts",
8
9
  "dependencies": {
9
- "flexsearch": "^0.7.31"
10
+ "@firecms/data_import_export": "^3.0.0-beta.2-pre.1",
11
+ "@firecms/schema_inference": "^3.0.0-beta.2-pre.1",
12
+ "@firecms/ui": "^3.0.0-beta.2-pre.1",
13
+ "json5": "^2.2.3",
14
+ "prism-react-renderer": "^2.3.1"
10
15
  },
11
16
  "peerDependencies": {
12
- "@firecms/data_import": "^3.0.0-alpha.9",
13
- "@firecms/schema_inference": "^3.0.0-alpha.9",
14
17
  "react": "^18.2.0",
15
18
  "react-dom": "^18.2.0",
16
19
  "react-router": "^6.12.0",
@@ -19,7 +22,8 @@
19
22
  "scripts": {
20
23
  "dev": "vite",
21
24
  "test": "jest",
22
- "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json"
25
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
26
+ "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
23
27
  },
24
28
  "eslintConfig": {
25
29
  "extends": [
@@ -41,33 +45,32 @@
41
45
  },
42
46
  "devDependencies": {
43
47
  "@jest/globals": "^29.7.0",
44
- "@types/react": "^18.2.33",
45
- "@types/react-dom": "^18.2.14",
48
+ "@types/react": "^18.2.54",
49
+ "@types/react-dom": "^18.2.18",
46
50
  "@typescript-eslint/eslint-plugin": "^5.62.0",
47
51
  "@typescript-eslint/parser": "^5.62.0",
48
- "@vitejs/plugin-react": "^4.1.0",
49
- "eslint": "^8.52.0",
52
+ "@vitejs/plugin-react": "^4.2.1",
53
+ "eslint": "^8.56.0",
50
54
  "eslint-config-standard": "^17.1.0",
51
- "eslint-plugin-import": "^2.29.0",
55
+ "eslint-plugin-import": "^2.29.1",
52
56
  "eslint-plugin-n": "^15.7.0",
53
57
  "eslint-plugin-promise": "^6.1.1",
54
58
  "eslint-plugin-react": "^7.33.2",
55
59
  "eslint-plugin-react-hooks": "^4.6.0",
56
60
  "jest": "^29.7.0",
57
- "react": "^18.2.0",
58
- "react-dom": "^18.2.0",
59
- "react-router": "^6.17.0",
60
- "react-router-dom": "^6.17.0",
61
- "ts-jest": "^29.1.1",
62
- "typescript": "^5.2.2",
63
- "vite": "^4.5.0",
61
+ "react-router": "^6.22.0",
62
+ "react-router-dom": "^6.22.0",
63
+ "ts-jest": "^29.1.2",
64
+ "typescript": "^5.3.3",
65
+ "vite": "^4.5.2",
64
66
  "vite-plugin-fonts": "^0.7.0"
65
67
  },
66
68
  "files": [
67
- "dist"
69
+ "dist",
70
+ "src"
68
71
  ],
69
72
  "publishConfig": {
70
73
  "access": "public"
71
74
  },
72
- "gitHead": "85611c918afa8321f1710b05ddc15f7a5354d077"
75
+ "gitHead": "84f61eb3868f008f9c7c892881f12f0e79b566a0"
73
76
  }