@firecms/core 3.0.0-canary.112 → 3.0.0-canary.113
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/index.es.js +53 -43
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +53 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/types/datasource.d.ts +8 -6
- package/dist/types/entity_overrides.d.ts +2 -2
- package/package.json +5 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
- package/src/core/EntityEditView.tsx +2 -2
- package/src/core/SideDialogs.tsx +0 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/useDataSource.tsx +10 -2
- package/src/hooks/useBuildNavigationController.tsx +2 -1
- package/src/internal/useBuildDataSource.ts +41 -67
- package/src/types/datasource.ts +9 -6
- package/src/types/entity_overrides.tsx +2 -2
package/dist/index.es.js
CHANGED
|
@@ -3248,8 +3248,6 @@ function replacePlaceholders({
|
|
|
3248
3248
|
const DataSourceContext = React__default.createContext({});
|
|
3249
3249
|
const useDataSource = (collection) => {
|
|
3250
3250
|
const defaultDataSource = useContext(DataSourceContext);
|
|
3251
|
-
if (collection?.overrides?.dataSource)
|
|
3252
|
-
return collection?.overrides.dataSource;
|
|
3253
3251
|
return defaultDataSource;
|
|
3254
3252
|
};
|
|
3255
3253
|
const NavigationContext = React__default.createContext({});
|
|
@@ -3387,7 +3385,7 @@ function useCollectionFetch({
|
|
|
3387
3385
|
itemCount,
|
|
3388
3386
|
searchString
|
|
3389
3387
|
}) {
|
|
3390
|
-
const dataSource = useDataSource(
|
|
3388
|
+
const dataSource = useDataSource();
|
|
3391
3389
|
const navigationController = useNavigationController();
|
|
3392
3390
|
const path = navigationController.resolveAliasesFrom(inputPath);
|
|
3393
3391
|
const sortByProperty = sortBy ? sortBy[0] : void 0;
|
|
@@ -3470,7 +3468,7 @@ function useEntityFetch({
|
|
|
3470
3468
|
collection,
|
|
3471
3469
|
useCache = false
|
|
3472
3470
|
}) {
|
|
3473
|
-
const dataSource = useDataSource(
|
|
3471
|
+
const dataSource = useDataSource();
|
|
3474
3472
|
const navigationController = useNavigationController();
|
|
3475
3473
|
const path = navigationController.resolveAliasesFrom(inputPath);
|
|
3476
3474
|
const context = useFireCMSContext();
|
|
@@ -3681,7 +3679,8 @@ async function deleteEntityWithCallbacks({
|
|
|
3681
3679
|
}
|
|
3682
3680
|
}
|
|
3683
3681
|
return dataSource.deleteEntity({
|
|
3684
|
-
entity
|
|
3682
|
+
entity,
|
|
3683
|
+
collection
|
|
3685
3684
|
}).then(() => {
|
|
3686
3685
|
onDeleteSuccess && onDeleteSuccess(entity);
|
|
3687
3686
|
try {
|
|
@@ -10348,7 +10347,7 @@ function useDataSourceEntityCollectionTableController({
|
|
|
10348
10347
|
} = collection;
|
|
10349
10348
|
const [popupCell, setPopupCell] = React__default.useState(void 0);
|
|
10350
10349
|
const navigation = useNavigationController();
|
|
10351
|
-
const dataSource = useDataSource(
|
|
10350
|
+
const dataSource = useDataSource();
|
|
10352
10351
|
const resolvedPath = useMemo(() => navigation.resolveAliasesFrom(fullPath), [fullPath, navigation.resolveAliasesFrom]);
|
|
10353
10352
|
const forceFilter = forceFilterFromProps ?? forceFilterFromCollection;
|
|
10354
10353
|
const paginationEnabled = collection.pagination === void 0 || Boolean(collection.pagination);
|
|
@@ -10596,7 +10595,7 @@ function DeleteEntityDialog({
|
|
|
10596
10595
|
onMultipleEntitiesDelete,
|
|
10597
10596
|
path
|
|
10598
10597
|
}) {
|
|
10599
|
-
const dataSource = useDataSource(
|
|
10598
|
+
const dataSource = useDataSource();
|
|
10600
10599
|
const customizationController = useCustomizationController();
|
|
10601
10600
|
const snackbarController = useSnackbarController();
|
|
10602
10601
|
const [loading, setLoading] = useState(false);
|
|
@@ -10891,7 +10890,8 @@ function ReferenceSelectionTable({
|
|
|
10891
10890
|
const analyticsController = useAnalyticsController();
|
|
10892
10891
|
const customizationController = useCustomizationController();
|
|
10893
10892
|
const fullPath = navigation.resolveAliasesFrom(pathInput);
|
|
10894
|
-
|
|
10893
|
+
console.trace("Opening reference dialog for path " + fullPath);
|
|
10894
|
+
const dataSource = useDataSource();
|
|
10895
10895
|
const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = useState([]);
|
|
10896
10896
|
const toggleEntitySelection = (entity) => {
|
|
10897
10897
|
let newValue;
|
|
@@ -12240,7 +12240,7 @@ const EntityCollectionView = React__default.memo(
|
|
|
12240
12240
|
}) {
|
|
12241
12241
|
const context = useFireCMSContext();
|
|
12242
12242
|
const fullPath = fullPathProp ?? collectionProp.path;
|
|
12243
|
-
const dataSource = useDataSource(
|
|
12243
|
+
const dataSource = useDataSource();
|
|
12244
12244
|
const navigation = useNavigationController();
|
|
12245
12245
|
const sideEntityController = useSideEntityController();
|
|
12246
12246
|
const authController = useAuthController();
|
|
@@ -12374,7 +12374,7 @@ const EntityCollectionView = React__default.memo(
|
|
|
12374
12374
|
value,
|
|
12375
12375
|
property,
|
|
12376
12376
|
entityId
|
|
12377
|
-
}) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection
|
|
12377
|
+
}) => dataSource.checkUniqueField(fullPath, name, value, entityId, collection),
|
|
12378
12378
|
[fullPath]
|
|
12379
12379
|
);
|
|
12380
12380
|
const onValueChange = ({
|
|
@@ -12754,7 +12754,7 @@ function EntitiesCount({
|
|
|
12754
12754
|
sortBy,
|
|
12755
12755
|
onCountChange
|
|
12756
12756
|
}) {
|
|
12757
|
-
const dataSource = useDataSource(
|
|
12757
|
+
const dataSource = useDataSource();
|
|
12758
12758
|
const navigation = useNavigationController();
|
|
12759
12759
|
const [count, setCount] = useState(void 0);
|
|
12760
12760
|
const [error, setError] = useState(void 0);
|
|
@@ -17311,7 +17311,7 @@ function EntityEditViewInner({
|
|
|
17311
17311
|
}, false, 2e3);
|
|
17312
17312
|
const inputCollection = collection;
|
|
17313
17313
|
const authController = useAuthController();
|
|
17314
|
-
const dataSource = useDataSource(
|
|
17314
|
+
const dataSource = useDataSource();
|
|
17315
17315
|
const sideDialogContext = useSideDialogContext();
|
|
17316
17316
|
const sideEntityController = useSideEntityController();
|
|
17317
17317
|
const snackbarController = useSnackbarController();
|
|
@@ -17333,7 +17333,7 @@ function EntityEditViewInner({
|
|
|
17333
17333
|
if (mustSetCustomId) {
|
|
17334
17334
|
return void 0;
|
|
17335
17335
|
} else {
|
|
17336
|
-
return dataSource.generateEntityId(path);
|
|
17336
|
+
return dataSource.generateEntityId(path, collection);
|
|
17337
17337
|
}
|
|
17338
17338
|
} else {
|
|
17339
17339
|
return entityIdProp;
|
|
@@ -17706,7 +17706,7 @@ function EntityEditViewInner({
|
|
|
17706
17706
|
name,
|
|
17707
17707
|
value,
|
|
17708
17708
|
property
|
|
17709
|
-
}) => dataSource.checkUniqueField(path, name, value, entityId, collection
|
|
17709
|
+
}) => dataSource.checkUniqueField(path, name, value, entityId, collection),
|
|
17710
17710
|
[dataSource, path, entityId]
|
|
17711
17711
|
);
|
|
17712
17712
|
const validationSchema = useMemo(
|
|
@@ -18259,11 +18259,9 @@ function SideDialogView({
|
|
|
18259
18259
|
setDrawerCloseRequested(false);
|
|
18260
18260
|
};
|
|
18261
18261
|
const onCloseRequest = (force) => {
|
|
18262
|
-
console.log("onCloseRequest", blocked, force);
|
|
18263
18262
|
if (blocked && !force) {
|
|
18264
18263
|
setDrawerCloseRequested(true);
|
|
18265
18264
|
} else {
|
|
18266
|
-
console.log("onCloseRequest closing");
|
|
18267
18265
|
sideDialogsController.close();
|
|
18268
18266
|
panel?.onClose?.();
|
|
18269
18267
|
}
|
|
@@ -18677,7 +18675,8 @@ function useBuildDataSource({
|
|
|
18677
18675
|
orderBy,
|
|
18678
18676
|
order
|
|
18679
18677
|
}) => {
|
|
18680
|
-
|
|
18678
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18679
|
+
return usedDelegate.fetchCollection({
|
|
18681
18680
|
path,
|
|
18682
18681
|
filter,
|
|
18683
18682
|
limit,
|
|
@@ -18717,10 +18716,10 @@ function useBuildDataSource({
|
|
|
18717
18716
|
onError
|
|
18718
18717
|
}) => {
|
|
18719
18718
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
18720
|
-
|
|
18721
|
-
if (!
|
|
18719
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18720
|
+
if (!usedDelegate.listenCollection)
|
|
18722
18721
|
throw Error("useBuildDataSource delegate not initialised");
|
|
18723
|
-
return
|
|
18722
|
+
return usedDelegate.listenCollection({
|
|
18724
18723
|
path,
|
|
18725
18724
|
filter,
|
|
18726
18725
|
limit,
|
|
@@ -18744,11 +18743,14 @@ function useBuildDataSource({
|
|
|
18744
18743
|
path,
|
|
18745
18744
|
entityId,
|
|
18746
18745
|
collection
|
|
18747
|
-
}) =>
|
|
18748
|
-
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
|
|
18746
|
+
}) => {
|
|
18747
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18748
|
+
return usedDelegate.fetchEntity({
|
|
18749
|
+
path,
|
|
18750
|
+
entityId,
|
|
18751
|
+
collection
|
|
18752
|
+
});
|
|
18753
|
+
}, [delegate.fetchEntity]),
|
|
18752
18754
|
/**
|
|
18753
18755
|
*
|
|
18754
18756
|
* @param path
|
|
@@ -18766,9 +18768,10 @@ function useBuildDataSource({
|
|
|
18766
18768
|
onUpdate,
|
|
18767
18769
|
onError
|
|
18768
18770
|
}) => {
|
|
18769
|
-
|
|
18771
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18772
|
+
if (!usedDelegate.listenEntity)
|
|
18770
18773
|
throw Error("useBuildDataSource delegate not initialised");
|
|
18771
|
-
return
|
|
18774
|
+
return usedDelegate.listenEntity({
|
|
18772
18775
|
path,
|
|
18773
18776
|
entityId,
|
|
18774
18777
|
onUpdate,
|
|
@@ -18795,6 +18798,7 @@ function useBuildDataSource({
|
|
|
18795
18798
|
status
|
|
18796
18799
|
}) => {
|
|
18797
18800
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
18801
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18798
18802
|
console.log("useBuildDatasource save", {
|
|
18799
18803
|
path,
|
|
18800
18804
|
entityId,
|
|
@@ -18810,29 +18814,29 @@ function useBuildDataSource({
|
|
|
18810
18814
|
fields: propertyConfigs
|
|
18811
18815
|
}) : void 0;
|
|
18812
18816
|
const properties = resolvedCollection?.properties;
|
|
18813
|
-
const firestoreValues =
|
|
18817
|
+
const firestoreValues = usedDelegate.cmsToDelegateModel(
|
|
18814
18818
|
values
|
|
18815
18819
|
);
|
|
18816
|
-
const
|
|
18820
|
+
const updatedValues = properties ? updateDateAutoValues(
|
|
18817
18821
|
{
|
|
18818
18822
|
inputValues: firestoreValues,
|
|
18819
18823
|
properties,
|
|
18820
18824
|
status,
|
|
18821
|
-
timestampNowValue:
|
|
18822
|
-
setDateToMidnight:
|
|
18825
|
+
timestampNowValue: usedDelegate.currentTime?.() ?? /* @__PURE__ */ new Date(),
|
|
18826
|
+
setDateToMidnight: usedDelegate.setDateToMidnight
|
|
18823
18827
|
}
|
|
18824
18828
|
) : firestoreValues;
|
|
18825
|
-
return
|
|
18829
|
+
return usedDelegate.saveEntity({
|
|
18826
18830
|
path,
|
|
18827
18831
|
collection,
|
|
18828
18832
|
entityId,
|
|
18829
|
-
values:
|
|
18833
|
+
values: updatedValues,
|
|
18830
18834
|
status
|
|
18831
18835
|
}).then((res) => {
|
|
18832
18836
|
return {
|
|
18833
18837
|
id: res.id,
|
|
18834
18838
|
path: res.path,
|
|
18835
|
-
values:
|
|
18839
|
+
values: usedDelegate.delegateToCMSModel(updatedValues)
|
|
18836
18840
|
};
|
|
18837
18841
|
});
|
|
18838
18842
|
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
@@ -18843,9 +18847,11 @@ function useBuildDataSource({
|
|
|
18843
18847
|
* @group Firestore
|
|
18844
18848
|
*/
|
|
18845
18849
|
deleteEntity: useCallback(({
|
|
18846
|
-
entity
|
|
18850
|
+
entity,
|
|
18851
|
+
collection
|
|
18847
18852
|
}) => {
|
|
18848
|
-
|
|
18853
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18854
|
+
return usedDelegate.deleteEntity({ entity, collection });
|
|
18849
18855
|
}, [delegate.deleteEntity]),
|
|
18850
18856
|
/**
|
|
18851
18857
|
* Check if the given property is unique in the given collection
|
|
@@ -18857,11 +18863,13 @@ function useBuildDataSource({
|
|
|
18857
18863
|
* @return `true` if there are no other fields besides the given entity
|
|
18858
18864
|
* @group Firestore
|
|
18859
18865
|
*/
|
|
18860
|
-
checkUniqueField: useCallback((path, name, value, entityId,
|
|
18861
|
-
|
|
18866
|
+
checkUniqueField: useCallback((path, name, value, entityId, collection) => {
|
|
18867
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18868
|
+
return usedDelegate.checkUniqueField(path, name, value, entityId, collection);
|
|
18862
18869
|
}, [delegate.checkUniqueField]),
|
|
18863
|
-
generateEntityId: useCallback((path) => {
|
|
18864
|
-
|
|
18870
|
+
generateEntityId: useCallback((path, collection) => {
|
|
18871
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18872
|
+
return usedDelegate.generateEntityId(path, collection);
|
|
18865
18873
|
}, [delegate.generateEntityId]),
|
|
18866
18874
|
countEntities: delegate.countEntities ? async ({
|
|
18867
18875
|
path,
|
|
@@ -18870,7 +18878,8 @@ function useBuildDataSource({
|
|
|
18870
18878
|
order,
|
|
18871
18879
|
orderBy
|
|
18872
18880
|
}) => {
|
|
18873
|
-
|
|
18881
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18882
|
+
return usedDelegate.countEntities({
|
|
18874
18883
|
path,
|
|
18875
18884
|
filter,
|
|
18876
18885
|
orderBy,
|
|
@@ -18896,9 +18905,10 @@ function useBuildDataSource({
|
|
|
18896
18905
|
);
|
|
18897
18906
|
}, [delegate.isFilterCombinationValid]),
|
|
18898
18907
|
initTextSearch: useCallback(async (props) => {
|
|
18899
|
-
|
|
18908
|
+
const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
18909
|
+
if (!usedDelegate.initTextSearch)
|
|
18900
18910
|
return false;
|
|
18901
|
-
return
|
|
18911
|
+
return usedDelegate.initTextSearch(props);
|
|
18902
18912
|
}, [delegate.initTextSearch])
|
|
18903
18913
|
};
|
|
18904
18914
|
}
|