@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.
Files changed (190) hide show
  1. package/dist/app/Drawer.d.ts +1 -1
  2. package/dist/app/Scaffold.d.ts +1 -1
  3. package/dist/components/ArrayContainer.d.ts +2 -1
  4. package/dist/components/CircularProgressCenter.d.ts +1 -1
  5. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
  6. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
  7. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  8. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
  9. package/dist/components/EntityPreview.d.ts +1 -1
  10. package/dist/components/ErrorView.d.ts +1 -1
  11. package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
  12. package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
  13. package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
  14. package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
  15. package/dist/components/common/useColumnsIds.d.ts +2 -1
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/core/DefaultAppBar.d.ts +1 -1
  18. package/dist/core/DefaultDrawer.d.ts +1 -1
  19. package/dist/core/DrawerNavigationItem.d.ts +2 -1
  20. package/dist/core/EntityEditView.d.ts +3 -3
  21. package/dist/core/FireCMS.d.ts +1 -1
  22. package/dist/core/NavigationRoutes.d.ts +1 -1
  23. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  24. package/dist/form/components/FormikArrayContainer.d.ts +2 -1
  25. package/dist/form/components/LabelWithIcon.d.ts +1 -1
  26. package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
  27. package/dist/form/components/index.d.ts +1 -0
  28. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  29. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  30. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  31. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  32. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  33. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
  34. package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
  35. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
  39. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  40. package/dist/form/index.d.ts +3 -3
  41. package/dist/form/useClearRestoreValue.d.ts +2 -2
  42. package/dist/hooks/useProjectLog.d.ts +2 -2
  43. package/dist/index.es.js +14127 -11014
  44. package/dist/index.es.js.map +1 -1
  45. package/dist/index.umd.js +19987 -587
  46. package/dist/index.umd.js.map +1 -1
  47. package/dist/preview/PropertyPreviewProps.d.ts +1 -1
  48. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  49. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  50. package/dist/types/auth.d.ts +1 -1
  51. package/dist/types/collections.d.ts +12 -3
  52. package/dist/types/datasource.d.ts +35 -22
  53. package/dist/types/entities.d.ts +1 -0
  54. package/dist/types/entity_overrides.d.ts +2 -2
  55. package/dist/types/fields.d.ts +20 -15
  56. package/dist/types/navigation.d.ts +1 -0
  57. package/dist/types/properties.d.ts +18 -18
  58. package/dist/types/side_dialogs_controller.d.ts +10 -0
  59. package/dist/types/storage.d.ts +75 -0
  60. package/dist/util/entities.d.ts +1 -1
  61. package/dist/util/icon_list.d.ts +5 -1
  62. package/dist/util/icons.d.ts +1 -0
  63. package/dist/util/index.d.ts +1 -0
  64. package/dist/util/plurals.d.ts +0 -2
  65. package/dist/util/property_utils.d.ts +1 -1
  66. package/dist/util/resolutions.d.ts +15 -1
  67. package/dist/util/storage.d.ts +1 -1
  68. package/dist/util/useStorageUploadController.d.ts +2 -2
  69. package/package.json +15 -17
  70. package/src/app/Drawer.tsx +1 -1
  71. package/src/app/Scaffold.tsx +22 -27
  72. package/src/components/ArrayContainer.tsx +15 -10
  73. package/src/components/CircularProgressCenter.tsx +1 -1
  74. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
  75. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
  76. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
  77. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
  78. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
  79. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
  80. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
  81. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
  82. package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
  83. package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
  84. package/src/components/EntityPreview.tsx +30 -31
  85. package/src/components/ErrorView.tsx +1 -1
  86. package/src/components/HomePage/DefaultHomePage.tsx +24 -18
  87. package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
  88. package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
  89. package/src/components/PropertyIdCopyTooltip.tsx +48 -0
  90. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
  91. package/src/components/SearchIconsView.tsx +5 -2
  92. package/src/components/SelectableTable/SelectableTable.tsx +2 -4
  93. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
  94. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
  95. package/src/components/VirtualTable/VirtualTable.tsx +33 -9
  96. package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
  97. package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
  98. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
  99. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
  100. package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
  101. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
  102. package/src/components/common/useColumnsIds.tsx +13 -0
  103. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
  104. package/src/components/common/useTableSearchHelper.ts +1 -0
  105. package/src/components/index.tsx +1 -0
  106. package/src/core/DefaultAppBar.tsx +3 -3
  107. package/src/core/DefaultDrawer.tsx +18 -12
  108. package/src/core/DrawerNavigationItem.tsx +31 -27
  109. package/src/core/EntityEditView.tsx +136 -109
  110. package/src/core/FireCMS.tsx +2 -2
  111. package/src/core/NavigationRoutes.tsx +1 -1
  112. package/src/core/SideDialogs.tsx +1 -0
  113. package/src/core/field_configs.tsx +5 -5
  114. package/src/form/PropertyFieldBinding.tsx +24 -14
  115. package/src/form/components/CustomIdField.tsx +4 -2
  116. package/src/form/components/FieldHelperText.tsx +1 -1
  117. package/src/form/components/FormikArrayContainer.tsx +4 -1
  118. package/src/form/components/LabelWithIcon.tsx +27 -19
  119. package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
  120. package/src/form/components/StorageItemPreview.tsx +1 -0
  121. package/src/form/components/StorageUploadProgress.tsx +0 -1
  122. package/src/form/components/index.tsx +1 -0
  123. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
  124. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
  125. package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
  126. package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
  127. package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
  128. package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
  129. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
  130. package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
  131. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
  132. package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
  133. package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
  134. package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
  135. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
  136. package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
  137. package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
  138. package/src/form/index.tsx +4 -9
  139. package/src/form/useClearRestoreValue.tsx +2 -2
  140. package/src/hooks/data/delete.ts +2 -1
  141. package/src/hooks/data/save.ts +5 -2
  142. package/src/hooks/data/useDataSource.tsx +11 -3
  143. package/src/hooks/useBuildNavigationController.tsx +10 -3
  144. package/src/hooks/useProjectLog.tsx +18 -7
  145. package/src/internal/useBuildDataSource.ts +59 -76
  146. package/src/internal/useBuildSideDialogsController.tsx +1 -0
  147. package/src/internal/useBuildSideEntityController.tsx +17 -4
  148. package/src/internal/useUnsavedChangesDialog.tsx +3 -1
  149. package/src/preview/PropertyPreview.tsx +2 -2
  150. package/src/preview/PropertyPreviewProps.tsx +1 -1
  151. package/src/preview/components/BooleanPreview.tsx +1 -1
  152. package/src/preview/components/EnumValuesChip.tsx +1 -1
  153. package/src/preview/components/ImagePreview.tsx +4 -2
  154. package/src/preview/components/ReferencePreview.tsx +2 -13
  155. package/src/preview/components/UrlComponentPreview.tsx +1 -1
  156. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  157. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
  158. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
  159. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
  160. package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
  161. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  162. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  163. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  164. package/src/preview/util.ts +2 -2
  165. package/src/types/auth.tsx +1 -1
  166. package/src/types/collections.ts +15 -4
  167. package/src/types/datasource.ts +42 -27
  168. package/src/types/entities.ts +2 -0
  169. package/src/types/entity_overrides.tsx +2 -2
  170. package/src/types/fields.tsx +23 -17
  171. package/src/types/navigation.ts +1 -0
  172. package/src/types/properties.ts +18 -17
  173. package/src/types/side_dialogs_controller.tsx +13 -0
  174. package/src/types/storage.ts +82 -0
  175. package/src/util/entities.ts +1 -1
  176. package/src/util/icon_list.ts +14 -9
  177. package/src/util/icons.tsx +8 -2
  178. package/src/util/index.ts +1 -0
  179. package/src/util/plurals.ts +0 -2
  180. package/src/util/property_utils.tsx +1 -1
  181. package/src/util/references.ts +3 -0
  182. package/src/util/resolutions.ts +43 -11
  183. package/src/util/storage.ts +6 -2
  184. package/src/util/useStorageUploadController.tsx +15 -7
  185. package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
  186. package/dist/form/PropertiesForm.d.ts +0 -8
  187. package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
  188. package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
  189. package/src/form/PropertiesForm.tsx +0 -81
  190. 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: collectionProp,
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
- return delegate.fetchCollection<M>({
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 isCollectionGroup = Boolean(collection?.collectionGroup) ?? false;
110
- if (!delegate.listenCollection)
110
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
111
+
112
+ if (!usedDelegate.listenCollection)
111
113
  throw Error("useBuildDataSource delegate not initialised");
112
114
 
113
- return delegate.listenCollection<M>({
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
- isCollectionGroup,
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> => delegate.fetchEntity({
141
- path,
142
- entityId
143
- }), [delegate]),
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
- if (!delegate.listenEntity)
170
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
171
+
172
+ if (!usedDelegate.listenEntity)
166
173
  throw Error("useBuildDataSource delegate not initialised");
167
174
 
168
- return delegate.listenEntity<M>({
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 = delegate.cmsToDelegateModel(
218
+ const firestoreValues = usedDelegate.cmsToDelegateModel(
210
219
  values,
211
220
  );
212
221
 
213
- const updatedFirestoreValues: EntityValues<M> = properties
222
+ const updatedValues: EntityValues<M> = properties
214
223
  ? updateDateAutoValues(
215
224
  {
216
225
  inputValues: firestoreValues,
217
226
  properties,
218
227
  status,
219
- timestampNowValue: delegate.currentTime(),
220
- setDateToMidnight: delegate.setDateToMidnight
228
+ timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
229
+ setDateToMidnight: usedDelegate.setDateToMidnight
221
230
  })
222
231
  : firestoreValues;
223
232
 
224
- return delegate.saveEntity({
233
+ return usedDelegate.saveEntity({
225
234
  path,
235
+ collection,
226
236
  entityId,
227
- values: updatedFirestoreValues,
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: delegate.delegateToCMSModel(updatedFirestoreValues)
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
- return delegate.deleteEntity({ entity });
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
- return delegate.checkUniqueField(path, name, value, entityId);
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
- return delegate.generateEntityId(path,);
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
- return delegate.countEntities!({
306
+ const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
307
+ return usedDelegate.countEntities!({
289
308
  path,
290
309
  filter,
291
310
  orderBy,
292
311
  order,
293
- isCollectionGroup: Boolean(collection.collectionGroup) ?? false
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
- if (!delegate.initTextSearch)
345
+ const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
346
+ if (!usedDelegate.initTextSearch)
324
347
  return false;
325
- return delegate.initTextSearch(props)
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
- // }
@@ -118,6 +118,7 @@ export function useBuildSideDialogsController(): SideDialogsController {
118
118
 
119
119
  return {
120
120
  sidePanels,
121
+ setSidePanels: updateSidePanels,
121
122
  close,
122
123
  open,
123
124
  replace
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from "react";
2
2
  import {
3
3
  EntityCollection,
4
4
  EntitySidePanelProps,
5
- NavigationController, PropertyConfig,
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<any>,
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: getEntityViewWidth(props, smallLayout),
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}
@@ -3,7 +3,7 @@ import { CMSType, Property, ResolvedProperty } from "../types";
3
3
  /**
4
4
  * @group Preview components
5
5
  */
6
- export type PreviewSize = "medium" | "small" | "tiny";
6
+ export type PreviewSize = "medium" | "small" | "smallest";
7
7
 
8
8
  /**
9
9
  * @group Preview components
@@ -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 === "tiny" ? "text-sm" : "")}>{property.name}</span>}
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: "tiny" | "small" | "medium";
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 === "tiny") {
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 title="Copy url to clipboard" side={"bottom"}>
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 = React.memo<ReferencePreviewProps>(function ReferencePreview(props: ReferencePreviewProps) {
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
- }, areEqual) as React.FunctionComponent<ReferencePreviewProps>;
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,
@@ -84,7 +84,7 @@ function VideoPreview({
84
84
  }: { size: PreviewSize, src: string, interactive: boolean }) {
85
85
 
86
86
  const imageSize = useMemo(() => {
87
- if (size === "tiny")
87
+ if (size === "smallest")
88
88
  return "140px";
89
89
  else if (size === "small")
90
90
  return "240px";
@@ -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" : "tiny";
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" : "tiny";
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" : "tiny";
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" : "tiny";
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 === "tiny")
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 === "tiny")
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 === "tiny" ? 40 : size === "small" ? 100 : 200;
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 === "tiny" ? "text-sm" : "")}>
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 === "tiny"
55
+ : (size === "smallest"
56
56
  ? <span className={"text-sm"}>{value}</span>
57
57
  : <>{value}</>
58
58
  );
@@ -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 === "tiny")
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 "tiny";
22
+ return "smallest";
23
23
  case "m":
24
24
  return "small";
25
25
  case "l":
@@ -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 extends any = any> = {
12
+ export type AuthController<UserType extends User = any, ExtraData = any> = {
13
13
 
14
14
  /**
15
15
  * The user currently logged in