@firecms/core 3.5.1 → 3.5.2-canary.09e1281

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 (56) hide show
  1. package/dist/components/EntityCollectionView/CollectionCountBadge.d.ts +8 -0
  2. package/dist/components/EntityCollectionView/CollectionPathTitle.d.ts +24 -0
  3. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +5 -0
  4. package/dist/components/EntityCollectionView/EntityIdHeaderWidget.d.ts +12 -0
  5. package/dist/components/EntityCollectionView/utils.d.ts +3 -3
  6. package/dist/components/HomePage/HomePageDnD.d.ts +4 -2
  7. package/dist/{de-CBOjCvsy.js → de-CUF9f7S-.js} +2 -1
  8. package/dist/{de-CBOjCvsy.js.map → de-CUF9f7S-.js.map} +1 -1
  9. package/dist/{editor-BSo_aS1I.js → editor-WZytSO_1.js} +172 -137
  10. package/dist/editor-WZytSO_1.js.map +1 -0
  11. package/dist/{fr-DRfttcG0.js → fr-DmkMX6hp.js} +2 -1
  12. package/dist/{fr-DRfttcG0.js.map → fr-DmkMX6hp.js.map} +1 -1
  13. package/dist/{hi-DwieOZNf.js → hi-BKuaMr7w.js} +2 -1
  14. package/dist/{hi-DwieOZNf.js.map → hi-BKuaMr7w.js.map} +1 -1
  15. package/dist/index.es.js +787 -638
  16. package/dist/index.es.js.map +1 -1
  17. package/dist/index.umd.js +946 -756
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/internal/useLeavePageConfirmation.d.ts +11 -0
  20. package/dist/{it-l2KXtx9n.js → it-BwQflFGz.js} +2 -1
  21. package/dist/{it-l2KXtx9n.js.map → it-BwQflFGz.js.map} +1 -1
  22. package/dist/{pl-DPZrdKhi.js → pl-BPsAvZvc.js} +2 -1
  23. package/dist/{pl-DPZrdKhi.js.map → pl-BPsAvZvc.js.map} +1 -1
  24. package/dist/{pt-BoHpabw1.js → pt-D5q7OQp1.js} +2 -1
  25. package/dist/{pt-BoHpabw1.js.map → pt-D5q7OQp1.js.map} +1 -1
  26. package/dist/types/side_dialogs_controller.d.ts +4 -2
  27. package/dist/types/translations.d.ts +1 -0
  28. package/package.json +3 -3
  29. package/src/components/EntityCollectionView/CollectionCountBadge.tsx +17 -0
  30. package/src/components/EntityCollectionView/CollectionPathTitle.tsx +68 -0
  31. package/src/components/EntityCollectionView/EntityCollectionView.tsx +12 -111
  32. package/src/components/EntityCollectionView/EntityIdHeaderWidget.tsx +124 -0
  33. package/src/components/EntityCollectionView/utils.ts +7 -7
  34. package/src/components/HomePage/DefaultHomePage.tsx +2 -0
  35. package/src/components/HomePage/HomePageDnD.tsx +12 -4
  36. package/src/components/common/default_entity_actions.tsx +2 -1
  37. package/src/core/DefaultAppBar.tsx +12 -9
  38. package/src/core/EntityEditView.tsx +26 -1
  39. package/src/core/SideDialogs.tsx +6 -13
  40. package/src/editor/selectors/link-selector.tsx +37 -12
  41. package/src/hooks/useReferenceDialog.tsx +2 -2
  42. package/src/internal/useBuildSideDialogsController.tsx +44 -2
  43. package/src/internal/useLeavePageConfirmation.ts +25 -0
  44. package/src/locales/de.ts +1 -0
  45. package/src/locales/en.ts +1 -0
  46. package/src/locales/es.ts +1 -0
  47. package/src/locales/fr.ts +1 -0
  48. package/src/locales/hi.ts +1 -0
  49. package/src/locales/it.ts +1 -0
  50. package/src/locales/pl.ts +1 -0
  51. package/src/locales/pt.ts +1 -0
  52. package/src/types/side_dialogs_controller.tsx +4 -2
  53. package/src/types/translations.ts +1 -0
  54. package/dist/editor-BSo_aS1I.js.map +0 -1
  55. package/dist/internal/useUnsavedChangesDialog.d.ts +0 -12
  56. package/src/internal/useUnsavedChangesDialog.tsx +0 -142
