@firecms/collection_editor 3.0.0-alpha.21 → 3.0.0-alpha.25

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 (92) hide show
  1. package/dist/ConfigControllerProvider.d.ts +36 -0
  2. package/dist/components/CollectionViewHeaderAction.d.ts +8 -0
  3. package/dist/components/EditorCollectionAction.d.ts +2 -0
  4. package/dist/components/HomePageEditorCollectionAction.d.ts +2 -0
  5. package/dist/components/MissingReferenceWidget.d.ts +3 -0
  6. package/dist/components/NewCollectionCard.d.ts +2 -0
  7. package/dist/components/PropertyAddColumnComponent.d.ts +6 -0
  8. package/dist/components/RootCollectionSuggestions.d.ts +1 -0
  9. package/dist/components/collection_editor/CollectionDetailsForm.d.ts +9 -0
  10. package/dist/components/collection_editor/CollectionEditorDialog.d.ts +37 -0
  11. package/dist/components/collection_editor/CollectionEditorWelcomeView.d.ts +15 -0
  12. package/dist/components/collection_editor/CollectionPropertiesEditorForm.d.ts +19 -0
  13. package/dist/components/collection_editor/CollectionYupValidation.d.ts +11 -0
  14. package/dist/components/collection_editor/EntityCustomViewsSelectDialog.d.ts +4 -0
  15. package/dist/components/collection_editor/EnumForm.d.ts +13 -0
  16. package/dist/components/collection_editor/PropertyEditView.d.ts +39 -0
  17. package/dist/components/collection_editor/PropertyFieldPreview.d.ts +15 -0
  18. package/dist/components/collection_editor/PropertySelectItem.d.ts +8 -0
  19. package/dist/components/collection_editor/PropertyTree.d.ts +30 -0
  20. package/dist/components/collection_editor/SelectIcons.d.ts +6 -0
  21. package/dist/components/collection_editor/SubcollectionsEditTab.d.ts +12 -0
  22. package/dist/components/collection_editor/UnsavedChangesDialog.d.ts +9 -0
  23. package/dist/components/collection_editor/import/CollectionEditorImportDataPreview.d.ts +7 -0
  24. package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +6 -0
  25. package/dist/components/collection_editor/import/clean_import_data.d.ts +7 -0
  26. package/dist/components/collection_editor/properties/BlockPropertyField.d.ts +7 -0
  27. package/dist/components/collection_editor/properties/BooleanPropertyField.d.ts +3 -0
  28. package/dist/components/collection_editor/properties/CommonPropertyFields.d.ts +10 -0
  29. package/dist/components/collection_editor/properties/DateTimePropertyField.d.ts +3 -0
  30. package/dist/components/collection_editor/properties/EnumPropertyField.d.ts +8 -0
  31. package/dist/components/collection_editor/properties/FieldHelperView.d.ts +4 -0
  32. package/dist/components/collection_editor/properties/KeyValuePropertyField.d.ts +3 -0
  33. package/dist/components/collection_editor/properties/MapPropertyField.d.ts +7 -0
  34. package/dist/components/collection_editor/properties/NumberPropertyField.d.ts +3 -0
  35. package/dist/components/collection_editor/properties/ReferencePropertyField.d.ts +13 -0
  36. package/dist/components/collection_editor/properties/RepeatPropertyField.d.ts +9 -0
  37. package/dist/components/collection_editor/properties/StoragePropertyField.d.ts +5 -0
  38. package/dist/components/collection_editor/properties/StringPropertyField.d.ts +5 -0
  39. package/dist/components/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +3 -0
  40. package/dist/components/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +5 -0
  41. package/dist/components/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +4 -0
  42. package/dist/components/collection_editor/properties/validation/NumberPropertyValidation.d.ts +3 -0
  43. package/dist/components/collection_editor/properties/validation/StringPropertyValidation.d.ts +11 -0
  44. package/dist/components/collection_editor/properties/validation/ValidationPanel.d.ts +2 -0
  45. package/dist/components/collection_editor/templates/blog_template.d.ts +10 -0
  46. package/dist/components/collection_editor/templates/products_template.d.ts +12 -0
  47. package/dist/components/collection_editor/templates/users_template.d.ts +7 -0
  48. package/dist/components/collection_editor/util.d.ts +4 -0
  49. package/dist/components/collection_editor/utils/supported_fields.d.ts +3 -0
  50. package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +2 -0
  51. package/dist/components/collection_editor/utils/useTraceUpdate.d.ts +1 -0
  52. package/dist/index.d.ts +11 -0
  53. package/dist/index.es.js +6754 -0
  54. package/dist/index.es.js.map +1 -0
  55. package/dist/index.umd.js +2 -0
  56. package/dist/index.umd.js.map +1 -0
  57. package/dist/types/collection_editor_controller.d.ts +33 -0
  58. package/dist/types/collection_inference.d.ts +2 -0
  59. package/dist/types/config_controller.d.ts +33 -0
  60. package/dist/types/config_permissions.d.ts +19 -0
  61. package/dist/types/persisted_collection.d.ts +6 -0
  62. package/dist/useCollectionEditorController.d.ts +6 -0
  63. package/dist/useCollectionEditorPlugin.d.ts +44 -0
  64. package/dist/useCollectionsConfigController.d.ts +6 -0
  65. package/dist/utils/arrays.d.ts +1 -0
  66. package/dist/utils/entities.d.ts +3 -0
  67. package/dist/utils/icons.d.ts +1 -0
  68. package/dist/utils/join_collections.d.ts +13 -0
  69. package/dist/utils/synonyms.d.ts +1951 -0
  70. package/package.json +6 -5
  71. package/src/ConfigControllerProvider.tsx +131 -8
  72. package/src/components/CollectionViewHeaderAction.tsx +38 -0
  73. package/src/components/MissingReferenceWidget.tsx +2 -1
  74. package/src/components/NewCollectionCard.tsx +2 -1
  75. package/src/components/PropertyAddColumnComponent.tsx +39 -0
  76. package/src/components/RootCollectionSuggestions.tsx +2 -1
  77. package/src/components/collection_editor/CollectionDetailsForm.tsx +1 -0
  78. package/src/components/collection_editor/CollectionEditorDialog.tsx +1 -1
  79. package/src/components/collection_editor/CollectionPropertiesEditorForm.tsx +3 -3
  80. package/src/components/collection_editor/PropertyEditView.tsx +112 -97
  81. package/src/components/collection_editor/SubcollectionsEditTab.tsx +14 -3
  82. package/src/components/collection_editor/import/CollectionEditorImportMapping.tsx +1 -1
  83. package/src/components/collection_editor/properties/BlockPropertyField.tsx +1 -1
  84. package/src/components/collection_editor/properties/CommonPropertyFields.tsx +0 -1
  85. package/src/components/collection_editor/properties/MapPropertyField.tsx +1 -1
  86. package/src/components/collection_editor/properties/RepeatPropertyField.tsx +1 -1
  87. package/src/index.ts +1 -0
  88. package/src/types/collection_editor_controller.tsx +11 -2
  89. package/src/types/config_controller.tsx +13 -2
  90. package/src/types/persisted_collection.ts +2 -1
  91. package/src/useCollectionEditorPlugin.tsx +22 -2
  92. package/src/utils/join_collections.ts +11 -48
