@firecms/core 3.0.0-alpha.28 → 3.0.0-alpha.29

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 (57) hide show
  1. package/dist/core/FireCMS.d.ts +2 -2
  2. package/dist/core/builders.d.ts +2 -2
  3. package/dist/core/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -2
  4. package/dist/core/components/EntityCollectionTable/internal/EntityCollectionRowActions.d.ts +15 -11
  5. package/dist/core/components/EntityCollectionTable/internal/default_entity_actions.d.ts +5 -0
  6. package/dist/core/components/EntityCollectionTable/types.d.ts +1 -37
  7. package/dist/core/components/VirtualTable/VirtualTableProps.d.ts +1 -1
  8. package/dist/core/contexts/DialogsProvider.d.ts +4 -0
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/internal/useBuildNavigationContext.d.ts +3 -3
  11. package/dist/core/util/resolutions.d.ts +1 -1
  12. package/dist/hooks/useDialogsController.d.ts +11 -0
  13. package/dist/index.es.js +8400 -8230
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/index.umd.js +67 -67
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/styles.d.ts +1 -1
  18. package/dist/types/collections.d.ts +36 -13
  19. package/dist/types/dialogs_controller.d.ts +30 -0
  20. package/dist/types/entity_actions.d.ts +33 -0
  21. package/dist/types/firecms.d.ts +5 -5
  22. package/dist/types/firecms_context.d.ts +7 -0
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/navigation.d.ts +3 -3
  25. package/dist/types/plugins.d.ts +11 -10
  26. package/package.json +3 -3
  27. package/src/components/Sheet.tsx +1 -0
  28. package/src/core/FireCMS.tsx +9 -6
  29. package/src/core/builders.ts +6 -6
  30. package/src/core/components/ArrayContainer.tsx +1 -1
  31. package/src/core/components/EntityCollectionTable/EntityCollectionTable.tsx +16 -9
  32. package/src/core/components/EntityCollectionTable/EntityCollectionTableProps.tsx +5 -2
  33. package/src/core/components/EntityCollectionTable/internal/EntityCollectionRowActions.tsx +96 -79
  34. package/src/core/components/EntityCollectionTable/internal/default_entity_actions.tsx +107 -0
  35. package/src/core/components/EntityCollectionTable/types.tsx +1 -56
  36. package/src/core/components/EntityCollectionView/EntityCollectionView.tsx +66 -42
  37. package/src/core/components/ReferenceSelectionInner.tsx +2 -2
  38. package/src/core/components/VirtualTable/VirtualTable.tsx +4 -6
  39. package/src/core/components/VirtualTable/VirtualTableProps.tsx +1 -1
  40. package/src/core/contexts/DialogsProvider.tsx +50 -0
  41. package/src/core/index.tsx +1 -1
  42. package/src/core/internal/useBuildNavigationContext.tsx +13 -13
  43. package/src/core/internal/useBuildSideEntityController.tsx +9 -1
  44. package/src/form/EntityForm.tsx +63 -6
  45. package/src/hooks/useDialogsController.tsx +14 -0
  46. package/src/hooks/useFireCMSContext.tsx +5 -11
  47. package/src/styles.ts +1 -1
  48. package/src/types/collections.ts +36 -17
  49. package/src/types/dialogs_controller.tsx +31 -0
  50. package/src/types/entity_actions.tsx +36 -0
  51. package/src/types/firecms.tsx +5 -5
  52. package/src/types/firecms_context.tsx +8 -0
  53. package/src/types/index.ts +1 -0
  54. package/src/types/navigation.ts +3 -3
  55. package/src/types/plugins.tsx +11 -10
  56. /package/dist/core/contexts/{SnackbarContext.d.ts → SnackbarProvider.d.ts} +0 -0
  57. /package/src/core/contexts/{SnackbarContext.tsx → SnackbarProvider.tsx} +0 -0
