@firecms/core 3.0.0-beta.11 → 3.0.0-beta.13

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 (201) hide show
  1. package/dist/app/Scaffold.d.ts +4 -0
  2. package/dist/components/ArrayContainer.d.ts +14 -3
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  5. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +15 -1
  6. package/dist/components/EntityCollectionTable/index.d.ts +1 -1
  7. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
  8. package/dist/components/EntityJsonPreview.d.ts +3 -0
  9. package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
  10. package/dist/components/SelectableTable/SelectableTable.d.ts +12 -2
  11. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
  12. package/dist/components/UnsavedChangesDialog.d.ts +8 -0
  13. package/dist/components/VirtualTable/VirtualTableProps.d.ts +13 -0
  14. package/dist/components/common/default_entity_actions.d.ts +0 -2
  15. package/dist/components/common/index.d.ts +1 -1
  16. package/dist/components/common/useColumnsIds.d.ts +1 -0
  17. package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
  18. package/dist/components/common/useDebouncedCallback.d.ts +1 -0
  19. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  20. package/dist/contexts/BreacrumbsContext.d.ts +8 -0
  21. package/dist/core/DefaultAppBar.d.ts +8 -2
  22. package/dist/core/EntityEditView.d.ts +36 -21
  23. package/dist/core/EntityEditViewFormActions.d.ts +2 -0
  24. package/dist/core/FireCMS.d.ts +2 -2
  25. package/dist/core/FireCMSRouter.d.ts +4 -0
  26. package/dist/core/NavigationRoutes.d.ts +0 -1
  27. package/dist/core/SideDialogs.d.ts +4 -2
  28. package/dist/core/index.d.ts +2 -1
  29. package/dist/form/EntityForm.d.ts +49 -0
  30. package/dist/form/EntityFormActions.d.ts +17 -0
  31. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  32. package/dist/form/components/FormEntry.d.ts +6 -0
  33. package/dist/form/components/FormLayout.d.ts +5 -0
  34. package/dist/form/components/index.d.ts +2 -0
  35. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  39. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  40. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  41. package/dist/form/index.d.ts +16 -16
  42. package/dist/hooks/data/save.d.ts +1 -1
  43. package/dist/hooks/data/useEntityFetch.d.ts +2 -1
  44. package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
  45. package/dist/hooks/useBuildNavigationController.d.ts +4 -1
  46. package/dist/hooks/useModeController.d.ts +1 -2
  47. package/dist/index.es.js +15842 -14396
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/index.umd.js +15833 -14389
  50. package/dist/index.umd.js.map +1 -1
  51. package/dist/internal/useBuildDataSource.d.ts +3 -2
  52. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  53. package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
  54. package/dist/routes/CustomCMSRoute.d.ts +4 -0
  55. package/dist/routes/FireCMSRoute.d.ts +1 -0
  56. package/dist/routes/HomePageRoute.d.ts +3 -0
  57. package/dist/types/collections.d.ts +36 -10
  58. package/dist/types/datasource.d.ts +2 -2
  59. package/dist/types/dialogs_controller.d.ts +7 -3
  60. package/dist/types/entities.d.ts +1 -1
  61. package/dist/types/entity_actions.d.ts +10 -0
  62. package/dist/types/fields.d.ts +13 -3
  63. package/dist/types/firecms.d.ts +1 -1
  64. package/dist/types/navigation.d.ts +33 -12
  65. package/dist/types/plugins.d.ts +2 -0
  66. package/dist/types/properties.d.ts +40 -4
  67. package/dist/types/side_entity_controller.d.ts +6 -1
  68. package/dist/util/builders.d.ts +1 -1
  69. package/dist/util/createFormexStub.d.ts +2 -0
  70. package/dist/util/entity_actions.d.ts +2 -0
  71. package/dist/util/entity_cache.d.ts +23 -0
  72. package/dist/util/index.d.ts +1 -0
  73. package/dist/util/navigation_from_path.d.ts +6 -1
  74. package/dist/util/navigation_utils.d.ts +13 -1
  75. package/dist/util/objects.d.ts +1 -1
  76. package/dist/util/property_utils.d.ts +2 -2
  77. package/dist/util/references.d.ts +2 -2
  78. package/dist/util/resolutions.d.ts +12 -2
  79. package/package.json +20 -21
  80. package/src/app/Scaffold.tsx +13 -3
  81. package/src/components/ArrayContainer.tsx +60 -24
  82. package/src/components/CircularProgressCenter.tsx +1 -1
  83. package/src/components/DeleteEntityDialog.tsx +5 -3
  84. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +46 -23
  85. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -4
  86. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +18 -1
  87. package/src/components/EntityCollectionTable/index.tsx +1 -1
  88. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
  89. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +10 -13
  90. package/src/components/EntityCollectionView/EntityCollectionView.tsx +105 -47
  91. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -2
  92. package/src/components/EntityJsonPreview.tsx +66 -0
  93. package/src/components/EntityPreview.tsx +10 -3
  94. package/src/components/EntityView.tsx +4 -1
  95. package/src/components/NotFoundPage.tsx +2 -2
  96. package/src/components/PropertyIdCopyTooltip.tsx +2 -3
  97. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +14 -7
  98. package/src/components/SelectableTable/SelectableTable.tsx +18 -3
  99. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +7 -7
  100. package/src/components/UnsavedChangesDialog.tsx +42 -0
  101. package/src/components/VirtualTable/VirtualTable.tsx +48 -3
  102. package/src/components/VirtualTable/VirtualTableProps.tsx +15 -0
  103. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +1 -1
  104. package/src/components/common/default_entity_actions.tsx +37 -37
  105. package/src/components/common/index.ts +1 -1
  106. package/src/components/common/useColumnsIds.tsx +1 -1
  107. package/src/components/common/useDataSourceTableController.tsx +420 -0
  108. package/src/components/common/useDebouncedCallback.tsx +20 -0
  109. package/src/components/common/useScrollRestoration.tsx +68 -0
  110. package/src/contexts/BreacrumbsContext.tsx +38 -0
  111. package/src/contexts/DialogsProvider.tsx +3 -2
  112. package/src/contexts/ModeController.tsx +1 -3
  113. package/src/core/DefaultAppBar.tsx +59 -17
  114. package/src/core/DefaultDrawer.tsx +1 -1
  115. package/src/core/EntityEditView.tsx +354 -1000
  116. package/src/core/EntityEditViewFormActions.tsx +199 -0
  117. package/src/core/EntitySidePanel.tsx +85 -15
  118. package/src/core/FireCMS.tsx +20 -16
  119. package/src/core/FireCMSRouter.tsx +17 -0
  120. package/src/core/NavigationRoutes.tsx +23 -32
  121. package/src/core/SideDialogs.tsx +20 -11
  122. package/src/core/index.tsx +4 -2
  123. package/src/form/EntityForm.tsx +782 -0
  124. package/src/form/EntityFormActions.tsx +169 -0
  125. package/src/form/PropertyFieldBinding.tsx +21 -16
  126. package/src/form/components/FormEntry.tsx +22 -0
  127. package/src/form/components/FormLayout.tsx +16 -0
  128. package/src/form/components/LabelWithIcon.tsx +6 -3
  129. package/src/form/components/StorageUploadProgress.tsx +1 -1
  130. package/src/form/components/index.tsx +2 -0
  131. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
  132. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +5 -2
  133. package/src/form/field_bindings/BlockFieldBinding.tsx +5 -3
  134. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -0
  135. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  136. package/src/form/field_bindings/MapFieldBinding.tsx +14 -16
  137. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +15 -8
  138. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +3 -3
  139. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  140. package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -1
  141. package/src/form/field_bindings/RepeatFieldBinding.tsx +13 -4
  142. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -2
  143. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +11 -6
  144. package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -0
  145. package/src/form/field_bindings/TextFieldBinding.tsx +1 -0
  146. package/src/form/index.tsx +16 -32
  147. package/src/form/validation.ts +12 -6
  148. package/src/hooks/data/save.ts +25 -30
  149. package/src/hooks/data/useCollectionFetch.tsx +1 -1
  150. package/src/hooks/data/useEntityFetch.tsx +5 -1
  151. package/src/hooks/useBreadcrumbsController.tsx +31 -0
  152. package/src/hooks/useBuildModeController.tsx +15 -28
  153. package/src/hooks/useBuildNavigationController.tsx +81 -24
  154. package/src/hooks/useFireCMSContext.tsx +0 -30
  155. package/src/hooks/useLargeLayout.tsx +0 -35
  156. package/src/hooks/useModeController.tsx +1 -2
  157. package/src/hooks/useResolvedNavigationFrom.tsx +4 -6
  158. package/src/internal/useBuildDataSource.ts +9 -5
  159. package/src/internal/useBuildSideDialogsController.tsx +3 -2
  160. package/src/internal/useBuildSideEntityController.tsx +135 -88
  161. package/src/internal/useUnsavedChangesDialog.tsx +126 -92
  162. package/src/preview/PropertyPreview.tsx +12 -10
  163. package/src/preview/components/UrlComponentPreview.tsx +17 -18
  164. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  165. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  166. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  167. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  168. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  169. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  170. package/src/preview/property_previews/MapPropertyPreview.tsx +3 -2
  171. package/src/routes/CustomCMSRoute.tsx +21 -0
  172. package/src/routes/FireCMSRoute.tsx +246 -0
  173. package/src/routes/HomePageRoute.tsx +17 -0
  174. package/src/types/collections.ts +45 -13
  175. package/src/types/datasource.ts +2 -1
  176. package/src/types/dialogs_controller.tsx +7 -3
  177. package/src/types/entities.ts +1 -1
  178. package/src/types/entity_actions.tsx +12 -0
  179. package/src/types/fields.tsx +18 -3
  180. package/src/types/firecms.tsx +1 -1
  181. package/src/types/navigation.ts +41 -16
  182. package/src/types/plugins.tsx +2 -0
  183. package/src/types/properties.ts +48 -4
  184. package/src/types/side_dialogs_controller.tsx +2 -0
  185. package/src/types/side_entity_controller.tsx +11 -1
  186. package/src/util/builders.ts +5 -3
  187. package/src/util/createFormexStub.tsx +62 -0
  188. package/src/util/entity_actions.ts +28 -0
  189. package/src/util/entity_cache.ts +204 -0
  190. package/src/util/index.ts +1 -0
  191. package/src/util/join_collections.ts +6 -1
  192. package/src/util/navigation_from_path.ts +18 -7
  193. package/src/util/navigation_utils.ts +115 -14
  194. package/src/util/objects.ts +9 -2
  195. package/src/util/parent_references_from_path.ts +3 -3
  196. package/src/util/property_utils.tsx +7 -3
  197. package/src/util/references.ts +8 -6
  198. package/src/util/resolutions.ts +41 -12
  199. package/src/util/useStorageUploadController.tsx +60 -23
  200. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
  201. /package/src/util/{common.tsx → common.ts} +0 -0
