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

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 (71) hide show
  1. package/dist/components/ArrayContainer.d.ts +7 -12
  2. package/dist/components/EntityPreview.d.ts +4 -2
  3. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  4. package/dist/components/VirtualTable/VirtualTableProps.d.ts +0 -4
  5. package/dist/components/index.d.ts +1 -0
  6. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  7. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -9
  8. package/dist/hooks/useBuildNavigationController.d.ts +2 -9
  9. package/dist/index.es.js +1183 -705
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +1191 -716
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/collections.d.ts +20 -2
  14. package/dist/types/firecms.d.ts +2 -1
  15. package/dist/types/navigation.d.ts +5 -0
  16. package/dist/types/plugins.d.ts +12 -0
  17. package/dist/types/side_entity_controller.d.ts +4 -0
  18. package/dist/util/callbacks.d.ts +2 -0
  19. package/dist/util/index.d.ts +1 -0
  20. package/package.json +8 -6
  21. package/src/components/ArrayContainer.tsx +409 -294
  22. package/src/components/ClearFilterSortButton.tsx +1 -1
  23. package/src/components/ConfirmationDialog.tsx +9 -9
  24. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +1 -1
  25. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +1 -1
  26. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +13 -2
  27. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +53 -27
  28. package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +9 -9
  29. package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -0
  30. package/src/components/EntityPreview.tsx +18 -14
  31. package/src/components/ErrorView.tsx +1 -1
  32. package/src/components/HomePage/DefaultHomePage.tsx +2 -1
  33. package/src/components/HomePage/NavigationCardBinding.tsx +3 -1
  34. package/src/components/SelectableTable/SelectableTable.tsx +140 -143
  35. package/src/components/VirtualTable/VirtualTable.tsx +8 -30
  36. package/src/components/VirtualTable/VirtualTableProps.tsx +0 -5
  37. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +0 -1
  38. package/src/components/index.tsx +2 -0
  39. package/src/core/EntityEditView.tsx +26 -14
  40. package/src/core/EntitySidePanel.tsx +15 -20
  41. package/src/core/FireCMS.tsx +7 -1
  42. package/src/form/EntityForm.tsx +1 -1
  43. package/src/form/PropertyFieldBinding.tsx +0 -1
  44. package/src/form/components/CustomIdField.tsx +3 -1
  45. package/src/form/components/LabelWithIcon.tsx +1 -1
  46. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +3 -2
  47. package/src/form/field_bindings/MapFieldBinding.tsx +5 -4
  48. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +1 -1
  49. package/src/form/field_bindings/RepeatFieldBinding.tsx +1 -0
  50. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -1
  51. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +222 -154
  52. package/src/hooks/data/save.ts +0 -6
  53. package/src/hooks/useBuildNavigationController.tsx +30 -16
  54. package/src/internal/useBuildSideEntityController.tsx +1 -1
  55. package/src/preview/components/ImagePreview.tsx +2 -2
  56. package/src/preview/components/ReferencePreview.tsx +1 -1
  57. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  58. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  59. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +1 -1
  60. package/src/preview/property_previews/StringPropertyPreview.tsx +1 -1
  61. package/src/types/collections.ts +24 -2
  62. package/src/types/firecms.tsx +2 -2
  63. package/src/types/navigation.ts +6 -0
  64. package/src/types/plugins.tsx +16 -0
  65. package/src/types/side_entity_controller.tsx +5 -5
  66. package/src/util/callbacks.ts +119 -0
  67. package/src/util/index.ts +1 -0
  68. package/src/util/navigation_utils.ts +70 -55
  69. package/src/util/objects.ts +53 -20
  70. package/dist/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.d.ts +0 -5
  71. package/src/components/EntityCollectionTable/internal/popup_field/ElementResizeListener.tsx +0 -59
@@ -12,32 +12,65 @@ export function isObject(item: any) {
12
12
  return item && typeof item === "object" && !Array.isArray(item);
13
13
  }
14
14
 
