@firecms/core 3.0.0-canary.41 → 3.0.0-canary.43
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/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/hooks/useValidateAuthenticator.d.ts +2 -6
- package/dist/index.es.js +2300 -2307
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -16
- package/dist/types/datasource.d.ts +2 -5
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/properties.d.ts +2 -2
- package/dist/util/entities.d.ts +1 -1
- package/package.json +17 -17
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -6
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -1
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +16 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -1
- package/src/components/HomePage/DefaultHomePage.tsx +1 -1
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/VirtualTable/VirtualTable.tsx +15 -17
- package/src/components/common/types.tsx +1 -1
- package/src/hooks/data/save.ts +1 -0
- package/src/hooks/useBuildNavigationController.tsx +4 -4
- package/src/hooks/useValidateAuthenticator.tsx +2 -22
- package/src/internal/useBuildDataSource.ts +42 -47
- package/src/preview/PropertyPreview.tsx +2 -12
- package/src/types/datasource.ts +7 -4
- package/src/types/entities.ts +9 -1
- package/src/types/index.ts +0 -1
- package/src/types/properties.ts +5 -4
- package/src/util/entities.ts +1 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/types/appcheck.ts +0 -29
|
@@ -5,12 +5,10 @@ import {
|
|
|
5
5
|
DeleteEntityProps,
|
|
6
6
|
Entity,
|
|
7
7
|
EntityCollection,
|
|
8
|
-
EntityReference,
|
|
9
8
|
EntityValues,
|
|
10
9
|
FetchCollectionProps,
|
|
11
10
|
FetchEntityProps,
|
|
12
11
|
FilterValues,
|
|
13
|
-
GeoPoint,
|
|
14
12
|
ListenCollectionProps,
|
|
15
13
|
ListenEntityProps,
|
|
16
14
|
NavigationController,
|
|
@@ -207,13 +205,10 @@ export function useBuildDataSource({
|
|
|
207
205
|
|
|
208
206
|
const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
|
|
209
207
|
|
|
210
|
-
const firestoreValues = cmsToDelegateModel(
|
|
208
|
+
const firestoreValues = delegate.cmsToDelegateModel(
|
|
211
209
|
values,
|
|
212
|
-
delegate.buildReference,
|
|
213
|
-
delegate.buildGeoPoint,
|
|
214
|
-
delegate.buildDate,
|
|
215
|
-
delegate.buildDeleteFieldValue
|
|
216
210
|
);
|
|
211
|
+
|
|
217
212
|
const updatedFirestoreValues: EntityValues<M> = properties
|
|
218
213
|
? updateDateAutoValues(
|
|
219
214
|
{
|
|
@@ -316,48 +311,48 @@ export function useBuildDataSource({
|
|
|
316
311
|
sortBy
|
|
317
312
|
}
|
|
318
313
|
)
|
|
319
|
-
}, [delegate.isFilterCombinationValid])
|
|
314
|
+
}, [delegate.isFilterCombinationValid]),
|
|
320
315
|
|
|
321
316
|
};
|
|
322
317
|
|
|
323
318
|
}
|
|
324
319
|
|
|
325
|
-
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
export function cmsToDelegateModel(data: any,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
): any {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
320
|
+
// /**
|
|
321
|
+
// * Recursive function that converts Firestore data types into CMS or plain
|
|
322
|
+
// * JS types.
|
|
323
|
+
// * FireCMS uses Javascript dates internally instead of Firestore timestamps.
|
|
324
|
+
// * This makes it easier to interact with the rest of the libraries and
|
|
325
|
+
// * bindings.
|
|
326
|
+
// * Also, Firestore references are replaced with {@link EntityReference}
|
|
327
|
+
// * @param data
|
|
328
|
+
// * @param buildReference
|
|
329
|
+
// * @param buildGeoPoint
|
|
330
|
+
// * @param buildDate
|
|
331
|
+
// * @param buildDelete
|
|
332
|
+
// * @group Firestore
|
|
333
|
+
// */
|
|
334
|
+
// export function cmsToDelegateModel(data: any,
|
|
335
|
+
// buildReference: (reference: EntityReference) => any,
|
|
336
|
+
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
337
|
+
// buildDate: (date: Date) => any,
|
|
338
|
+
// buildDelete: () => any
|
|
339
|
+
// ): any {
|
|
340
|
+
// if (data === undefined) {
|
|
341
|
+
// return buildDelete();
|
|
342
|
+
// } else if (data === null) {
|
|
343
|
+
// return null;
|
|
344
|
+
// } else if (Array.isArray(data)) {
|
|
345
|
+
// return data.map(v => cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete));
|
|
346
|
+
// } else if (data.isEntityReference && data.isEntityReference()) {
|
|
347
|
+
// return buildReference(data);
|
|
348
|
+
// } else if (data instanceof GeoPoint) {
|
|
349
|
+
// return buildGeoPoint(data);
|
|
350
|
+
// } else if (data instanceof Date) {
|
|
351
|
+
// return buildDate(data);
|
|
352
|
+
// } else if (data && typeof data === "object") {
|
|
353
|
+
// return Object.entries(data)
|
|
354
|
+
// .map(([key, v]) => ({ [key]: cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete) }))
|
|
355
|
+
// .reduce((a, b) => ({ ...a, ...b }), {});
|
|
356
|
+
// }
|
|
357
|
+
// return data;
|
|
358
|
+
// }
|
|
@@ -92,7 +92,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
92
92
|
size={props.size}
|
|
93
93
|
storagePathOrDownloadUrl={value}/>;
|
|
94
94
|
} else if (stringProperty.markdown) {
|
|
95
|
-
content = <Markdown source={value}/>;
|
|
95
|
+
content = <Markdown source={value} size={"small"}/>;
|
|
96
96
|
} else {
|
|
97
97
|
content = <StringPropertyPreview {...props}
|
|
98
98
|
property={stringProperty}
|
|
@@ -113,17 +113,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
113
113
|
content = <ArrayPropertyPreview {...props}
|
|
114
114
|
value={value}
|
|
115
115
|
property={property as ResolvedArrayProperty}/>;
|
|
116
|
-
}
|
|
117
|
-
// else if (arrayProperty.of.dataType === "map") {
|
|
118
|
-
// content =
|
|
119
|
-
// <ArrayOfMapsPreview propertyKey={propertyKey}
|
|
120
|
-
// property={property as ResolvedArrayProperty}
|
|
121
|
-
// value={value as Record<string, any>[]} // This might be wrong
|
|
122
|
-
// entity={entity}
|
|
123
|
-
// size={size}
|
|
124
|
-
// />;
|
|
125
|
-
// }
|
|
126
|
-
else if (arrayProperty.of.dataType === "reference") {
|
|
116
|
+
} else if (arrayProperty.of.dataType === "reference") {
|
|
127
117
|
content = <ArrayOfReferencesPreview {...props}
|
|
128
118
|
value={value}
|
|
129
119
|
property={property as ResolvedArrayProperty}/>;
|
package/src/types/datasource.ts
CHANGED
|
@@ -216,6 +216,7 @@ export interface DataSource {
|
|
|
216
216
|
* @param props
|
|
217
217
|
*/
|
|
218
218
|
isFilterCombinationValid?(props: FilterCombinationValidProps): boolean;
|
|
219
|
+
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
export type FilterCombinationValidProps = {
|
|
@@ -366,24 +367,26 @@ export interface DataSourceDelegate {
|
|
|
366
367
|
* Convert a FireCMS reference to a reference that can be used by the datasource
|
|
367
368
|
* @param reference
|
|
368
369
|
*/
|
|
369
|
-
buildReference: (reference: EntityReference) => any,
|
|
370
|
+
// buildReference: (reference: EntityReference) => any,
|
|
370
371
|
|
|
371
372
|
/**
|
|
372
373
|
* Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
|
|
373
374
|
* @param geoPoint
|
|
374
375
|
*/
|
|
375
|
-
buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
|
+
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
377
|
|
|
377
378
|
/**
|
|
378
379
|
* Get the object to generate the current time in the datasource
|
|
379
380
|
*/
|
|
380
381
|
currentTime(): any;
|
|
381
382
|
|
|
382
|
-
buildDate: (date: Date) => any;
|
|
383
|
+
// buildDate: (date: Date) => any;
|
|
383
384
|
|
|
384
|
-
buildDeleteFieldValue: () => any;
|
|
385
|
+
// buildDeleteFieldValue: () => any;
|
|
385
386
|
|
|
386
387
|
delegateToCMSModel: (data: any) => any;
|
|
387
388
|
|
|
389
|
+
cmsToDelegateModel: (data: any) => any;
|
|
390
|
+
|
|
388
391
|
setDateToMidnight: (input?: any) => any;
|
|
389
392
|
}
|
package/src/types/entities.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type EntityValues<M extends object> = M;
|
|
|
37
37
|
/**
|
|
38
38
|
* Class used to create a reference to an entity in a different path
|
|
39
39
|
*/
|
|
40
|
-
export class EntityReference
|
|
40
|
+
export class EntityReference {
|
|
41
41
|
/**
|
|
42
42
|
* ID of the entity
|
|
43
43
|
*/
|
|
@@ -78,3 +78,11 @@ export class GeoPoint {
|
|
|
78
78
|
this.longitude = longitude;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export class Vector {
|
|
83
|
+
readonly value: number[];
|
|
84
|
+
|
|
85
|
+
constructor(value: number[]) {
|
|
86
|
+
this.value = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ export * from "./plugins";
|
|
|
23
23
|
export * from "./analytics";
|
|
24
24
|
export * from "./firecms";
|
|
25
25
|
export * from "./roles";
|
|
26
|
-
export * from "./appcheck";
|
|
27
26
|
export * from "./export_import";
|
|
28
27
|
export * from "./modify_collections";
|
|
29
28
|
export * from "./analytics_controller";
|
package/src/types/properties.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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";
|
|
@@ -15,9 +15,10 @@ export type DataType<T extends CMSType = CMSType> =
|
|
|
15
15
|
T extends boolean ? "boolean" :
|
|
16
16
|
T extends Date ? "date" :
|
|
17
17
|
T extends GeoPoint ? "geopoint" :
|
|
18
|
-
T extends
|
|
19
|
-
T extends
|
|
20
|
-
T extends
|
|
18
|
+
T extends Vector ? "vector" :
|
|
19
|
+
T extends EntityReference ? "reference" :
|
|
20
|
+
T extends Array<CMSType> ? "array" :
|
|
21
|
+
T extends Record<string, any> ? "map" : never;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* @group Entity properties
|
package/src/util/entities.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function sanitizeData<M extends Record<string, any>>
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
export function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference
|
|
142
|
+
export function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference {
|
|
143
143
|
return new EntityReference(entity.id, entity.path);
|
|
144
144
|
}
|
|
145
145
|
|
package/dist/types/appcheck.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FirebaseApp } from "firebase/app";
|
|
2
|
-
/**
|
|
3
|
-
* @group Firebase
|
|
4
|
-
*/
|
|
5
|
-
export interface AppCheck {
|
|
6
|
-
firebaseApp?: FirebaseApp;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @group Firebase
|
|
10
|
-
*/
|
|
11
|
-
export interface AppCheckOptions {
|
|
12
|
-
providerKey: string;
|
|
13
|
-
useEnterpriseRecaptcha: boolean;
|
|
14
|
-
isTokenAutoRefreshEnabled?: boolean;
|
|
15
|
-
debugToken?: string;
|
|
16
|
-
forceRefresh?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @group Firebase
|
|
20
|
-
*/
|
|
21
|
-
export declare interface AppCheckTokenResult {
|
|
22
|
-
/**
|
|
23
|
-
* The token string in JWT format.
|
|
24
|
-
*/
|
|
25
|
-
readonly token: string;
|
|
26
|
-
}
|
package/src/types/appcheck.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FirebaseApp } from "firebase/app";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @group Firebase
|
|
5
|
-
*/
|
|
6
|
-
export interface AppCheck {
|
|
7
|
-
firebaseApp?: FirebaseApp;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @group Firebase
|
|
12
|
-
*/
|
|
13
|
-
export interface AppCheckOptions {
|
|
14
|
-
providerKey: string;
|
|
15
|
-
useEnterpriseRecaptcha: boolean;
|
|
16
|
-
isTokenAutoRefreshEnabled?: boolean;
|
|
17
|
-
debugToken?: string;
|
|
18
|
-
forceRefresh?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @group Firebase
|
|
23
|
-
*/
|
|
24
|
-
export declare interface AppCheckTokenResult {
|
|
25
|
-
/**
|
|
26
|
-
* The token string in JWT format.
|
|
27
|
-
*/
|
|
28
|
-
readonly token: string;
|
|
29
|
-
}
|