@@ -9,6 +9,7 @@ import {
9
9
  EntityCollection,
10
10
  EntityCollectionsBuilder,
11
11
  EntityReference,
12
+ NavigationBlocker,
12
13
  NavigationController,
13
14
  PermissionsBuilder,
14
15
  TopNavigationEntry,
@@ -26,6 +27,7 @@ import {
26
27
  resolvePermissions
27
28
  } from "../util";
28
29
  import { getParentReferencesFromPath } from "../util/parent_references_from_path";
30
+ import { useBlocker, useNavigate } from "react-router-dom";
29
31
 
30
32
  const DEFAULT_BASE_PATH = "/";
31
33
  const DEFAULT_COLLECTION_PATH = "/c";
@@ -49,6 +51,11 @@ export type BuildNavigationContextProps<EC extends EntityCollection, USER extend
49
51
  * @param collections
50
52
  */
51
53
  injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
54
+
55
+ /**
56
+ * If true, the navigation logic will not be updated until this flag is false
57
+ */
58
+ disabled?: boolean;
52
59
  };
53
60
 
54
61
  export function useBuildNavigationController<EC extends EntityCollection, USER extends User>(props: BuildNavigationContextProps<EC, USER>): NavigationController {
@@ -63,9 +70,12 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
63
70
  viewsOrder,
64
71
  userConfigPersistence,
65
72
  dataSourceDelegate,
66
- injectCollections
73
+ injectCollections,
74
+ disabled
67
75
  } = props;