@@ -1,4 +1,4 @@
1
- import { FireCMSProps, User } from "../types";
1
+ import { EntityCollection, FireCMSProps, User } from "../types";
2
2
  /**
3
3
  * If you are using independent components of the CMS
4
4
  * you need to wrap them with this main component, so the internal hooks work.
@@ -12,4 +12,4 @@ import { FireCMSProps, User } from "../types";
12
12
  * @constructor
13
13
  * @category Core
14
14
  */
15
- export declare function FireCMS<UserType extends User>(props: FireCMSProps<UserType>): import("react/jsx-runtime").JSX.Element;
15
+ export declare function FireCMS<UserType extends User, EC extends EntityCollection>(props: FireCMSProps<UserType, EC>): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { AdditionalFieldDelegate, ArrayProperty, BooleanProperty, CMSType, DateP
5
5
  * @param collection
6
6
  * @category Builder
7
7
  */
8
- export declare function buildCollection<M extends Record<string, any> = any, AdditionalKey extends string = string, UserType extends User = User>(collection: EntityCollection<M, AdditionalKey, UserType>): EntityCollection<M, AdditionalKey, UserType>;
8
+ export declare function buildCollection<M extends Record<string, any> = any, UserType extends User = User>(collection: EntityCollection<M, UserType>): EntityCollection<M, UserType>;
9
9
  /**
10
10
  * Identity function we use to defeat the type system of Typescript and preserve
11
11
  * the property keys.
@@ -54,7 +54,7 @@ export declare function buildEntityCallbacks<M extends Record<string, any> = any
54
54
  * @param additionalFieldDelegate
55
55
  * @category Builder
56
56
  */
57
- export declare function buildAdditionalFieldDelegate<M extends Record<string, any>, AdditionalKey extends string = string, UserType extends User = User>(additionalFieldDelegate: AdditionalFieldDelegate<M, AdditionalKey, UserType>): AdditionalFieldDelegate<M, AdditionalKey, UserType>;
57
+ export declare function buildAdditionalFieldDelegate<M extends Record<string, any>, UserType extends User = User>(additionalFieldDelegate: AdditionalFieldDelegate<M, UserType>): AdditionalFieldDelegate<M, UserType>;
58
58
  /**
59
59
  * Identity function we use to defeat the type system of Typescript and build
60
60
  * additional field delegates views with all its properties
@@ -11,7 +11,7 @@ export type OnColumnResizeParams = {
11
11
  /**
12
12
  * @category Collection components
13
13
  */
14
- export type EntityCollectionTableProps<M extends Record<string, any>, AdditionalKey extends string = string, UserType extends User = User> = {
14
+ export type EntityCollectionTableProps<M extends Record<string, any>, UserType extends User = User> = {
15
15
  /**
16
16
  * Display these entities as selected
17
17
  */
@@ -76,7 +76,7 @@ export type EntityCollectionTableProps<M extends Record<string, any>, Additional
76
76
  forceFilter?: FilterValues<Extract<keyof M, string>>;
77
77
  textSearchEnabled?: boolean;
78
78
  inlineEditing?: boolean | ((entity: Entity<M>) => boolean);
79
- additionalFields?: AdditionalFieldDelegate<M, AdditionalKey, UserType>[];
79
+ additionalFields?: AdditionalFieldDelegate<M, UserType>[];
80
80
  defaultSize?: CollectionSize;
81
81
  properties: ResolvedProperties<M>;
82
82
  getPropertyFor?: (props: GetPropertyForProps<M>) => ResolvedProperties<M>[string];
@@ -90,6 +90,8 @@ export type EntityCollectionTableProps<M extends Record<string, any>, Additional
90
90
  }) => React.ReactNode;
91
91
  AddColumnComponent?: React.ComponentType;
92
92
  additionalIDHeaderWidget?: React.ReactNode;
93
+ emptyComponent?: React.ReactNode;
94
+ getIdColumnWidth?: () => number;
93
95
  };