15
- export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U, ignoreUndefined: boolean = false): T & U {
16
- const targetIsObject = isObject(target);
17
- const output = targetIsObject ? { ...target } : target;
18
- if (targetIsObject && isObject(source)) {
19
- Object.keys(source).forEach(key => {
20
- const sourceElement = source[key];
21
- // Skip undefined values when ignoreUndefined is true
22
- if (ignoreUndefined && sourceElement === undefined) {
23
- return;
15
+ export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(
16
+ target: T,
17
+ source: U,
18
+ ignoreUndefined: boolean = false
19
+ ): T & U {
20
+ // If target is not a true object (e.g., null, array, primitive), return target itself.
21
+ if (!isObject(target)) {
22
+ return target as T & U;
23
+ }
24
+
25
+ // Create a shallow copy of the target to avoid modifying the original object.
26
+ const output = { ...target };
27
+
28
+ // If source is not a true object, there's nothing to merge from it.
29
+ // Return the shallow copy of target.
30
+ if (!isObject(source)) {
31
+ return output as T & U;
32
+ }
33
+
34
+ // Iterate over keys in the source object.
35
+ for (const key in source) {
36
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
37
+ const sourceValue = source[key];
38
+ const outputValue = (output as any)[key]; // Current value in our merged object (originating from target)
39
+
40
+ // Skip if source value is undefined and ignoreUndefined is true.
41
+ // This handles both not adding new undefined properties and not overwriting existing properties with undefined.
42
+ if (ignoreUndefined && sourceValue === undefined) {
43
+ continue;
24
44
  }
25
- if (sourceElement instanceof Date) {
26
- // Assign a new Date instance with the same time value
27
- Object.assign(output, { [key]: new Date(sourceElement.getTime()) });
28
- } else if (isObject(sourceElement)) {
29
- if (!(key in target))
30
- Object.assign(output, { [key]: sourceElement });
31
- else
32
- (output as any)[key] = mergeDeep((target as any)[key], sourceElement);
45
+
46
+ if ((sourceValue as any) instanceof Date) {
47
+ // If source value is a Date, create a new Date instance.
48
+ (output as any)[key] = new Date(sourceValue.getTime());
49
+ } else if (Array.isArray(sourceValue)) {
50
+ // If source value is an array, create a shallow copy of the array.
51
+ (output as any)[key] = [...sourceValue];
52
+ } else if (isObject(sourceValue)) {
53
+ // If source value is an object:
54
+ if (isObject(outputValue)) {
55
+ // If the corresponding value in output (from target) is also an object, recurse.
56
+ // Ensure the ignoreUndefined flag is passed down.
57
+ (output as any)[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
58
+ } else {
59
+ // If output's value (from target) is not an object (e.g., null, primitive, or key didn't exist in original target),
60
+ // overwrite with the source object.
61
+ (output as any)[key] = sourceValue;
62
+ }
33
63
  } else {
34
- Object.assign(output, { [key]: sourceElement });
64
+ // If source value is a primitive, null, or undefined (and not ignored).
65
+ (output as any)[key] = sourceValue;
35
66
  }
36
- });
67
+ }
37
68
  }
38
- return output as T;
69
+
70
+ return output as T & U;
39
71
  }
40
72
 
73
+
41
74
  export function getValueInPath(o: object | undefined, path: string): any {
42
75
  if (!o) return undefined;
43
76
  if (typeof o === "object") {
@@ -1,5 +0,0 @@
1
- interface Props {
2
- onResize: (event: Event) => void;
3
- }
4
- export declare const ElementResizeListener: React.FC<Props>;
5
- export {};
@@ -1,59 +0,0 @@
1
- import { RefObject, useCallback, useEffect, useRef } from "react";
2
-
3
- interface Props {
4
- onResize: (event: Event) => void;
5
- }
6
-
7
- export const ElementResizeListener: React.FC<Props> = ({ onResize }) => {
8
- const rafRef = useRef(0);
9
- const objectRef: RefObject<HTMLObjectElement> = useRef(null);
10
- const onResizeRef = useRef(onResize);
11
-
12
- onResizeRef.current = onResize;
13
-
14
- const _onResize = useCallback((e: Event) => {
15
- if (rafRef.current) {
16
- cancelAnimationFrame(rafRef.current);
17
- }
18
- rafRef.current = requestAnimationFrame(() => {
19
- onResizeRef.current(e);
20
- });
21
- }, []);
22
-
23
- const onLoad = useCallback(() => {
24
- const obj = objectRef.current;
25
- if (obj && obj.contentDocument && obj.contentDocument.defaultView) {
26
- obj.contentDocument.defaultView.addEventListener("resize", _onResize);
27
- }
28
- }, [_onResize]);
29
-
30
- useEffect(() => {
31
- const obj = objectRef.current;
32
- return () => {
33
- if (obj && obj.contentDocument && obj.contentDocument.defaultView) {
34
- obj.contentDocument.defaultView.removeEventListener("resize", _onResize);
35
- }
36
- };
37
- }, [_onResize]);
38
-
39
- return (
40
- <object
41
- onLoad={onLoad}
42
- ref={objectRef}
43
- tabIndex={-1}
44
- type={"text/html"}
45
- data={"about:blank"}
46
- title={""}
47
- style={{
48
- position: "absolute",
49
- top: 0,
50
- left: 0,
51
- height: "100%",
52
- width: "100%",
53
- pointerEvents: "none",
54
- zIndex: -1,
55
- opacity: 0
56
- }}
57
- />
58
- );
59
- };