68
76
 
77
+ const navigate = useNavigate();
78
+
69
79
  const collectionsRef = useRef<EntityCollection[] | undefined>();
70
80
  const viewsRef = useRef<CMSView[] | undefined>();
71
81
  const adminViewsRef = useRef<CMSView[] | undefined>();
@@ -185,7 +195,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
185
195
 
186
196
  const refreshNavigation = useCallback(async () => {
187
197
 
188
- if (authController.initialLoading)
198
+ if (disabled || authController.initialLoading)
189
199
  return;
190
200
 
191
201
  console.debug("Refreshing navigation");
@@ -202,7 +212,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
202
212
  let shouldUpdateTopLevelNav = false;
203
213
  if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
204
214
  collectionsRef.current = resolvedCollections;
205
- console.log("Collections have changed", resolvedCollections);
215
+ console.debug("Collections have changed", resolvedCollections);
206
216
  shouldUpdateTopLevelNav = true;
207
217
  }
208
218
  if (collectionsRef.current === undefined) {
@@ -237,6 +247,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
237
247
  collectionPermissions,
238
248
  authController.user,
239
249
  authController.initialLoading,
250
+ disabled,
240
251
  viewsProp,
241
252
  adminViewsProp,
242
253
  computeTopNavigation,
@@ -280,6 +291,16 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
280
291
 
281
292
  }, [userConfigPersistence]);