@@ -0,0 +1,33 @@
1
+ import { CollectionEditorPermissionsBuilder } from "./config_permissions";
2
+ import { EntityCollection, Property } from "@firecms/core";
3
+ /**
4
+ * Controller to open the collection editor dialog.
5
+ * @category Hooks and utilities
6
+ */
7
+ export interface CollectionEditorController {
8
+ editCollection: (props: {
9
+ path?: string;
10
+ fullPath?: string;
11
+ parentPathSegments: string[];
12
+ parentCollection?: EntityCollection<any, any, any>;
13
+ }) => void;
14
+ createCollection: (props: {
15
+ initialValues?: {
16
+ group?: string;
17
+ path?: string;
18
+ name?: string;
19
+ };
20
+ parentPathSegments: string[];
21
+ parentCollection?: EntityCollection<any, any, any>;
22
+ redirect: boolean;
23
+ }) => void;
24
+ editProperty: (props: {
25
+ propertyKey?: string;
26
+ property?: Property;
27
+ currentPropertiesOrder?: string[];
28
+ editedCollectionPath: string;
29
+ parentPathSegments: string[];
30
+ }) => void;
31
+ configPermissions: CollectionEditorPermissionsBuilder;
32
+ rootPathSuggestions?: string[];
33
+ }
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentPathSegments: string[]) => Promise<EntityCollection | null>;
@@ -0,0 +1,33 @@
1
+ import { CMSType, Property } from "@firecms/core";
2
+ import { PersistedCollection } from "./persisted_collection";
3
+ /**
4
+ * Use this controller to access the configuration that is stored externally,
5
+ * and not defined in code.
6
+ */
7
+ export interface CollectionsConfigController {
8
+ loading: boolean;
9
+ collections?: PersistedCollection[];
10
+ saveCollection: <M extends {
11
+ [Key: string]: CMSType;
12
+ }>(params: SaveCollectionParams<M>) => Promise<void>;
13
+ saveProperty: (params: SavePropertyParams) => Promise<void>;
14
+ deleteCollection: (props: DeleteCollectionParams) => Promise<void>;
15
+ }
16
+ export type SaveCollectionParams<M extends Record<string, any>> = {
17
+ path: string;
18
+ collectionData: PersistedCollection<M>;
19
+ previousPath?: string;
20
+ parentPathSegments?: string[];
21
+ };
22
+ export type SavePropertyParams = {
23
+ path: string;
24
+ propertyKey: string;
25
+ namespace?: string;
26
+ newPropertiesOrder?: string[];
27
+ property: Property;
28
+ parentPathSegments?: string[];
29
+ };
30
+ export type DeleteCollectionParams = {
31
+ path: string;
32
+ parentPathSegments?: string[];
33
+ };
@@ -0,0 +1,19 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export type CollectionEditorPermissionsBuilder<UserType = any, EC extends EntityCollection = EntityCollection> = (params: {
3
+ user: UserType | null;
4
+ collection?: EC;
5
+ }) => CollectionEditorPermissions;
6
+ export type CollectionEditorPermissions = {
7
+ /**
8
+ * Is the user allowed to create new collections.
9
+ */
10
+ createCollections: boolean;
11
+ /**
12
+ * Is the user allowed to modify this collection
13
+ */
14
+ editCollections: boolean;
15
+ /**
16
+ * Is the user allowed to delete this collection
17
+ */
18
+ deleteCollections: boolean;
19
+ };
@@ -0,0 +1,6 @@
1
+ import { EntityCollection, Properties, User } from "@firecms/core";
2
+ export type PersistedCollection<M extends Record<string, any> = any, AdditionalKey extends string = string, UserType extends User = User> = Omit<EntityCollection<M, AdditionalKey, UserType>, "properties" | "subcollections"> & {
3
+ properties: Properties<M>;
4
+ ownerId: string;
5
+ subcollections?: PersistedCollection<any, any>[];
6
+ };
@@ -0,0 +1,6 @@
1
+ import { CollectionEditorController } from "./types/collection_editor_controller";
2
+ /**
3
+ * Hook to access the collection editor controller.
4
+ * The methods in this controller can be used to open the collection editor dialog.
5
+ */
6
+ export declare const useCollectionEditorController: () => CollectionEditorController;
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+ import { FireCMSPlugin, User } from "@firecms/core";
3
+ import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
4
+ import { PersistedCollection } from "./types/persisted_collection";
5
+ import { CollectionInference } from "./types/collection_inference";
6
+ import { CollectionsConfigController } from "./types/config_controller";
7
+ export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, UserType extends User = User> {
8
+ /**
9
+ * Firebase app where the configuration is saved.
10
+ */
11
+ collectionConfigController: CollectionsConfigController;
12
+ /**
13
+ * Define what actions can be performed on the configuration.
14
+ */
15
+ configPermissions?: CollectionEditorPermissionsBuilder<UserType, EC>;
16
+ /**
17
+ * The words you define here will not be allowed to be used as group
18
+ * names when creating collections.
19
+ * e.g. ["admin"]
20
+ */
21
+ reservedGroups: string[];
22
+ extraView?: {
23
+ View: React.ComponentType<{
24
+ path: string;
25
+ }>;
26
+ icon: React.ReactNode;
27
+ };
28
+ pathSuggestions?: (path: string) => Promise<string[]>;
29
+ collectionInference?: CollectionInference;
30
+ getData?: (path: string) => Promise<object[]>;
31
+ getUser: (uid: string) => UserType | null;
32
+ }
33
+ /**
34
+ * Use this hook to initialise the Collection Editor plugin.
35
+ * This is likely the only hook you will need to use.
36
+ * @param firebaseApp Firebase app where your project data lives.
37
+ * @param configPermissions
38
+ * @param reservedGroups
39
+ * @param extraView
40
+ * @param pathSuggestions
41
+ * @param getUser
42
+ * @param collectionInference
43
+ */
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;
@@ -0,0 +1,6 @@
1
+ import { CollectionsConfigController } from "./types/config_controller";
2
+ /**
3
+ * Use this hook to access the configuration controller.
4
+ * You can use it to get the list of collections, and to save/delete collections.
5
+ */
6
+ export declare const useCollectionsConfigController: () => CollectionsConfigController;
@@ -0,0 +1 @@
1
+ export declare function toArray<T>(input?: T | T[]): T[];
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1 @@
1
+ export declare const iconsSearch: any;
@@ -0,0 +1,13 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ /**
3
+ *
4
+ * @param storedCollections
5
+ * @param codedCollections
6
+ */
7
+ export declare function joinCollectionLists(storedCollections: EntityCollection[], codedCollections: EntityCollection[] | undefined): EntityCollection[];
8
+ /**
9
+ *
10
+ * @param target
11
+ * @param source
12
+ */
13
+ export declare function mergeCollection(target: EntityCollection, source: EntityCollection): EntityCollection;