@firecms/core 3.0.0-beta.8 → 3.0.0-beta.9
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/app/Drawer.d.ts +1 -1
- package/dist/app/Scaffold.d.ts +1 -1
- package/dist/components/ArrayContainer.d.ts +2 -1
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/core/DefaultAppBar.d.ts +1 -1
- package/dist/core/DefaultDrawer.d.ts +1 -1
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +3 -3
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -3
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.es.js +14127 -11014
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19987 -587
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/collections.d.ts +12 -3
- package/dist/types/datasource.d.ts +35 -22
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +20 -15
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/properties.d.ts +18 -18
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/storage.d.ts +75 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icons.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/property_utils.d.ts +1 -1
- package/dist/util/resolutions.d.ts +15 -1
- package/dist/util/storage.d.ts +1 -1
- package/dist/util/useStorageUploadController.d.ts +2 -2
- package/package.json +15 -17
- package/src/app/Drawer.tsx +1 -1
- package/src/app/Scaffold.tsx +22 -27
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
- package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
- package/src/components/EntityPreview.tsx +30 -31
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/HomePage/DefaultHomePage.tsx +24 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/PropertyIdCopyTooltip.tsx +48 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
- package/src/components/SearchIconsView.tsx +5 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -4
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
- package/src/components/common/useTableSearchHelper.ts +1 -0
- package/src/components/index.tsx +1 -0
- package/src/core/DefaultAppBar.tsx +3 -3
- package/src/core/DefaultDrawer.tsx +18 -12
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +136 -109
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +1 -1
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/form/PropertyFieldBinding.tsx +24 -14
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/components/LabelWithIcon.tsx +27 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +1 -0
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
- package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
- package/src/form/index.tsx +4 -9
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useDataSource.tsx +11 -3
- package/src/hooks/useBuildNavigationController.tsx +10 -3
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/internal/useBuildDataSource.ts +59 -76
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +17 -4
- package/src/internal/useUnsavedChangesDialog.tsx +3 -1
- package/src/preview/PropertyPreview.tsx +2 -2
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +4 -2
- package/src/preview/components/ReferencePreview.tsx +2 -13
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +2 -2
- package/src/types/auth.tsx +1 -1
- package/src/types/collections.ts +15 -4
- package/src/types/datasource.ts +42 -27
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +23 -17
- package/src/types/navigation.ts +1 -0
- package/src/types/properties.ts +18 -17
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +14 -9
- package/src/util/icons.tsx +8 -2
- package/src/util/index.ts +1 -0
- package/src/util/plurals.ts +0 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/references.ts +3 -0
- package/src/util/resolutions.ts +43 -11
- package/src/util/storage.ts +6 -2
- package/src/util/useStorageUploadController.tsx +15 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/form/PropertiesForm.d.ts +0 -8
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/form/PropertiesForm.tsx +0 -81
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
|
@@ -52,23 +52,25 @@ export function useBuildDataSource({
|
|
|
52
52
|
*/
|
|
53
53
|
fetchCollection: useCallback(<M extends Record<string, any>>({
|
|
54
54
|
path,
|
|
55
|
-
collection
|
|
55
|
+
collection,
|
|
56
56
|
filter,
|
|
57
57
|
limit,
|
|
58
58
|
startAfter,
|
|
59
59
|
searchString,
|
|
60
60
|
orderBy,
|
|
61
|
-
order
|
|
61
|
+
order,
|
|
62
62
|
}: FetchCollectionProps<M>
|
|
63
63
|
): Promise<Entity<M>[]> => {
|
|
64
|
-
|
|
64
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
65
|
+
return usedDelegate.fetchCollection<M>({
|
|
65
66
|
path,
|
|
66
67
|
filter,
|
|
67
68
|
limit,
|
|
68
69
|
startAfter,
|
|
69
70
|
searchString,
|
|
70
71
|
orderBy,
|
|
71
|
-
order
|
|
72
|
+
order,
|
|
73
|
+
collection
|
|
72
74
|
});
|
|
73
75
|
}, [delegate]),
|
|
74
76
|
|
|
@@ -89,7 +91,6 @@ export function useBuildDataSource({
|
|
|
89
91
|
* @group Firestore
|
|
90
92
|
*/
|
|
91
93
|
listenCollection: delegate.listenCollection
|
|
92
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
93
94
|
? useCallback(<M extends Record<string, any>>(
|
|
94
95
|
{
|
|
95
96
|
path,
|
|
@@ -106,11 +107,12 @@ export function useBuildDataSource({
|
|
|
106
107
|
): () => void => {
|
|
107
108
|
|
|
108
109
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
109
|
-
const
|
|
110
|
-
|
|
110
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
111
|
+
|
|
112
|
+
if (!usedDelegate.listenCollection)
|
|
111
113
|
throw Error("useBuildDataSource delegate not initialised");
|
|
112
114
|
|
|
113
|
-
return
|
|
115
|
+
return usedDelegate.listenCollection<M>({
|
|
114
116
|
path,
|
|
115
117
|
filter,
|
|
116
118
|
limit,
|
|
@@ -120,8 +122,7 @@ export function useBuildDataSource({
|
|
|
120
122
|
order,
|
|
121
123
|
onUpdate,
|
|
122
124
|
onError,
|
|
123
|
-
|
|
124
|
-
collection
|
|
125
|
+
collection,
|
|
125
126
|
});
|
|
126
127
|
}, [delegate, navigationController.getCollection])
|
|
127
128
|
: undefined,
|
|
@@ -135,12 +136,17 @@ export function useBuildDataSource({
|
|
|
135
136
|
*/
|
|
136
137
|
fetchEntity: useCallback(<M extends Record<string, any>>({
|
|
137
138
|
path,
|
|
138
|
-
entityId
|
|
139
|
+
entityId,
|
|
140
|
+
collection
|
|
139
141
|
}: FetchEntityProps<M>
|
|
140
|
-
): Promise<Entity<M> | undefined> =>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
): Promise<Entity<M> | undefined> => {
|
|
143
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
144
|
+
return usedDelegate.fetchEntity({
|
|
145
|
+
path,
|
|
146
|
+
entityId,
|
|
147
|
+
collection
|
|
148
|
+
});
|
|
149
|
+
}, [delegate.fetchEntity]),
|
|
144
150
|
|
|
145
151
|
/**
|
|
146
152
|
*
|
|
@@ -153,7 +159,6 @@ export function useBuildDataSource({
|
|
|
153
159
|
* @group Firestore
|
|
154
160
|
*/
|
|
155
161
|
listenEntity: delegate.listenEntity
|
|
156
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
157
162
|
? useCallback(<M extends Record<string, any>>(
|
|
158
163
|
{
|
|
159
164
|
path,
|
|
@@ -162,14 +167,17 @@ export function useBuildDataSource({
|
|
|
162
167
|
onUpdate,
|
|
163
168
|
onError
|
|
164
169
|
}: ListenEntityProps<M>): () => void => {
|
|
165
|
-
|
|
170
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
171
|
+
|
|
172
|
+
if (!usedDelegate.listenEntity)
|
|
166
173
|
throw Error("useBuildDataSource delegate not initialised");
|
|
167
174
|
|
|
168
|
-
return
|
|
175
|
+
return usedDelegate.listenEntity<M>({
|
|
169
176
|
path,
|
|
170
177
|
entityId,
|
|
171
178
|
onUpdate,
|
|
172
|
-
onError
|
|
179
|
+
onError,
|
|
180
|
+
collection
|
|
173
181
|
})
|
|
174
182
|
}, [delegate.listenEntity]) : undefined,
|
|
175
183
|
|
|
@@ -194,6 +202,7 @@ export function useBuildDataSource({
|
|
|
194
202
|
}: SaveEntityProps<M>): Promise<Entity<M>> => {
|
|
195
203
|
|
|
196
204
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
205
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
197
206
|
|
|
198
207
|
const resolvedCollection = collection
|
|
199
208
|
? resolveCollection<M>({
|
|
@@ -206,31 +215,32 @@ export function useBuildDataSource({
|
|
|
206
215
|
|
|
207
216
|
const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
|
|
208
217
|
|
|
209
|
-
const firestoreValues =
|
|
218
|
+
const firestoreValues = usedDelegate.cmsToDelegateModel(
|
|
210
219
|
values,
|
|
211
220
|
);
|
|
212
221
|
|
|
213
|
-
const
|
|
222
|
+
const updatedValues: EntityValues<M> = properties
|
|
214
223
|
? updateDateAutoValues(
|
|
215
224
|
{
|
|
216
225
|
inputValues: firestoreValues,
|
|
217
226
|
properties,
|
|
218
227
|
status,
|
|
219
|
-
timestampNowValue:
|
|
220
|
-
setDateToMidnight:
|
|
228
|
+
timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
|
|
229
|
+
setDateToMidnight: usedDelegate.setDateToMidnight
|
|
221
230
|
})
|
|
222
231
|
: firestoreValues;
|
|
223
232
|
|
|
224
|
-
return
|
|
233
|
+
return usedDelegate.saveEntity({
|
|
225
234
|
path,
|
|
235
|
+
collection,
|
|
226
236
|
entityId,
|
|
227
|
-
values:
|
|
237
|
+
values: updatedValues,
|
|
228
238
|
status
|
|
229
239
|
}).then((res) => {
|
|
230
240
|
return {
|
|
231
241
|
id: res.id,
|
|
232
242
|
path: res.path,
|
|
233
|
-
values:
|
|
243
|
+
values: usedDelegate.delegateToCMSModel(updatedValues)
|
|
234
244
|
} as Entity<M>;
|
|
235
245
|
});
|
|
236
246
|
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
@@ -243,10 +253,15 @@ export function useBuildDataSource({
|
|
|
243
253
|
*/
|
|
244
254
|
deleteEntity: useCallback(<M extends Record<string, any>>(
|
|
245
255
|
{
|
|
246
|
-
entity
|
|
256
|
+
entity,
|
|
257
|
+
collection
|
|
247
258
|
}: DeleteEntityProps<M>
|
|
248
259
|
): Promise<void> => {
|
|
249
|
-
|
|
260
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
261
|
+
return usedDelegate.deleteEntity({
|
|
262
|
+
entity,
|
|
263
|
+
collection
|
|
264
|
+
});
|
|
250
265
|
}, [delegate.deleteEntity]),
|
|
251
266
|
|
|
252
267
|
/**
|
|
@@ -263,13 +278,16 @@ export function useBuildDataSource({
|
|
|
263
278
|
path: string,
|
|
264
279
|
name: string,
|
|
265
280
|
value: any,
|
|
266
|
-
entityId?: string
|
|
281
|
+
entityId?: string,
|
|
282
|
+
collection?: EntityCollection
|
|
267
283
|
): Promise<boolean> => {
|
|
268
|
-
|
|
284
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
285
|
+
return usedDelegate.checkUniqueField(path, name, value, entityId, collection);
|
|
269
286
|
}, [delegate.checkUniqueField]),
|
|
270
287
|
|
|
271
|
-
generateEntityId: useCallback((path: string): string => {
|
|
272
|
-
|
|
288
|
+
generateEntityId: useCallback((path: string, collection: EntityCollection): string => {
|
|
289
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
290
|
+
return usedDelegate.generateEntityId(path, collection);
|
|
273
291
|
}, [delegate.generateEntityId]),
|
|
274
292
|
|
|
275
293
|
countEntities: delegate.countEntities ? async ({
|
|
@@ -285,21 +303,24 @@ export function useBuildDataSource({
|
|
|
285
303
|
orderBy?: string,
|
|
286
304
|
order?: "desc" | "asc",
|
|
287
305
|
}): Promise<number> => {
|
|
288
|
-
|
|
306
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
307
|
+
return usedDelegate.countEntities!({
|
|
289
308
|
path,
|
|
290
309
|
filter,
|
|
291
310
|
orderBy,
|
|
292
311
|
order,
|
|
293
|
-
|
|
312
|
+
collection
|
|
294
313
|
});
|
|
295
314
|
} : undefined,
|
|
296
315
|
|
|
297
316
|
isFilterCombinationValid: useCallback(({
|
|
298
317
|
path,
|
|
318
|
+
databaseId,
|
|
299
319
|
filterValues,
|
|
300
320
|
sortBy
|
|
301
321
|
}: {
|
|
302
322
|
path: string,
|
|
323
|
+
databaseId?: string,
|
|
303
324
|
filterValues: FilterValues<any>,
|
|
304
325
|
sortBy?: [string, "asc" | "desc"]
|
|
305
326
|
}): boolean => {
|
|
@@ -308,6 +329,7 @@ export function useBuildDataSource({
|
|
|
308
329
|
return delegate.isFilterCombinationValid(
|
|
309
330
|
{
|
|
310
331
|
path,
|
|
332
|
+
databaseId,
|
|
311
333
|
filterValues,
|
|
312
334
|
sortBy
|
|
313
335
|
}
|
|
@@ -320,51 +342,12 @@ export function useBuildDataSource({
|
|
|
320
342
|
collection: EntityCollection,
|
|
321
343
|
parentCollectionIds?: string[]
|
|
322
344
|
}): Promise<boolean> => {
|
|
323
|
-
|
|
345
|
+
const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
346
|
+
if (!usedDelegate.initTextSearch)
|
|
324
347
|
return false;
|
|
325
|
-
return
|
|
348
|
+
return usedDelegate.initTextSearch(props)
|
|
326
349
|
}, [delegate.initTextSearch]),
|
|
327
350
|
|
|
328
351
|
};
|
|
329
352
|
|
|
330
353
|
}
|
|
331
|
-
|
|
332
|
-
// /**
|
|
333
|
-
// * Recursive function that converts Firestore data types into CMS or plain
|
|
334
|
-
// * JS types.
|
|
335
|
-
// * FireCMS uses Javascript dates internally instead of Firestore timestamps.
|
|
336
|
-
// * This makes it easier to interact with the rest of the libraries and
|
|
337
|
-
// * bindings.
|
|
338
|
-
// * Also, Firestore references are replaced with {@link EntityReference}
|
|
339
|
-
// * @param data
|
|
340
|
-
// * @param buildReference
|
|
341
|
-
// * @param buildGeoPoint
|
|
342
|
-
// * @param buildDate
|
|
343
|
-
// * @param buildDelete
|
|
344
|
-
// * @group Firestore
|
|
345
|
-
// */
|
|
346
|
-
// export function cmsToDelegateModel(data: any,
|
|
347
|
-
// buildReference: (reference: EntityReference) => any,
|
|
348
|
-
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
349
|
-
// buildDate: (date: Date) => any,
|
|
350
|
-
// buildDelete: () => any
|
|
351
|
-
// ): any {
|
|
352
|
-
// if (data === undefined) {
|
|
353
|
-
// return buildDelete();
|
|
354
|
-
// } else if (data === null) {
|
|
355
|
-
// return null;
|
|
356
|
-
// } else if (Array.isArray(data)) {
|
|
357
|
-
// return data.map(v => cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete));
|
|
358
|
-
// } else if (data.isEntityReference && data.isEntityReference()) {
|
|
359
|
-
// return buildReference(data);
|
|
360
|
-
// } else if (data instanceof GeoPoint) {
|
|
361
|
-
// return buildGeoPoint(data);
|
|
362
|
-
// } else if (data instanceof Date) {
|
|
363
|
-
// return buildDate(data);
|
|
364
|
-
// } else if (data && typeof data === "object") {
|
|
365
|
-
// return Object.entries(data)
|
|
366
|
-
// .map(([key, v]) => ({ [key]: cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete) }))
|
|
367
|
-
// .reduce((a, b) => ({ ...a, ...b }), {});
|
|
368
|
-
// }
|
|
369
|
-
// return data;
|
|
370
|
-
// }
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
EntityCollection,
|
|
4
4
|
EntitySidePanelProps,
|
|
5
|
-
NavigationController,
|
|
5
|
+
NavigationController,
|
|
6
6
|
ResolvedProperty,
|
|
7
7
|
SideDialogPanelProps,
|
|
8
8
|
SideDialogsController,
|
|
@@ -115,6 +115,16 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
115
115
|
}
|
|
116
116
|
}, [location, navigation.loading, navigation.isUrlCollectionPath, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, sideDialogsController, smallLayout, navigation]);
|
|
117
117
|
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {
|
|
120
|
+
if (sidePanelProps.additional) {
|
|
121
|
+
return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout);
|
|
122
|
+
}
|
|
123
|
+
return sidePanelProps;
|
|
124
|
+
});
|
|
125
|
+
sideDialogsController.setSidePanels(updatedSidePanels);
|
|
126
|
+
}, [smallLayout]);
|
|
127
|
+
|
|
118
128
|
const close = useCallback(() => {
|
|
119
129
|
sideDialogsController.close();
|
|
120
130
|
}, [sideDialogsController]);
|
|
@@ -210,7 +220,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
210
220
|
return sidePanels;
|
|
211
221
|
}
|
|
212
222
|
|
|
213
|
-
const propsToSidePanel = (props: EntitySidePanelProps
|
|
223
|
+
const propsToSidePanel = (props: EntitySidePanelProps,
|
|
214
224
|
buildUrlCollectionPath: (path: string) => string,
|
|
215
225
|
resolveAliasesFrom: (pathWithAliases: string) => string,
|
|
216
226
|
smallLayout: boolean): SideDialogPanelProps => {
|
|
@@ -227,13 +237,16 @@ const propsToSidePanel = (props: EntitySidePanelProps<any>,
|
|
|
227
237
|
path: resolvedPath,
|
|
228
238
|
};
|
|
229
239
|
|
|
240
|
+
const entityViewWidth = getEntityViewWidth(props, smallLayout);
|
|
241
|
+
|
|
230
242
|
return {
|
|
231
243
|
key: `${props.path}/${props.entityId}`,
|
|
232
244
|
component: <EntitySidePanel {...resolvedPanelProps}/>,
|
|
233
245
|
urlPath: newPath,
|
|
234
246
|
parentUrlPath: buildUrlCollectionPath(collectionPath),
|
|
235
|
-
width:
|
|
236
|
-
onClose: props.onClose
|
|
247
|
+
width: entityViewWidth,
|
|
248
|
+
onClose: props.onClose,
|
|
249
|
+
additional: props
|
|
237
250
|
};
|
|
238
251
|
}
|
|
239
252
|
;
|
|
@@ -84,8 +84,10 @@ export function UnsavedChangesDialog({
|
|
|
84
84
|
|
|
85
85
|
return (
|
|
86
86
|
<Dialog
|
|
87
|
+
onEscapeKeyDown={() => {
|
|
88
|
+
handleCancel();
|
|
89
|
+
}}
|
|
87
90
|
open={open}
|
|
88
|
-
onOpenChange={(open) => open ? handleCancel() : handleOk()}
|
|
89
91
|
>
|
|
90
92
|
<DialogContent>
|
|
91
93
|
<Typography variant={"h6"}>{title}</Typography>
|
|
@@ -86,6 +86,8 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
86
86
|
url={value}
|
|
87
87
|
interactive={interactive}
|
|
88
88
|
previewType={stringProperty.url}/>;
|
|
89
|
+
} else if (stringProperty.markdown) {
|
|
90
|
+
content = <Markdown source={value} size={"small"}/>;
|
|
89
91
|
} else if (stringProperty.storage) {
|
|
90
92
|
const filePath = stringProperty.storage.previewUrl ? stringProperty.storage.previewUrl(value) : value;
|
|
91
93
|
content = <StorageThumbnail
|
|
@@ -93,8 +95,6 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
93
95
|
storeUrl={property.storage?.storeUrl ?? false}
|
|
94
96
|
size={props.size}
|
|
95
97
|
storagePathOrDownloadUrl={filePath}/>;
|
|
96
|
-
} else if (stringProperty.markdown) {
|
|
97
|
-
content = <Markdown source={value} size={"small"}/>;
|
|
98
98
|
} else {
|
|
99
99
|
content = <StringPropertyPreview {...props}
|
|
100
100
|
property={stringProperty}
|
|
@@ -21,6 +21,6 @@ export function BooleanPreview({
|
|
|
21
21
|
size={size}
|
|
22
22
|
color={"secondary"}/>
|
|
23
23
|
{property.name && <span
|
|
24
|
-
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "
|
|
24
|
+
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "smallest" ? "text-sm" : "")}>{property.name}</span>}
|
|
25
25
|
</div>;
|
|
26
26
|
}
|
|
@@ -6,7 +6,7 @@ import { buildEnumLabel, enumToObjectEntries, getColorScheme, getLabelOrConfigFr
|
|
|
6
6
|
export interface EnumValuesChipProps {
|
|
7
7
|
enumValues?: EnumValues;
|
|
8
8
|
enumKey: string | number;
|
|
9
|
-
size: "
|
|
9
|
+
size: "smallest" | "small" | "medium";
|
|
10
10
|
className?: string;
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
}
|
|
@@ -22,7 +22,7 @@ export function ImagePreview({
|
|
|
22
22
|
|
|
23
23
|
const imageSize = useMemo(() => getThumbnailMeasure(size), [size]);
|
|
24
24
|
|
|
25
|
-
if (size === "
|
|
25
|
+
if (size === "smallest") {
|
|
26
26
|
return (
|
|
27
27
|
<img src={url}
|
|
28
28
|
className={"rounded-md"}
|
|
@@ -58,7 +58,9 @@ export function ImagePreview({
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
<div className={"flex flex-row gap-2 absolute bottom-[-4px] right-[-4px] invisible group-hover:visible"}>
|
|
61
|
-
{navigator && <Tooltip
|
|
61
|
+
{navigator && <Tooltip
|
|
62
|
+
asChild={true}
|
|
63
|
+
title="Copy url to clipboard" side={"bottom"}>
|
|
62
64
|
<IconButton
|
|
63
65
|
variant={"filled"}
|
|
64
66
|
size={"small"}
|
|
@@ -21,7 +21,7 @@ export type ReferencePreviewProps = {
|
|
|
21
21
|
/**
|
|
22
22
|
* @group Preview components
|
|
23
23
|
*/
|
|
24
|
-
export const ReferencePreview =
|
|
24
|
+
export const ReferencePreview = function ReferencePreview(props: ReferencePreviewProps) {
|
|
25
25
|
const reference = props.reference;
|
|
26
26
|
if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
|
|
27
27
|
console.warn("Reference preview received value of type", typeof reference);
|
|
@@ -33,18 +33,7 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
33
33
|
</EntityPreviewContainer>;
|
|
34
34
|
}
|
|
35
35
|
return <ReferencePreviewInternal {...props} />;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewProps) {
|
|
39
|
-
return prevProps.disabled === nextProps.disabled &&
|
|
40
|
-
prevProps.size === nextProps.size &&
|
|
41
|
-
prevProps.hover === nextProps.hover &&
|
|
42
|
-
prevProps.reference?.id === nextProps.reference?.id &&
|
|
43
|
-
prevProps.reference?.path === nextProps.reference?.path &&
|
|
44
|
-
prevProps.includeEntityLink === nextProps.includeEntityLink &&
|
|
45
|
-
prevProps.onClick === nextProps.onClick
|
|
46
|
-
;
|
|
47
|
-
}
|
|
36
|
+
};
|
|
48
37
|
|
|
49
38
|
function ReferencePreviewInternal({
|
|
50
39
|
disabled,
|
|
@@ -54,7 +54,7 @@ export function ArrayOfMapsPreview({
|
|
|
54
54
|
values.map((v, index) => {
|
|
55
55
|
return (
|
|
56
56
|
<div key={`table_${v}_${index}`}
|
|
57
|
-
className="border-b last:border-b-0">
|
|
57
|
+
className="border-b last:border-b-0 py-2">
|
|
58
58
|
{mapProperties && mapProperties.map(
|
|
59
59
|
(key) => (
|
|
60
60
|
<div
|
|
@@ -28,7 +28,7 @@ export function ArrayOfReferencesPreview({
|
|
|
28
28
|
if (property?.dataType !== "array" || !property.of || property.of.dataType !== "reference")
|
|
29
29
|
throw Error("Picked wrong preview component ArrayOfReferencesPreview");
|
|
30
30
|
|
|
31
|
-
const childSize: PreviewSize = size === "medium" ? "small" : "
|
|
31
|
+
const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<div className="flex flex-col w-full">
|
|
@@ -33,7 +33,7 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
33
33
|
if (property.dataType !== "array" || !property.of || property.of.dataType !== "string")
|
|
34
34
|
throw Error("Picked wrong preview component ArrayOfStorageComponentsPreview");
|
|
35
35
|
|
|
36
|
-
const childSize: PreviewSize = size === "medium" ? "small" : "
|
|
36
|
+
const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div className={"flex flex-wrap gap-2"}>
|
|
@@ -37,7 +37,7 @@ export function ArrayOneOfPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "small" : "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
|
|
41
41
|
|
|
42
42
|
const typeField = property.oneOf.typeField ?? DEFAULT_ONE_OF_TYPE;
|
|
43
43
|
const valueField = property.oneOf.valueField ?? DEFAULT_ONE_OF_VALUE;
|
|
@@ -49,7 +49,7 @@ export function ArrayOneOfPreview({
|
|
|
49
49
|
values.map((value, index) =>
|
|
50
50
|
<React.Fragment
|
|
51
51
|
key={"preview_array_" + value + "_" + index}>
|
|
52
|
-
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
|
|
52
|
+
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0 py-2")}>
|
|
53
53
|
<ErrorBoundary>
|
|
54
54
|
{value && <PropertyPreview
|
|
55
55
|
propertyKey={propertyKey}
|
|
@@ -37,7 +37,7 @@ export function ArrayPropertyPreview({
|
|
|
37
37
|
|
|
38
38
|
if (!values) return null;
|
|
39
39
|
|
|
40
|
-
const childSize: PreviewSize = size === "medium" ? "small" : "
|
|
40
|
+
const childSize: PreviewSize = size === "medium" ? "small" : "smallest";
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex flex-col gap-2">
|
|
@@ -34,7 +34,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
34
34
|
|
|
35
35
|
const mapPropertyKeys: string[] = Object.keys(mapProperty.properties)
|
|
36
36
|
|
|
37
|
-
if (size === "
|
|
37
|
+
if (size === "smallest")
|
|
38
38
|
return (
|
|
39
39
|
<div className="w-full flex flex-col space-y-1 md:space-y-2">
|
|
40
40
|
{mapPropertyKeys.map((key, index) => (
|
|
@@ -87,7 +87,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
87
87
|
mapPropertyKeys = (property.previewProperties || Object.keys(property.properties)) as string[];
|
|
88
88
|
if (size === "small")
|
|
89
89
|
mapPropertyKeys = mapPropertyKeys.slice(0, 3);
|
|
90
|
-
else if (size === "
|
|
90
|
+
else if (size === "smallest")
|
|
91
91
|
mapPropertyKeys = mapPropertyKeys.slice(0, 1);
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -226,7 +226,7 @@ function renderUrlAudioComponent() {
|
|
|
226
226
|
|
|
227
227
|
export function renderSkeletonImageThumbnail(size: PreviewSize) {
|
|
228
228
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
229
|
-
const imageSize = size === "
|
|
229
|
+
const imageSize = size === "smallest" ? 40 : size === "small" ? 100 : 200;
|
|
230
230
|
return (
|
|
231
231
|
<Skeleton width={imageSize}
|
|
232
232
|
height={imageSize}/>
|
|
@@ -45,14 +45,14 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={cls("overflow-x-scroll", size === "
|
|
48
|
+
? <div className={cls("overflow-x-scroll", size === "smallest" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
|
52
52
|
{index !== lines.length - 1 && <br/>}
|
|
53
53
|
</React.Fragment>)}
|
|
54
54
|
</div>
|
|
55
|
-
: (size === "
|
|
55
|
+
: (size === "smallest"
|
|
56
56
|
? <span className={"text-sm"}>{value}</span>
|
|
57
57
|
: <>{value}</>
|
|
58
58
|
);
|
package/src/preview/util.ts
CHANGED
|
@@ -6,7 +6,7 @@ export const SMALL_THUMBNAIL = 100;
|
|
|
6
6
|
export const REGULAR_THUMBNAIL = 200;
|
|
7
7
|
|
|
8
8
|
export function getThumbnailMeasure(size: PreviewSize): number {
|
|
9
|
-
if (size === "
|
|
9
|
+
if (size === "smallest")
|
|
10
10
|
return TINY_THUMBNAIL;
|
|
11
11
|
else if (size === "small")
|
|
12
12
|
return SMALL_THUMBNAIL;
|
|
@@ -19,7 +19,7 @@ export function getPreviewSizeFrom(size: CollectionSize): PreviewSize {
|
|
|
19
19
|
switch (size) {
|
|
20
20
|
case "xs":
|
|
21
21
|
case "s":
|
|
22
|
-
return "
|
|
22
|
+
return "smallest";
|
|
23
23
|
case "m":
|
|
24
24
|
return "small";
|
|
25
25
|
case "l":
|
package/src/types/auth.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { StorageSource } from "./storage";
|
|
|
9
9
|
* to do it as the result of a hook.
|
|
10
10
|
* @group Hooks and utilities
|
|
11
11
|
*/
|
|
12
|
-
export type AuthController<UserType extends User = any, ExtraData
|
|
12
|
+
export type AuthController<UserType extends User = any, ExtraData = any> = {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The user currently logged in
|