282
293
 
294
+ const getCollectionById = useCallback((id: string): EC | undefined => {
295
+ const collections = collectionsRef.current;
296
+ if (collections === undefined)
297
+ throw Error("getCollectionById: Collections have not been initialised yet");
298
+ const collection: EntityCollection | undefined = collections.find(c => c.id === id);
299
+ if (!collection)
300
+ return undefined;
301
+ return collection as EC;
302
+ }, []);
303
+
283
304
  const getCollectionFromPaths = useCallback(<EC extends EntityCollection>(pathSegments: string[]): EC | undefined => {
284
305
 
285
306
  const collections = collectionsRef.current;
@@ -332,16 +353,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
332
353
  throw Error("Expected path starting with " + fullCollectionPath);
333
354
  }, [fullCollectionPath]);
334
355
 
335
- const buildUrlEditCollectionPath = useCallback(({
336
- path
337
- }: {
338
- path: string
339
- }): string => {
340
- return `s/edit/${encodePath(path)}`;
341
- },
342
- []);
343
-
344
- const resolveAliasesFrom = useCallback((path: string): string => {
356
+ const resolveIdsFrom = useCallback((path: string): string => {
345
357
  const collections = collectionsRef.current ?? [];
346
358
  return resolveCollectionPathIds(path, collections);
347
359
  }, []);
@@ -396,29 +408,22 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
396
408
  baseCollectionPath,
397
409
  initialised,
398
410
  getCollection,
411
+ getCollectionById,
399
412
  getCollectionFromPaths,
400
413
  getCollectionFromIds,
401
414
  isUrlCollectionPath,
402
415
  urlPathToDataPath,
403
416
  buildUrlCollectionPath,
404
- buildUrlEditCollectionPath,
405
- buildCMSUrlPath,
406
- resolveAliasesFrom,
417
+ resolveIdsFrom,
407
418
  topLevelNavigation,
408
419
  refreshNavigation,
409
420
  getParentReferencesFromPath: getAllParentReferencesForPath,
410
421
  getParentCollectionIds,
411
- convertIdsToPaths
422
+ convertIdsToPaths,
423
+ navigate,
412
424
  };
413
425
  }
414
426
 