@@ -1,12 +0,0 @@
1
- /**
2
- * Custom hook to handle navigation blocking when there are unsaved changes.
3
- *
4
- * @param when - Indicates whether to block navigation.
5
- * @param onSuccess - Callback invoked when navigation is confirmed.
6
- * @returns An object containing the state of navigation blocking and handlers.
7
- */
8
- export declare function useNavigationUnsavedChangesDialog(when: boolean, onSuccess: () => void): {
9
- navigationWasBlocked: boolean;
10
- handleCancel: () => void;
11
- handleOk: () => void;
12
- };
@@ -1,142 +0,0 @@
1
- import React, { useCallback, useEffect, useState } from "react";
2
- import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
3
-
4
- /**
5
- * Type representing a pending navigation action.
6
- */
7
- type PendingNavigation =
8
- | {
9
- type: "popstate";
10
- delta: number;
11
- }
12
- | {
13
- type: "link";
14
- href: string;
15
- }
16
- | null;
17
-
18
- /**
19
- * Custom hook to handle navigation blocking when there are unsaved changes.
20
- *
21
- * @param when - Indicates whether to block navigation.
22
- * @param onSuccess - Callback invoked when navigation is confirmed.
23
- * @returns An object containing the state of navigation blocking and handlers.
24
- */
25
- export function useNavigationUnsavedChangesDialog(
26
- when: boolean,
27
- onSuccess: () => void
28
- ): {
29
- navigationWasBlocked: boolean;
30
- handleCancel: () => void;
31
- handleOk: () => void;
32
- } {
33
- const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
34
- const [pendingNavigation, setPendingNavigation] = useState<PendingNavigation>(null);
35
-
36
- /**
37
- * Handler to cancel the navigation attempt.
38
- */
39
- const handleCancel = useCallback(() => {
40
- setIsDialogOpen(false);
41
- setPendingNavigation(null);
42
- }, []);
43
-
44
- /**
45
- * Handler to confirm and proceed with the navigation.
46
- */
47
- const handleOk = useCallback(() => {
48
- setIsDialogOpen(false);
49
- if (pendingNavigation) {
50
- onSuccess();
51
- if (pendingNavigation.type === "popstate") {
52
- window.history.go(pendingNavigation.delta);
53
- } else if (pendingNavigation.type === "link") {
54
- window.location.href = pendingNavigation.href;
55
- }
56
- setPendingNavigation(null);
57
- }
58
- }, [onSuccess, pendingNavigation]);
59
-
60
- /**
61
- * Event handler for beforeunload to handle page refresh or tab close.
62
- */
63
- const handleBeforeUnload = useCallback(
64
- (e: BeforeUnloadEvent) => {
65
- if (when) {
66
- e.preventDefault();
67
- e.returnValue = "";
68
- }
69
- },
70
- [when]
71
- );
72
-
73
- /**
74
- * Event handler for popstate to handle back and forward browser buttons.
75
- */
76
- const handlePopState = useCallback(
77
- (e: PopStateEvent) => {
78
- if (when) {
79
- e.preventDefault();
80
- // Assuming backward navigation; adjust delta as needed
81
- setPendingNavigation({
82
- type: "popstate",
83
- delta: -1
84
- });
85
- setIsDialogOpen(true);
86
- }
87
- },
88
- [when]
89
- );
90
-
91
- /**
92
- * Event handler to intercept link clicks within the application.
93
- */
94
- const handleLinkClick = useCallback(
95
- (e: MouseEvent) => {
96
- if (!when) return;
97
-
98
- const target = e.target as HTMLElement;
99
- const anchor = target.closest("a[href]") as HTMLAnchorElement | null;
100
- if (anchor && anchor.host === window.location.host) {
101
- e.preventDefault();
102
- const href = anchor.getAttribute("href");
103
- if (href) {
104
- setPendingNavigation({
105
- type: "link",
106
- href
107
- });
108
- setIsDialogOpen(true);
109
- }
110
- }
111
- },
112
- [when]
113
- );
114
-
115
- /**
116
- * Effect hook to add and clean up event listeners based on the `when` condition.
117
- */
118
- useEffect(() => {
119
- if (when) {
120
- window.addEventListener("beforeunload", handleBeforeUnload);
121
- window.addEventListener("popstate", handlePopState);
122
- document.addEventListener("click", handleLinkClick);
123
- } else {
124
- window.removeEventListener("beforeunload", handleBeforeUnload);
125
- window.removeEventListener("popstate", handlePopState);
126
- document.removeEventListener("click", handleLinkClick);
127
- }
128
-
129
- // Cleanup on unmount or when `when` changes
130
- return () => {
131
- window.removeEventListener("beforeunload", handleBeforeUnload);
132
- window.removeEventListener("popstate", handlePopState);
133
- document.removeEventListener("click", handleLinkClick);
134
- };
135
- }, [when, handleBeforeUnload, handlePopState, handleLinkClick]);
136
-
137
- return {
138
- navigationWasBlocked: isDialogOpen,
139
- handleCancel,
140
- handleOk,
141
- };
142
- }