@firecms/core 3.0.0-beta.4.pre.2 → 3.0.0-beta.6

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 (109) hide show
  1. package/README.md +1 -1
  2. package/dist/components/ClearFilterSortButton.d.ts +5 -0
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
  4. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -1
  5. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
  6. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +11 -1
  7. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
  8. package/dist/components/EntityPreview.d.ts +2 -2
  9. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  10. package/dist/components/common/types.d.ts +1 -1
  11. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  12. package/dist/form/components/ErrorFocus.d.ts +1 -1
  13. package/dist/hooks/data/delete.d.ts +2 -2
  14. package/dist/hooks/data/save.d.ts +1 -1
  15. package/dist/hooks/data/useDataSource.d.ts +1 -1
  16. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  17. package/dist/hooks/index.d.ts +1 -0
  18. package/dist/hooks/useBuildNavigationController.d.ts +1 -2
  19. package/dist/hooks/useProjectLog.d.ts +2 -2
  20. package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
  21. package/dist/index.es.js +3948 -3737
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/index.umd.js +5 -5
  24. package/dist/index.umd.js.map +1 -1
  25. package/dist/internal/useBuildDataSource.d.ts +1 -16
  26. package/dist/internal/useRestoreScroll.d.ts +1 -1
  27. package/dist/preview/PropertyPreviewProps.d.ts +1 -4
  28. package/dist/types/auth.d.ts +30 -1
  29. package/dist/types/collections.d.ts +8 -4
  30. package/dist/types/datasource.d.ts +3 -6
  31. package/dist/types/entities.d.ts +5 -1
  32. package/dist/types/entity_callbacks.d.ts +2 -2
  33. package/dist/types/index.d.ts +1 -1
  34. package/dist/types/navigation.d.ts +4 -4
  35. package/dist/types/plugins.d.ts +5 -3
  36. package/dist/types/properties.d.ts +2 -2
  37. package/dist/types/roles.d.ts +31 -0
  38. package/dist/types/storage.d.ts +11 -3
  39. package/dist/types/user.d.ts +5 -0
  40. package/dist/util/collections.d.ts +1 -1
  41. package/dist/util/entities.d.ts +1 -1
  42. package/dist/util/navigation_utils.d.ts +2 -2
  43. package/dist/util/resolutions.d.ts +5 -5
  44. package/dist/util/useTraceUpdate.d.ts +1 -0
  45. package/package.json +23 -20
  46. package/src/components/ClearFilterSortButton.tsx +41 -0
  47. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -11
  48. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -1
  49. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +16 -19
  50. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
  51. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
  52. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
  53. package/src/components/EntityCollectionView/EntityCollectionView.tsx +28 -5
  54. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  55. package/src/components/EntityPreview.tsx +5 -2
  56. package/src/components/EntityView.tsx +1 -1
  57. package/src/components/HomePage/DefaultHomePage.tsx +2 -2
  58. package/src/components/HomePage/NavigationCard.tsx +1 -1
  59. package/src/components/ReferenceWidget.tsx +1 -1
  60. package/src/components/SelectableTable/SelectableTable.tsx +1 -1
  61. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
  62. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
  63. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +24 -5
  64. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  65. package/src/components/VirtualTable/VirtualTable.tsx +28 -20
  66. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  67. package/src/components/common/types.tsx +1 -1
  68. package/src/contexts/AuthControllerContext.tsx +1 -1
  69. package/src/core/FireCMS.tsx +2 -3
  70. package/src/core/field_configs.tsx +1 -2
  71. package/src/form/EntityForm.tsx +1 -1
  72. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
  73. package/src/hooks/data/delete.ts +3 -3
  74. package/src/hooks/data/save.ts +2 -1
  75. package/src/hooks/data/useDataSource.tsx +1 -1
  76. package/src/hooks/data/useEntityFetch.tsx +3 -3
  77. package/src/hooks/index.tsx +2 -0
  78. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
  79. package/src/hooks/useBuildModeController.tsx +11 -5
  80. package/src/hooks/useBuildNavigationController.tsx +136 -59
  81. package/src/hooks/useProjectLog.tsx +8 -6
  82. package/src/hooks/useValidateAuthenticator.tsx +115 -0
  83. package/src/internal/useBuildDataSource.ts +42 -47
  84. package/src/internal/useBuildSideEntityController.tsx +18 -12
  85. package/src/preview/PropertyPreview.tsx +2 -12
  86. package/src/preview/PropertyPreviewProps.tsx +1 -11
  87. package/src/preview/components/BooleanPreview.tsx +4 -2
  88. package/src/preview/components/ReferencePreview.tsx +1 -1
  89. package/src/types/auth.tsx +40 -1
  90. package/src/types/collections.ts +8 -4
  91. package/src/types/datasource.ts +8 -5
  92. package/src/types/entities.ts +9 -1
  93. package/src/types/entity_callbacks.ts +2 -2
  94. package/src/types/index.ts +1 -1
  95. package/src/types/navigation.ts +6 -6
  96. package/src/types/plugins.tsx +6 -5
  97. package/src/types/properties.ts +5 -4
  98. package/src/types/roles.ts +41 -0
  99. package/src/types/storage.ts +12 -3
  100. package/src/types/user.ts +7 -0
  101. package/src/util/collections.ts +1 -1
  102. package/src/util/entities.ts +1 -1
  103. package/src/util/navigation_utils.ts +6 -6
  104. package/src/util/strings.ts +2 -2
  105. package/src/util/useTraceUpdate.tsx +2 -1
  106. package/dist/internal/useLocaleConfig.d.ts +0 -1
  107. package/dist/types/appcheck.d.ts +0 -26
  108. package/src/internal/useLocaleConfig.tsx +0 -18
  109. package/src/types/appcheck.ts +0 -29