415
- export function getSidePanelKey(path: string, entityId?: string) {
416
- if (entityId)
417
- return `${removeInitialAndTrailingSlashes(path)}/${removeInitialAndTrailingSlashes(entityId)}`;
418
- else
419
- return removeInitialAndTrailingSlashes(path);
420
- }
421
-
422
427
  function encodePath(input: string) {
423
428
  return encodeURIComponent(removeInitialAndTrailingSlashes(input))
424
429
  .replaceAll("%2F", "/")
@@ -427,6 +432,7 @@ function encodePath(input: string) {
427
432
 
428
433
  function filterOutNotAllowedCollections(resolvedCollections: EntityCollection[], authController: AuthController<User>): EntityCollection[] {
429
434
  return resolvedCollections
435
+ .filter((c) => Boolean(c.path))
430
436
  .filter((c) => {
431
437
  if (!c.permissions) return true;
432
438
  const resolvedPermissions = resolvePermissions(c, authController, c.path, null);
@@ -513,3 +519,54 @@ function areCollectionsEqual(a: EntityCollection, b: EntityCollection) {
513
519
  }
514
520
  return equal(removeFunctions(restA), removeFunctions(restB));
515
521
  }
522
+
523
+ function useCustomBlocker(): NavigationBlocker {
524
+ const [blockListeners, setBlockListeners] = useState<Record<string, {
525
+ block: boolean,
526
+ basePath?: string
527
+ }>>({});
528
+
529
+ const shouldBlock = Object.values(blockListeners).some(b => b.block);
530
+
531
+ let blocker: any;
532
+ try {
533
+ blocker = useBlocker(({
534
+ nextLocation
535
+ }) => {
536
+ const allBasePaths = Object.values(blockListeners).map(b => b.basePath).filter(Boolean) as string[];
537
+ if (allBasePaths && allBasePaths.some(path => nextLocation.pathname.startsWith(path)))
538
+ return false;
539
+ return shouldBlock;
540
+ });
541
+ } catch (e) {
542
+ // console.warn("Blocker not available, navigation will not be blocked");
543
+ }
544
+
545
+ const updateBlockListener = (path: string, block: boolean, basePath?: string) => {
546
+ setBlockListeners(prev => ({
547
+ ...prev,
548
+ [path]: {
549
+ block,
550
+ basePath
551
+ }
552
+ }));
553
+ return () => setBlockListeners(prev => {
554
+ const {
555
+ [path]: removed,
556
+ ...rest
557
+ } = prev;
558
+ return rest;
559
+ })
560
+ };
561
+
562
+ const isBlocked = (path: string) => {
563
+ return (blockListeners[path]?.block ?? false) && blocker?.state === "blocked";
564
+ }
565
+
566
+ return {
567
+ updateBlockListener,
568
+ isBlocked,
569
+ proceed: blocker?.proceed,
570
+ reset: blocker?.reset
571
+ }
572
+ }
@@ -67,33 +67,3 @@ export const useFireCMSContext = <USER extends User = User, AuthControllerType e
67
67
 
68
68
  return fireCMSContextRef.current;
69
69
  }
70
-
71
- // export const useFireCMSContext = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): FireCMSContext<USER, AuthControllerType> => {
72
- //
73
- // const authController = useAuthController<USER, AuthControllerType>();
74
- // const sideDialogsController = useSideDialogsController();
75
- // const sideEntityController = useSideEntityController();
76
- // const navigation = useNavigationController();
77
- // const dataSource = useDataSource();
78
- // const storageSource = useStorageSource();
79
- // const snackbarController = useSnackbarController();
80
- // const userConfigPersistence = useUserConfigurationPersistence();
81
- // const dialogsController = useDialogsController();
82
- // const customizationController = useCustomizationController();
83
- // const analyticsController = useAnalyticsController();
84
- //
85
- // return {
86
- // authController,
87
- // sideDialogsController,
88
- // sideEntityController,
89
- // navigation,
90
- // dataSource,
91
- // storageSource,
92
- // snackbarController,
93
- // userConfigPersistence,
94
- // dialogsController,
95
- // customizationController,
96
- // analyticsController
97
- // };
98
- //
99
- // };
@@ -63,38 +63,3 @@ function checkLargeLayout(breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" |
63
63
  return false;
64
64
  return window.matchMedia(`(min-width: ${breakpoints[breakpoint] + 1}px)`).matches;
65
65
  }
66
-
67
- // import { useEffect, useState } from "react";
68
- //
69
- // const breakpoints = {
70
- // xs: 0,
71
- // sm: 640,
72
- // md: 768,
73
- // lg: 1024,
74
- // xl: 1280,
75
- // "2xl": 1536,
76
- // "3xl": 1920
77
- // }
78
- // export const useLargeLayout = (breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" = "lg"): boolean => {
79
- // const [isLargeLayout, setIsLargeLayout] = useState<boolean>(false);
80
- //
81
- // useEffect(() => {
82
- // const handleResize = () => {
83
- // const matched = window.matchMedia(`(min-width: ${breakpoints[breakpoint] + 1}px)`).matches;
84
- // setIsLargeLayout(matched);
85
- // };
86
- //
87
- // // Set initial state
88
- // handleResize();
89
- //
90
- // // Set up event listener for resize events
91
- // window.addEventListener("resize", handleResize);
92
- //
93
- // // Clean up event listener when component unmounts
94
- // return () => {
95
- // window.removeEventListener("resize", handleResize);
96
- // };
97
- // }, []);
98
- //
99
- // return isLargeLayout;
100
- // };
@@ -7,8 +7,7 @@ import { useContext } from "react";
7
7
  */
8
8
  export interface ModeController {
9
9
  mode: "light" | "dark";
10
- setMode: (mode: "light" | "dark") => void;
11
- toggleMode: () => void;
10
+ setMode: (mode: "light" | "dark" | "system") => void;
12
11
  }
13
12
 
14
13
  /**
@@ -1,6 +1,6 @@
1
1
  import { Entity, EntityCollection, EntityCustomView, FireCMSContext, User } from "../types";
2
2
  import { useEffect, useState } from "react";
3
- import { getNavigationEntriesFromPathInternal } from "../util/navigation_from_path";
3
+ import { getNavigationEntriesFromPath } from "../util/navigation_from_path";
4
4
  import { useFireCMSContext } from "./useFireCMSContext";
5
5
 
6
6
  /**
@@ -67,10 +67,10 @@ export function resolveNavigationFrom<M extends Record<string, any>, USER extend
67
67
  const navigation = context.navigation;
68
68
 
69
69
  if (!navigation) {
70
- throw Error("Calling getNavigationFrom, but main navigation has not yet been initialised");
70
+ throw Error("Calling resolveNavigationFrom, but main navigation has not yet been initialised");
71
71
  }
72
72
 
73
- const navigationEntries = getNavigationEntriesFromPathInternal({
73
+ const navigationEntries = getNavigationEntriesFromPath({
74
74
  path,
75
75
  collections: navigation.collections ?? []
76
76
  });
@@ -143,9 +143,7 @@ export function useResolvedNavigationFrom<M extends Record<string, any>, USER ex
143
143
  setDataLoading(true);
144
144
  setDataLoadingError(undefined);
145
145
  resolveNavigationFrom<M, USER>({ path, context })
146
- .then((res) => {
147
- setData(res);
148
- })
146
+ .then(setData)
149
147
  .catch((e) => setDataLoadingError(e))
150
148
  .finally(() => setDataLoading(false));
151
149
  }
@@ -1,5 +1,6 @@
1
1
  import { useCallback } from "react";
2
2
  import {
3
+ AuthController,
3
4
  DataSource,
4
5
  DataSourceDelegate,
5
6
  DeleteEntityProps,
@@ -27,11 +28,13 @@ import { resolveCollection, updateDateAutoValues } from "../util";
27
28
  export function useBuildDataSource({
28
29
  delegate,
29
30
  propertyConfigs,
30
- navigationController
31
+ navigationController,
32
+ authController
31
33
  }: {
32
34
  delegate: DataSourceDelegate,
33
35
  propertyConfigs?: Record<string, PropertyConfig>;
34
36
  navigationController: NavigationController;
37
+ authController: AuthController;
35
38
  }): DataSource {
36
39
 
37
40
  return {
@@ -209,26 +212,27 @@ export function useBuildDataSource({
209
212
  collection,
210
213
  path,
211
214
  entityId,
212
- propertyConfigs: propertyConfigs
215
+ propertyConfigs: propertyConfigs,
216
+ authController
213
217
  })
214
218
  : undefined;
215
219
 
216
220
  const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
217
221
 
218
- const firestoreValues = usedDelegate.cmsToDelegateModel(
222
+ const delegateValues = usedDelegate.cmsToDelegateModel(
219
223
  values,
220
224
  );
221
225
 
222
226
  const updatedValues: EntityValues<M> = properties
223
227
  ? updateDateAutoValues(
224
228
  {
225
- inputValues: firestoreValues,
229
+ inputValues: delegateValues,
226
230
  properties,
227
231
  status,
228
232
  timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
229
233
  setDateToMidnight: usedDelegate.setDateToMidnight
230
234
  })
231
- : firestoreValues;
235
+ : delegateValues;
232
236
 
233
237
  return usedDelegate.saveEntity({
234
238
  path,
@@ -25,8 +25,9 @@ export function useBuildSideDialogsController(): SideDialogsController {
25
25
  const newPanels = panelKeys
26
26
  .map(key => routesStore.current[key])
27
27
  .filter(p => Boolean(p)) as SideDialogPanelProps[];
28
- if (!equal(sidePanelsRef.current.map(p => p.key), newPanels.map(p => p.key)))
28
+ if (!equal(sidePanelsRef.current.map(p => p.key), newPanels.map(p => p.key))) {
29
29
  updateSidePanels(newPanels);
30
+ }
30
31
  }, [location]);
31
32
 
32
33
  const close = useCallback(() => {
@@ -39,7 +40,7 @@ export function useBuildSideDialogsController(): SideDialogsController {
39
40
  updateSidePanels(updatedPanels);
40
41
 
41
42
  if (routesCount.current > 0) {
42
- if (lastSidePanel.urlPath)
43
+ if (lastSidePanel.urlPath) // if it has a url path, we need to navigate back, don't remove this code
43
44
  navigate(-1);
44
45
  routesCount.current--;
45
46
  } else if (lastSidePanel.parentUrlPath) {