@firecms/collection_editor 3.0.0-alpha.10
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/ConfigControllerProvider.d.ts +36 -0
- package/dist/components/EditorCollectionAction.d.ts +2 -0
- package/dist/components/HomePageEditorCollectionAction.d.ts +2 -0
- package/dist/components/NewCollectionCard.d.ts +2 -0
- package/dist/components/collection_editor/CollectionDetailsForm.d.ts +9 -0
- package/dist/components/collection_editor/CollectionEditorDialog.d.ts +33 -0
- package/dist/components/collection_editor/CollectionEditorWelcomeView.d.ts +15 -0
- package/dist/components/collection_editor/CollectionPropertiesEditorForm.d.ts +17 -0
- package/dist/components/collection_editor/CollectionYupValidation.d.ts +11 -0
- package/dist/components/collection_editor/EnumForm.d.ts +13 -0
- package/dist/components/collection_editor/PropertyEditView.d.ts +38 -0
- package/dist/components/collection_editor/PropertyFieldPreview.d.ts +14 -0
- package/dist/components/collection_editor/PropertySelectItem.d.ts +8 -0
- package/dist/components/collection_editor/PropertyTree.d.ts +29 -0
- package/dist/components/collection_editor/SelectIcons.d.ts +6 -0
- package/dist/components/collection_editor/SubcollectionsEditTab.d.ts +12 -0
- package/dist/components/collection_editor/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/collection_editor/import/CollectionEditorImportDataPreview.d.ts +7 -0
- package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +4 -0
- package/dist/components/collection_editor/import/clean_import_data.d.ts +7 -0
- package/dist/components/collection_editor/properties/BlockPropertyField.d.ts +5 -0
- package/dist/components/collection_editor/properties/BooleanPropertyField.d.ts +3 -0
- package/dist/components/collection_editor/properties/CommonPropertyFields.d.ts +10 -0
- package/dist/components/collection_editor/properties/DateTimePropertyField.d.ts +3 -0
- package/dist/components/collection_editor/properties/EnumPropertyField.d.ts +8 -0
- package/dist/components/collection_editor/properties/FieldHelperView.d.ts +4 -0
- package/dist/components/collection_editor/properties/KeyValuePropertyField.d.ts +3 -0
- package/dist/components/collection_editor/properties/MapPropertyField.d.ts +5 -0
- package/dist/components/collection_editor/properties/NumberPropertyField.d.ts +3 -0
- package/dist/components/collection_editor/properties/ReferencePropertyField.d.ts +13 -0
- package/dist/components/collection_editor/properties/RepeatPropertyField.d.ts +7 -0
- package/dist/components/collection_editor/properties/StoragePropertyField.d.ts +5 -0
- package/dist/components/collection_editor/properties/StringPropertyField.d.ts +5 -0
- package/dist/components/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +3 -0
- package/dist/components/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +5 -0
- package/dist/components/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +4 -0
- package/dist/components/collection_editor/properties/validation/NumberPropertyValidation.d.ts +3 -0
- package/dist/components/collection_editor/properties/validation/StringPropertyValidation.d.ts +11 -0
- package/dist/components/collection_editor/properties/validation/ValidationPanel.d.ts +2 -0
- package/dist/components/collection_editor/templates/blog_template.d.ts +10 -0
- package/dist/components/collection_editor/templates/products_template.d.ts +12 -0
- package/dist/components/collection_editor/templates/users_template.d.ts +7 -0
- package/dist/components/collection_editor/util.d.ts +4 -0
- package/dist/components/collection_editor/utils/supported_fields.d.ts +3 -0
- package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +3 -0
- package/dist/components/collection_editor/utils/useTraceUpdate.d.ts +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.es.js +6211 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/collection_editor_controller.d.ts +20 -0
- package/dist/types/collection_inference.d.ts +2 -0
- package/dist/types/config_controller.d.ts +24 -0
- package/dist/types/config_permissions.d.ts +19 -0
- package/dist/types/editable_properties.d.ts +10 -0
- package/dist/types/persisted_collection.d.ts +4 -0
- package/dist/useCollectionEditorController.d.ts +6 -0
- package/dist/useCollectionEditorPlugin.d.ts +44 -0
- package/dist/useCollectionsConfigController.d.ts +6 -0
- package/dist/utils/arrays.d.ts +1 -0
- package/dist/utils/entities.d.ts +4 -0
- package/dist/utils/icons.d.ts +2 -0
- package/dist/utils/synonyms.d.ts +1951 -0
- package/package.json +73 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CollectionEditorPermissionsBuilder } from "./config_permissions";
|
|
2
|
+
import { EntityCollection } 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
|
+
group?: string;
|
|
16
|
+
parentPathSegments: string[];
|
|
17
|
+
parentCollection?: EntityCollection<any, any, any>;
|
|
18
|
+
}) => void;
|
|
19
|
+
configPermissions: CollectionEditorPermissionsBuilder;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CMSType, EntityCollection } 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
|
+
deleteCollection: (props: DeleteCollectionParams) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type SaveCollectionParams<M extends Record<string, any>> = {
|
|
16
|
+
path: string;
|
|
17
|
+
collectionData: EntityCollection<M>;
|
|
18
|
+
previousPath?: string;
|
|
19
|
+
parentPathSegments?: string[];
|
|
20
|
+
};
|
|
21
|
+
export type DeleteCollectionParams = {
|
|
22
|
+
path: string;
|
|
23
|
+
parentPathSegments?: string[];
|
|
24
|
+
};
|
|
@@ -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,10 @@
|
|
|
1
|
+
import { CMSType, Property, PropertyBuilderProps, ResolvedProperty } from "@firecms/core";
|
|
2
|
+
export type EditablePropertyOrBuilder = EditableProperty | EditablePropertyBuilder;
|
|
3
|
+
export type EditableProperty = Property & {
|
|
4
|
+
editable: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type EditablePropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, path, entityId }: PropertyBuilderProps<M>) => EditableProperty | null;
|
|
7
|
+
export type EditablePropertiesOrBuilders<M extends Record<string, any> = Record<string, any>> = {
|
|
8
|
+
[k in keyof M]: EditablePropertyOrBuilder;
|
|
9
|
+
};
|
|
10
|
+
export declare function isEditablePropertyBuilder<T extends CMSType, M extends Record<string, any>>(propertyOrBuilder?: EditablePropertyOrBuilder | ResolvedProperty<T>): propertyOrBuilder is EditablePropertyBuilder;
|
|
@@ -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,4 @@
|
|
|
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;
|