@@ -1,4 +1,4 @@
1
- import { DataSource, DataSourceDelegate, EntityReference, GeoPoint, NavigationController, PropertyConfig } from "../types";
1
+ import { DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
2
2
  /**
3
3
  * Use this hook to build a {@link DataSource} based on Firestore
4
4
  * @param firebaseApp
@@ -9,18 +9,3 @@ export declare function useBuildDataSource({ delegate, propertyConfigs, navigati
9
9
  propertyConfigs?: Record<string, PropertyConfig>;
10
10
  navigationController: NavigationController;
11
11
  }): DataSource;
12
- /**
13
- * Recursive function that converts Firestore data types into CMS or plain
14
- * JS types.
15
- * FireCMS uses Javascript dates internally instead of Firestore timestamps.
16
- * This makes it easier to interact with the rest of the libraries and
17
- * bindings.
18
- * Also, Firestore references are replaced with {@link EntityReference}
19
- * @param data
20
- * @param buildReference
21
- * @param buildGeoPoint
22
- * @param buildDate
23
- * @param buildDelete
24
- * @group Firestore
25
- */
26
- export declare function cmsToDelegateModel(data: any, buildReference: (reference: EntityReference) => any, buildGeoPoint: (geoPoint: GeoPoint) => any, buildDate: (date: Date) => any, buildDelete: () => any): any;
@@ -2,5 +2,5 @@ import React from "react";
2
2
  export declare function useRestoreScroll(): {
3
3
  containerRef: React.RefObject<HTMLDivElement>;
4
4
  scroll: number;
5
- direction: "down" | "up";
5
+ direction: "up" | "down";
6
6
  };
@@ -6,7 +6,7 @@ export type PreviewSize = "medium" | "small" | "tiny";
6
6
  /**
7
7
  * @group Preview components
8
8
  */
9
- export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any, M extends Record<string, any> = Record<string, any>> {
9
+ export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any> {
10
10
  /**
11
11
  * Name of the property
12
12
  */
@@ -19,9 +19,6 @@ export interface PropertyPreviewProps<T extends CMSType = any, CustomProps = any
19
19
  * Property this display is related to
20
20
  */
21
21
  property: Property<T> | ResolvedProperty<T>;
22
- /**
23
- * Click handler
24
- */
25
22
  /**
26
23
  * Desired size of the preview, depending on the context.
27
24
  */
@@ -1,16 +1,23 @@
1
1
  import { User } from "./user";
2
+ import { Role } from "./roles";
3
+ import { DataSourceDelegate } from "./datasource";
4
+ import { StorageSource } from "./storage";
2
5
  /**
3
6
  * Controller for retrieving the logged user or performing auth related operations.
4
7
  * Note that if you are implementing your AuthController, you probably will want
5
8
  * to do it as the result of a hook.
6
9
  * @group Hooks and utilities
7
10
  */
8
- export type AuthController<UserType extends User = User, ExtraData extends any = any> = {
11
+ export type AuthController<UserType extends User = any, ExtraData extends any = any> = {
9
12
  /**
10
13
  * The user currently logged in
11
14
  * The values can be: the user object, null if they skipped login
12
15
  */
13
16
  user: UserType | null;
17
+ /**
18
+ * Roles related to the logged user
19
+ */
20
+ roles?: Role[];
14
21
  /**
15
22
  * Initial loading flag. It is used not to display the login screen
16
23
  * when the app first loads, and it has not been checked whether the user
@@ -45,3 +52,25 @@ export type AuthController<UserType extends User = User, ExtraData extends any =
45
52
  extra: ExtraData;
46
53
  setExtra: (extra: ExtraData) => void;
47
54
  };
55
+ /**
56
+ * Implement this function to allow access to specific users.
57
+ * @group Hooks and utilities
58
+ */
59
+ export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
60
+ /**
61
+ * Logged-in user or null
62
+ */
63
+ user: UserType | null;
64
+ /**
65
+ * AuthController
66
+ */
67
+ authController: Controller;
68
+ /**
69
+ * Connector to your database, e.g. your Firestore database
70
+ */
71
+ dataSourceDelegate: DataSourceDelegate;
72
+ /**
73
+ * Used storage implementation
74
+ */
75
+ storageSource: StorageSource;
76
+ }) => boolean | Promise<boolean>;
@@ -16,7 +16,7 @@ import { EntityOverrides } from "./entity_overrides";
16
16
  *
17
17
  * @group Models
18
18
  */
19
- export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = User> {
19
+ export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = any> {
20
20
  /**
21
21
  * You can set an alias that will be used internally instead of the `path`.
22
22
  * The `alias` value will be used to determine the URL of the collection,
@@ -94,6 +94,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
94
94
  * `subcollection:`. e.g. `subcollection:orders`.
95
95
  * - If you are using a collection group, you will also have an
96
96
  * additional `collectionGroupParent` column.
97
+ * You can use this prop to hide some properties from the table view.
98
+ * Note that if you set this prop, other ways to hide fields, like
99
+ * `hidden` in the property definition,will be ignored.
100
+ * `propertiesOrder` has precedence over `hidden`.
97
101
  */
98
102
  propertiesOrder?: Extract<keyof M, string>[];
99
103
  /**
@@ -128,7 +132,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
128
132
  * is being created, updated or deleted.
129
133
  * Useful for adding your own logic or blocking the execution of the operation.
130
134
  */
131
- callbacks?: EntityCallbacks<M>;
135
+ callbacks?: EntityCallbacks<M, UserType>;
132
136
  /**
133
137
  * Builder for rendering additional components such as buttons in the
134
138
  * collection toolbar
@@ -382,7 +386,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any, Us
382
386
  */
383
387
  value?: (props: {
384
388
  entity: Entity<M>;
385
- context: FireCMSContext;
389
+ context: FireCMSContext<any>;
386
390
  }) => string | number | Promise<string | number> | undefined;
387
391
  }
388
392
  /**
@@ -445,7 +449,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
445
449
  filterValues?: FilterValues<Extract<keyof M, string>>;
446
450
  setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
447
451
  sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
448
- setSortBy?: (sortBy: [Extract<keyof M, string>, "asc" | "desc"]) => void;
452
+ setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
449
453
  searchString?: string;
450
454
  setSearchString?: (searchString?: string) => void;
451
455
  clearFilter?: () => void;
@@ -1,4 +1,4 @@
1
- import { Entity, EntityReference, EntityStatus, EntityValues, GeoPoint } from "./entities";
1
+ import { Entity, EntityStatus, EntityValues } from "./entities";
2
2
  import { EntityCollection, FilterValues } from "./collections";
3
3
  import { ResolvedEntityCollection } from "./resolved_entities";
4
4
  /**
@@ -7,7 +7,7 @@ import { ResolvedEntityCollection } from "./resolved_entities";
7
7
  export interface FetchEntityProps<M extends Record<string, any> = any> {
8
8
  path: string;
9
9
  entityId: string;
10
- collection?: EntityCollection<M>;
10
+ collection?: EntityCollection<M, any>;
11
11
  }
12
12
  /**
13
13
  * @group Datasource
@@ -245,18 +245,15 @@ export interface DataSourceDelegate {
245
245
  * Convert a FireCMS reference to a reference that can be used by the datasource
246
246
  * @param reference
247
247
  */
248
- buildReference: (reference: EntityReference) => any;
249
248
  /**
250
249
  * Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
251
250
  * @param geoPoint
252
251
  */
253
- buildGeoPoint: (geoPoint: GeoPoint) => any;
254
252
  /**
255
253
  * Get the object to generate the current time in the datasource
256
254
  */
257
255
  currentTime(): any;
258
- buildDate: (date: Date) => any;
259
- buildDeleteFieldValue: () => any;
260
256
  delegateToCMSModel: (data: any) => any;
257
+ cmsToDelegateModel: (data: any) => any;
261
258
  setDateToMidnight: (input?: any) => any;
262
259
  }
@@ -31,7 +31,7 @@ export type EntityValues<M extends object> = M;
31
31
  /**
32
32
  * Class used to create a reference to an entity in a different path
33
33
  */
34
- export declare class EntityReference<M extends Record<string, any> = any> {
34
+ export declare class EntityReference {
35
35
  /**
36
36
  * ID of the entity
37
37
  */
@@ -56,3 +56,7 @@ export declare class GeoPoint {
56
56
  readonly longitude: number;
57
57
  constructor(latitude: number, longitude: number);
58
58
  }
59
+ export declare class Vector {
60
+ readonly value: number[];
61
+ constructor(value: number[]);
62
+ }
@@ -63,7 +63,7 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
63
63
  /**
64
64
  * Collection of the entity
65
65
  */
66
- collection: EntityCollection<M>;
66
+ collection: EntityCollection<M, UserType>;
67
67
  /**
68
68
  * Full path of the CMS where this collection is being fetched.
69
69
  * Might contain unresolved aliases.
@@ -155,7 +155,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
155
155
  /**
156
156
  * Context of the app status
157
157
  */
158
- context: FireCMSContext;
158
+ context: FireCMSContext<UserType>;
159
159
  }
160
160
  /**
161
161
  * Parameters passed to hooks when an entity is deleted
@@ -22,7 +22,7 @@ export * from "./local_config_persistence";
22
22
  export * from "./plugins";
23
23
  export * from "./analytics";
24
24
  export * from "./firecms";
25
- export * from "./appcheck";
25
+ export * from "./roles";
26
26
  export * from "./export_import";
27
27
  export * from "./modify_collections";
28
28
  export * from "./analytics_controller";
@@ -6,7 +6,7 @@ import { EntityReference } from "./entities";
6
6
  * attributes.
7
7
  * @group Models
8
8
  */
9
- export type NavigationController = {
9
+ export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
10
10
  /**
11
11
  * List of the mapped collections in the CMS.
12
12
  * Each entry relates to a collection in the root database.
@@ -47,15 +47,15 @@ export type NavigationController = {
47
47
  * Get the collection configuration for a given path.
48
48
  * The collection is resolved from the given path or alias.
49
49
  */
50
- getCollection: <EC extends EntityCollection = EntityCollection<any>>(pathOrAlias: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
50
+ getCollection: (pathOrId: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
51
51
  /**
52
52
  * Get the collection configuration from its parent path segments.
53
53
  */
54
- getCollectionFromIds: <EC extends EntityCollection = EntityCollection<any>>(ids: string[]) => EC | undefined;
54
+ getCollectionFromIds: (ids: string[]) => EC | undefined;
55
55
  /**
56
56
  * Get the collection configuration from its parent path segments.
57
57
  */
58
- getCollectionFromPaths: <EC extends EntityCollection = EntityCollection<any>>(pathSegments: string[]) => EC | undefined;
58
+ getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
59
59
  /**
60
60
  * Default path under the navigation routes of the CMS will be created
61
61
  */
@@ -11,11 +11,11 @@ import { ResolvedProperty } from "./resolved_entities";
11
11
  * NOTE: This is a work in progress and the API is not stable yet.
12
12
  * @group Core
13
13
  */
14
- export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any> = {
14
+ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
15
15
  /**
16
- * Name of the plugin
16
+ * Key of the plugin. This is used to identify the plugin in the CMS.
17
17
  */
18
- name: string;
18
+ key: string;
19
19
  /**
20
20
  * If this flag is set to true, no content will be shown in the CMS
21
21
  * until the plugin is fully loaded.
@@ -78,6 +78,8 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
78
78
  */
79
79
  CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
80
80
  collectionActionsProps?: COL_ACTIONS_PROPS;
81
+ CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
82
+ collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
81
83
  showTextSearchBar?: (props: {
82
84
  context: FireCMSContext;
83
85
  path: string;
@@ -1,14 +1,14 @@
1
1
  import React from "react";
2
2
  import { FieldProps } from "./fields";
3
3
  import { PropertyPreviewProps } from "../preview";
4
- import { EntityReference, EntityValues, GeoPoint } from "./entities";
4
+ import { EntityReference, EntityValues, GeoPoint, Vector } from "./entities";
5
5
  import { ResolvedArrayProperty, ResolvedStringProperty } from "./resolved_entities";
6
6
  import { FilterValues } from "./collections";
7
7
  import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
8
8
  /**
9
9
  * @group Entity properties
10
10
  */
11
- export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends EntityReference ? "reference" : T extends Array<CMSType> ? "array" : T extends Record<string, any> ? "map" : never;
11
+ export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends Vector ? "vector" : T extends EntityReference ? "reference" : T extends Array<CMSType> ? "array" : T extends Record<string, any> ? "map" : never;
12
12
  /**
13
13
  * @group Entity properties
14
14
  */
@@ -0,0 +1,31 @@
1
+ import { Permissions } from "../index";
2
+ export type Role = {
3
+ /**
4
+ * ID of the role
5
+ */
6
+ id: string;
7
+ /**
8
+ * Name of the role
9
+ */
10
+ name: string;
11
+ /**
12
+ * If this flag is true, the user can perform any action
13
+ */
14
+ isAdmin?: boolean;
15
+ /**
16
+ * Default permissions for all collections for this role.
17
+ * You can override this values at the collection level using
18
+ * {@link collectionPermissions}
19
+ */
20
+ defaultPermissions?: Permissions;
21
+ /**
22
+ * Record of stripped collection ids to their permissions.
23
+ * @see stripCollectionPath
24
+ */
25
+ collectionPermissions?: Record<string, Permissions>;
26
+ config?: {
27
+ createCollections?: boolean;
28
+ editCollections?: boolean | "own";
29
+ deleteCollections?: boolean | "own";
30
+ };
31
+ };
@@ -6,6 +6,7 @@ export interface UploadFileProps {
6
6
  fileName?: string;
7
7
  path?: string;
8
8
  metadata?: any;
9
+ bucket?: string;
9
10
  }
10
11
  /**
11
12
  * @group Models
@@ -15,6 +16,10 @@ export interface UploadFileResult {
15
16
  * Storage path including the file name where the file was uploaded.
16
17
  */
17
18
  path: string;
19
+ /**
20
+ * Bucket where the file was uploaded
21
+ */
22
+ bucket: string;
18
23
  }
19
24
  /**
20
25
  * @group Models
@@ -66,17 +71,20 @@ export interface StorageSource {
66
71
  * @param fileName
67
72
  * @param path
68
73
  * @param metadata
74
+ * @param bucket
69
75
  */
70
- uploadFile: ({ file, fileName, path, metadata }: UploadFileProps) => Promise<UploadFileResult>;
76
+ uploadFile: ({ file, fileName, path, metadata, bucket }: UploadFileProps) => Promise<UploadFileResult>;
71
77
  /**
72
78
  * Convert a storage path or URL into a download configuration
73
79
  * @param path
80
+ * @param bucket
74
81
  */
75
- getDownloadURL: (pathOrUrl: string) => Promise<DownloadConfig>;
82
+ getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
76
83
  /**
77
84
  * Get a file from a storage path.
78
85
  * It returns null if the file does not exist.
79
86
  * @param props
87
+ * @param bucket
80
88
  */
81
- getFile: (path: string) => Promise<File | null>;
89
+ getFile: (path: string, bucket?: string) => Promise<File | null>;
82
90
  }
@@ -1,3 +1,4 @@
1
+ import { Role } from "./roles";
1
2
  /**
2
3
  * This interface represents a user.
3
4
  * It has some of the same fields as a Firebase User.
@@ -33,4 +34,8 @@ export type User = {
33
34
  *
34
35
  */
35
36
  readonly isAnonymous: boolean;
37
+ /**
38
+ *
39
+ */
40
+ roles?: Role[];
36
41
  };
@@ -8,4 +8,4 @@ export declare function resolveDefaultSelectedView(defaultSelectedView: string |
8
8
  * @param collections
9
9
  * @param permissionsBuilder
10
10
  */
11
- export declare const applyPermissionsFunctionIfEmpty: (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder) => EntityCollection[];
11
+ export declare const applyPermissionsFunctionIfEmpty: (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>) => EntityCollection[];
@@ -23,6 +23,6 @@ export declare function updateDateAutoValues<M extends Record<string, any>>({ in
23
23
  * @group Datasource
24
24
  */
25
25
  export declare function sanitizeData<M extends Record<string, any>>(values: EntityValues<M>, properties: ResolvedProperties<M>): any;
26
- export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference<M>;
26
+ export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference;
27
27
  export declare function traverseValuesProperties<M extends Record<string, any>>(inputValues: Partial<EntityValues<M>>, properties: ResolvedProperties<M>, operation: (value: any, property: Property) => any): EntityValues<M> | undefined;
28
28
  export declare function traverseValueProperty(inputValue: any, property: Property, operation: (value: any, property: Property) => any): any;
@@ -8,10 +8,10 @@ export declare function resolveCollectionPathIds(path: string, allCollections: E
8
8
  /**
9
9
  * Find the corresponding view at any depth for a given path.
10
10
  * Note that path or segments of the paths can be collection aliases.
11
- * @param pathOrAlias
11
+ * @param pathOrId
12
12
  * @param collections
13
13
  */
14
- export declare function getCollectionByPathOrId(pathOrAlias: string, collections: EntityCollection[]): EntityCollection | undefined;
14
+ export declare function getCollectionByPathOrId(pathOrId: string, collections: EntityCollection[]): EntityCollection | undefined;
15
15
  /**
16
16
  * Get the subcollection combinations from a path:
17
17
  * "sites/es/locales" => ["sites/es/locales", "sites"]
@@ -2,11 +2,11 @@ import { ArrayProperty, CMSType, EntityCollection, EntityCustomView, EntityValue
2
2
  export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, fields }: {
3
3
  collection: EntityCollection<M> | ResolvedEntityCollection<M>;
4
4
  path: string;
5
- entityId?: string | undefined;
6
- values?: Partial<M> | undefined;
7
- previousValues?: Partial<M> | undefined;
8
- userConfigPersistence?: UserConfigurationPersistence | undefined;
9
- fields?: Record<string, PropertyConfig> | undefined;
5
+ entityId?: string;
6
+ values?: Partial<EntityValues<M>>;
7
+ previousValues?: Partial<EntityValues<M>>;
8
+ userConfigPersistence?: UserConfigurationPersistence;
9
+ fields?: Record<string, PropertyConfig>;
10
10
  }) => ResolvedEntityCollection<M>;
11
11
  /**
12
12
  * Resolve property builders, enums and arrays.
@@ -1 +1,2 @@
1
+ export declare function printChanged(props: any, prev: any, path?: string | undefined, depth?: number | undefined, maxDepth?: number | undefined): void;
1
2
  export declare function useTraceUpdate(props: any, maxDepth?: number): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.4.pre.2",
4
+ "version": "3.0.0-beta.6",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -41,22 +41,25 @@
41
41
  ".": {
42
42
  "import": "./dist/index.es.js",
43
43
  "require": "./dist/index.umd.js",
44
- "types": "./dist/src/index.d.ts"
44
+ "types": "./dist/index.d.ts"
45
45
  },
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-beta.4.pre.2",
50
- "@firecms/ui": "^3.0.0-beta.4.pre.2",
51
- "@fontsource/ibm-plex-mono": "^5.0.12",
52
- "@fontsource/roboto": "^5.0.12",
53
- "@hello-pangea/dnd": "^16.5.0",
49
+ "@firecms/formex": "^3.0.0-beta.6",
50
+ "@firecms/ui": "^3.0.0-beta.6",
51
+ "@fontsource/jetbrains-mono": "^5.0.19",
52
+ "@hello-pangea/dnd": "^16.6.0",
53
+ "@radix-ui/react-portal": "^1.0.4",
54
+ "clsx": "^2.1.0",
54
55
  "date-fns": "^3.6.0",
55
56
  "history": "^5.3.0",
56
57
  "js-search": "^2.0.1",
57
58
  "markdown-it": "^14.1.0",
58
59
  "notistack": "^3.0.1",
59
60
  "object-hash": "^3.0.0",
61
+ "react-dropzone": "^14.2.3",
62
+ "react-fast-compare": "^3.2.2",
60
63
  "react-image-file-resizer": "^0.4.8",
61
64
  "react-markdown-editor-lite": "^1.3.4",
62
65
  "react-transition-group": "^4.4.5",
@@ -69,8 +72,8 @@
69
72
  "firebase": "^10.5.2",
70
73
  "react": "^18.2.0",
71
74
  "react-dom": "^18.2.0",
72
- "react-router": "^6.2.0",
73
- "react-router-dom": "^6.2.0"
75
+ "react-router": "^6.22.0",
76
+ "react-router-dom": "^6.22.0"
74
77
  },
75
78
  "eslintConfig": {
76
79
  "extends": [
@@ -81,16 +84,16 @@
81
84
  "devDependencies": {
82
85
  "@jest/globals": "^29.7.0",
83
86
  "@testing-library/jest-dom": "^6.4.2",
84
- "@testing-library/react": "^14.2.1",
87
+ "@testing-library/react": "^14.3.1",
85
88
  "@testing-library/user-event": "^14.5.2",
86
89
  "@types/jest": "^29.5.12",
87
- "@types/node": "^20.11.30",
90
+ "@types/node": "^20.12.7",
88
91
  "@types/object-hash": "^3.0.6",
89
- "@types/react": "^18.2.67",
90
- "@types/react-dom": "^18.2.22",
92
+ "@types/react": "^18.2.79",
93
+ "@types/react-dom": "^18.2.25",
91
94
  "@types/react-measure": "^2.0.12",
92
- "@typescript-eslint/eslint-plugin": "^7.3.1",
93
- "@typescript-eslint/parser": "^7.3.1",
95
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
96
+ "@typescript-eslint/parser": "^7.7.0",
94
97
  "@vitejs/plugin-react": "^4.2.1",
95
98
  "cross-env": "^7.0.3",
96
99
  "eslint": "^8.57.0",
@@ -100,22 +103,22 @@
100
103
  "eslint-plugin-promise": "^6.1.1",
101
104
  "eslint-plugin-react": "^7.34.1",
102
105
  "eslint-plugin-react-hooks": "^4.6.0",
103
- "firebase": "^10.9.0",
106
+ "firebase": "^10.11.0",
104
107
  "jest": "^29.7.0",
105
108
  "npm-run-all": "^4.1.5",
106
109
  "react-router": "^6.22.3",
107
110
  "react-router-dom": "^6.22.3",
108
111
  "ts-jest": "^29.1.2",
109
112
  "ts-node": "^10.9.2",
110
- "tsd": "^0.30.7",
111
- "typescript": "^5.4.2",
112
- "vite": "^5.1.6"
113
+ "tsd": "^0.31.0",
114
+ "typescript": "^5.4.5",
115
+ "vite": "^5.2.9"
113
116
  },
114
117
  "files": [
115
118
  "dist",
116
119
  "src"
117
120
  ],
118
- "gitHead": "77875cc369a0bfe7b0b141e794b14a819d5811df",
121
+ "gitHead": "ffcbddbd73211bb644ff7503c2c62790bff6202a",
119
122
  "publishConfig": {
120
123
  "access": "public"
121
124
  }
@@ -0,0 +1,41 @@
1
+ import { Button, FilterListOffIcon } from "@firecms/ui";
2
+ import { EntityTableController } from "../types";
3
+
4
+ export function ClearFilterSortButton({
5
+ tableController,
6
+ enabled
7
+ }: {
8
+ enabled: boolean;
9
+ tableController: EntityTableController
10
+ }) {
11
+ if (!enabled) {
12
+ return null;
13
+ }
14
+
15
+ const filterIsSet = !!tableController.filterValues && Object.keys(tableController.filterValues).length > 0;
16
+ const sortIsSet = !!tableController.sortBy && tableController.sortBy.length > 0;
17
+
18
+ if ((filterIsSet || sortIsSet) && (tableController.clearFilter || tableController.setSortBy)) {
19
+ let label;
20
+ if (filterIsSet && sortIsSet) {
21
+ label = "Clear filter and sort";
22
+ } else if (filterIsSet) {
23
+ label = "Clear filter";
24
+ } else {
25
+ label = "Clear sort";
26
+ }
27
+ return <Button
28
+ variant={"outlined"}
29
+ className="h-fit-content"
30
+ aria-label="filter clear"
31
+ onClick={() => {
32
+ tableController.clearFilter?.();
33
+ tableController.setSortBy?.(undefined);
34
+ }}
35
+ size={"small"}>
36
+ <FilterListOffIcon/>
37
+ {label}
38
+ </Button>
39
+ }
40
+ return null;
41
+ }
@@ -16,7 +16,6 @@ import { propertiesToColumns } from "./column_utils";
16
16
  import { ErrorView } from "../ErrorView";
17
17
  import { SelectableTable } from "../SelectableTable/SelectableTable";
18
18
 
19
-
20
19
  /**
21
20
  * This component is in charge of rendering a collection table with a high
22
21
  * degree of customization.
@@ -88,8 +87,6 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
88
87
 
89
88
  const selectedEntityIds = selectedEntities?.map(e => e.id);
90
89
 
91
- const filterIsSet = !!tableController.filterValues && Object.keys(tableController.filterValues).length > 0;
92
-
93
90
  const updateSize = useCallback((size: CollectionSize) => {
94
91
  if (onSizeChanged)
95
92
  onSizeChanged(size);
@@ -179,7 +176,10 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
179
176
 
180
177
  const child = Builder
181
178
  ? <Builder entity={entity} context={context}/>
182
- : <>{additionalField.value?.({ entity, context })}</>;
179
+ : <>{additionalField.value?.({
180
+ entity,
181
+ context
182
+ })}</>;
183
183
 
184
184
  return (
185
185
  <EntityTableCell
@@ -237,10 +237,12 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
237
237
 
238
238
  const columns: VirtualTableColumn[] = [
239
239
  idColumn,
240
- ...displayedColumnIds
241
- .map((p) => {
242
- return collectionColumns.find(c => c.key === p.key);
243
- }).filter(Boolean) as VirtualTableColumn[]
240
+ ...(displayedColumnIds
241
+ ? displayedColumnIds
242
+ .map((p) => {
243
+ return collectionColumns.find(c => c.key === p.key);
244
+ }).filter(Boolean)
245
+ : collectionColumns) as VirtualTableColumn[]
244
246
  ];
245
247
 
246
248
  const cellRenderer = (props: CellRendererParams<any>) => {
@@ -291,12 +293,9 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
291
293
  className="h-full w-full flex flex-col bg-white dark:bg-gray-950">
292
294
 
293
295
  <CollectionTableToolbar
294
- forceFilter={disabledFilterChange}
295
- filterIsSet={filterIsSet}
296
296
  onTextSearch={textSearchEnabled ? onTextSearch : undefined}
297
297
  textSearchLoading={textSearchLoading}
298
298
  onTextSearchClick={textSearchEnabled ? onTextSearchClick : undefined}
299
- clearFilter={tableController.clearFilter}
300
299
  size={size}
301
300
  onSizeChanged={updateSize}
302
301
  title={title}