94
96
  export type GetPropertyForProps<M extends Record<string, any>> = {
95
97
  propertyKey: string;
@@ -1,4 +1,5 @@
1
- import { CollectionSize, Entity } from "../../../../types";
1
+ import React from "react";
2
+ import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../../../types";
2
3
  /**
3
4
  *
4
5
  * @param entity
@@ -16,16 +17,19 @@ import { CollectionSize, Entity } from "../../../../types";
16
17
  *
17
18
  * @category Collection components
18
19
  */
19
- export declare function EntityCollectionRowActions<M extends Record<string, any>>({ entity, width, frozen, isSelected, selectionEnabled, size, toggleEntitySelection, onCopyClicked, onEditClicked, onDeleteClicked, hideId }: {
20
- entity: Entity<M>;
20
+ export declare const EntityCollectionRowActions: React.NamedExoticComponent<{
21
+ entity: Entity<any>;
22
+ collection?: EntityCollection<any, import("../../../../types").User> | undefined;
23
+ fullPath?: string | undefined;
21
24
  width: number;
22
- frozen?: boolean;
25
+ frozen?: boolean | undefined;
23
26
  size: CollectionSize;
24
27
  isSelected: boolean;
25
- selectionEnabled?: boolean;
26
- toggleEntitySelection?: (selectedEntity: Entity<M>) => void;
27
- onEditClicked?: (selectedEntity: Entity<M>) => void;
28
- onCopyClicked?: (selectedEntity: Entity<M>) => void;
29
- onDeleteClicked?: (selectedEntity: Entity<M>) => void;
30
- hideId?: boolean;
31
- }): import("react/jsx-runtime").JSX.Element;
28
+ selectionEnabled?: boolean | undefined;
29
+ actions?: EntityAction[] | undefined;
30
+ hideId?: boolean | undefined;
31
+ onCollectionChange?: (() => void) | undefined;
32
+ selectionController?: SelectionController | undefined;
33
+ highlightEntity?: ((entity: Entity<any>) => void) | undefined;
34
+ unhighlightEntity?: ((entity: Entity<any>) => void) | undefined;
35
+ }>;
@@ -0,0 +1,5 @@
1
+ import { EntityAction } from "../../../../types";
2
+ export declare const editEntityAction: EntityAction;
3
+ export declare const copyEntityAction: EntityAction;
4
+ export declare const archiveEntityAction: EntityAction;
5
+ export declare const deleteEntityAction: EntityAction;
@@ -1,40 +1,4 @@
1
- import { CollectionSize, Entity, EntityCollection, FireCMSContext, ResolvedProperty, SelectedCellProps, User } from "../../../types";
2
- export type EntityCollectionTableProviderProps<M extends Record<string, any>, AdditionalKey extends string, UserType extends User> = {
3
- /**
4
- * Absolute collection path
5
- */
6
- path: string;
7
- /**
8
- * Use to resolve the collection properties for specific path, entity id or values
9
- */
10
- collection: EntityCollection<M>;
11
- /**
12
- * List of entities that will be displayed on top, no matter the ordering.
13
- * This is used for reference fields selection
14
- */
15
- entitiesDisplayedFirst?: Entity<M>[];
16
- /**
17
- * Callback when anywhere on the table is clicked
18
- */
19
- onEntityClick?(entity: Entity<M>): void;
20
- /**
21
- * Callback when the selected size of the table is changed
22
- */
23
- onSizeChanged?(size: CollectionSize): void;
24
- /**
25
- * Can the table be edited inline
26
- */
27
- inlineEditing: ((entity: Entity<any>) => boolean) | boolean;
28
- /**
29
- * Builder for creating the buttons in each row
30
- * @param entity
31
- * @param size
32
- */
33
- tableRowActionsBuilder?: ({ entity, size }: {
34
- entity: Entity<M>;
35
- size: CollectionSize;
36
- }) => React.ReactNode;
37
- };
1
+ import { CollectionSize, Entity, FireCMSContext, ResolvedProperty, SelectedCellProps } from "../../../types";
38
2
  export type EntityCollectionTableController<M extends Record<string, any>> = {
39
3
  selectedCell?: SelectedCellProps<any>;
40
4
  select: (cell?: SelectedCellProps<M>) => void;
@@ -83,7 +83,7 @@ export interface VirtualTableProps<T extends Record<string, any>> {
83
83
  /**
84
84
  * Message displayed when there is no data
85
85
  */
86
- emptyMessage?: string;
86
+ emptyComponent?: React.ReactNode;
87
87
  /**
88
88
  * Is the table in a loading state
89
89
  */
@@ -0,0 +1,4 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { DialogsController } from "../../types/dialogs_controller";
3
+ export declare const DialogsControllerContext: React.Context<DialogsController>;
4
+ export declare const DialogsProvider: React.FC<PropsWithChildren<{}>>;
@@ -12,6 +12,6 @@ export * from "./form_field_configs";
12
12
  export * from "./useBuildModeController";
13
13
  export * from "../components/util/useOutsideAlerter";
14
14
  export * from "./useBuildLocalConfigurationPersistence";
15
- export { SnackbarProvider } from "./contexts/SnackbarContext";
15
+ export { SnackbarProvider } from "./contexts/SnackbarProvider";
16
16
  export { ModeControllerProvider } from "./contexts/ModeController";
17
17
  export * from "./contexts/AuthControllerContext";
@@ -1,14 +1,14 @@
1
1
  import { AuthController, CMSView, CMSViewsBuilder, DataSource, EntityCollection, EntityCollectionsBuilder, FireCMSPlugin, NavigationContext, User, UserConfigurationPersistence } from "../../types";
2
- type BuildNavigationContextProps<UserType extends User> = {
2
+ type BuildNavigationContextProps<EC extends EntityCollection, UserType extends User> = {
3
3
  basePath: string;
4
4
  baseCollectionPath: string;
5
5
  authController: AuthController<UserType>;
6
- collections?: EntityCollection[] | EntityCollectionsBuilder;
6
+ collections?: EC[] | EntityCollectionsBuilder<EC>;
7
7
  views?: CMSView[] | CMSViewsBuilder;
8
8
  userConfigPersistence?: UserConfigurationPersistence;
9
9
  plugins?: FireCMSPlugin[];
10
10
  dataSource: DataSource;
11
11
  };
12
- export declare function useBuildNavigationContext<UserType extends User>({ basePath, baseCollectionPath, authController, collections: baseCollections, views: baseViews, userConfigPersistence, plugins, dataSource }: BuildNavigationContextProps<UserType>): NavigationContext;
12
+ export declare function useBuildNavigationContext<EC extends EntityCollection, UserType extends User>({ basePath, baseCollectionPath, authController, collections: baseCollections, views: baseViews, userConfigPersistence, plugins, dataSource }: BuildNavigationContextProps<EC, UserType>): NavigationContext;
13
13
  export declare function getSidePanelKey(path: string, entityId?: string): string;
14
14
  export {};
@@ -1,6 +1,6 @@
1
1
  import { ArrayProperty, CMSType, EntityCollection, EntityCustomView, EntityValues, EnumValueConfig, EnumValues, PropertyConfig, NumberProperty, PropertiesOrBuilders, PropertyOrBuilder, ResolvedArrayProperty, ResolvedEntityCollection, ResolvedNumberProperty, ResolvedProperties, ResolvedProperty, ResolvedStringProperty, StringProperty, UserConfigurationPersistence } from "../../types";
2
2
  export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, fields }: {
3
- collection: EntityCollection<M, string, import("../../types").User> | ResolvedEntityCollection<M>;
3
+ collection: EntityCollection<M, import("../../types").User> | ResolvedEntityCollection<M>;
4
4
  path: string;
5
5
  entityId?: string | undefined;
6
6
  values?: Partial<M> | undefined;
@@ -0,0 +1,11 @@
1
+ import { DialogsController } from "../types/dialogs_controller";
2
+ /**
3
+ * Use this hook to open a dialog imperatively.
4
+ * Alternatively, you can use dialogs declaratively using the `Dialog` component.
5
+ *
6
+ * Consider that in order to use this hook you need to have a parent
7
+ * `FireCMS`
8
+ *
9
+ * @category Hooks and utilities
10
+ */
11
+ export declare const useDialogsController: () => DialogsController;