@firecms/core 3.0.0-canary.55 → 3.0.0-canary.57

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.
@@ -99,7 +99,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
99
99
  * `hidden` in the property definition,will be ignored.
100
100
  * `propertiesOrder` has precedence over `hidden`.
101
101
  */
102
- propertiesOrder?: Extract<keyof M, string>[];
102
+ propertiesOrder?: (Extract<keyof M, string> | `subcollection:${string}`)[];
103
103
  /**
104
104
  * If enabled, content is loaded in batches. If `false` all entities in the
105
105
  * collection are loaded.
@@ -1,6 +1,6 @@
1
1
  export declare const pick: <T>(obj: T, ...args: any[]) => T;
2
2
  export declare function isObject(item: any): any;
3
- export declare function mergeDeep<T extends object>(target: T, source: any): T;
3
+ export declare function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U): T & U;
4
4
  export declare function getValueInPath(o: object | undefined, path: string): any;
5
5
  export declare function removeInPath(o: object, path: string): object | undefined;
6
6
  export declare function removeFunctions(o: object | undefined): any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.55",
4
+ "version": "3.0.0-canary.57",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,8 +46,8 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-canary.55",
50
- "@firecms/ui": "^3.0.0-canary.55",
49
+ "@firecms/formex": "^3.0.0-canary.57",
50
+ "@firecms/ui": "^3.0.0-canary.57",
51
51
  "@fontsource/jetbrains-mono": "^5.0.20",
52
52
  "@hello-pangea/dnd": "^16.6.0",
53
53
  "@radix-ui/react-portal": "^1.0.4",
@@ -111,7 +111,7 @@
111
111
  "dist",
112
112
  "src"
113
113
  ],
114
- "gitHead": "504f907bf8ecf1b7ed81fa1f84d3461c06efb39a",
114
+ "gitHead": "54c0d79d2648c937d055bacab2d7d92fbd294c7b",
115
115
  "publishConfig": {
116
116
  "access": "public"
117
117
  },
@@ -19,7 +19,7 @@ import { User } from "../types";
19
19
 
20
20
  export type FireCMSAppBarProps<ADDITIONAL_PROPS = object> = {
21
21
 
22
- title: React.ReactNode;
22
+ title?: React.ReactNode;
23
23
  /**
24
24
  * A component that gets rendered on the upper side of the main toolbar
25
25
  */
@@ -48,7 +48,7 @@ export function SearchIconsView({
48
48
  return (
49
49
  <>
50
50
  <SearchBar
51
- autoFocus
51
+ autoFocus={false}
52
52
  innerClassName={"w-full sticky top-0 z-10"}
53
53
  onTextSearch={(value?: string) => setQuery(value ?? "")}
54
54
  placeholder="Search for more icons…"
@@ -33,7 +33,7 @@ export interface ScaffoldProps<ExtraAppbarProps = object> {
33
33
  /**
34
34
  * Name of the app, displayed as the main title and in the tab title
35
35
  */
36
- name: React.ReactNode;
36
+ name?: React.ReactNode;
37
37
 
38
38
  /**
39
39
  * Logo to be displayed in the drawer of the CMS
@@ -57,8 +57,7 @@ export interface ScaffoldProps<ExtraAppbarProps = object> {
57
57
  autoOpenDrawer?: boolean;
58
58
 
59
59
  /**
60
- * A component that gets rendered on the upper side of the main toolbar.
61
- * `toolbarExtraWidget` has no effect if this is set.
60
+ * The AppBar component to be used in the scaffold.
62
61
  */
63
62
  FireCMSAppBar?: React.ComponentType<FireCMSAppBarProps<ExtraAppbarProps>>;
64
63
 
@@ -331,7 +331,7 @@ export function getFieldConfig(property: Property | ResolvedProperty, propertyCo
331
331
  }
332
332
  const defaultFieldConfig = DEFAULT_FIELD_CONFIGS[defaultFieldId];
333
333
  const customField = fieldId ? propertyConfigs[fieldId] : undefined;
334
- return mergeDeep(defaultFieldConfig ?? {}, customField ?? {});
334
+ return mergeDeep(defaultFieldConfig ?? {}, customField ?? {} as PropertyConfig);
335
335
  }
336
336
 
337
337
  export function getDefaultFieldId(property: Property | ResolvedProperty) {
@@ -22,10 +22,9 @@ export function useBuildLocalConfigurationPersistence(): UserConfigurationPersis
22
22
  const onCollectionModified = useCallback(<M extends Record<string, any>>(path: string, data: PartialEntityCollection<M>) => {
23
23
  const storageKey = `collection_config::${stripCollectionPath(path)}`;
24
24
  localStorage.setItem(storageKey, JSON.stringify(data));
25
- const currentCache = configCache.current;
26
- const cachedConfig = currentCache[storageKey];
25
+ const cachedConfig = configCache.current[storageKey];
27
26
  const newConfig = mergeDeep(cachedConfig ?? getCollectionFromStorage(path), data);
28
- configCache.current = mergeDeep(currentCache, newConfig);
27
+ configCache.current[storageKey] = mergeDeep(configCache.current[storageKey], newConfig);
29
28
  }, [getCollectionFromStorage]);
30
29
 
31
30
  const [recentlyVisitedPaths, _setRecentlyVisitedPaths] = useState<string[]>([]);
@@ -250,7 +250,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
250
250
  const baseCollection = getCollectionByPathOrId(removeInitialAndTrailingSlashes(idOrPath), collections);
251
251
 
252
252
  const userOverride = includeUserOverride ? userConfigPersistence?.getCollectionConfig(idOrPath) : undefined;
253
- const overriddenCollection = baseCollection ? mergeDeep(baseCollection, userOverride) : undefined;
253
+ const overriddenCollection = baseCollection ? mergeDeep(baseCollection, userOverride ?? {}) : undefined;
254
254
 
255
255
  let result: Partial<EntityCollection> | undefined = overriddenCollection;
256
256
 
@@ -112,7 +112,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
112
112
  * `hidden` in the property definition,will be ignored.
113
113
  * `propertiesOrder` has precedence over `hidden`.
114
114
  */
115
- propertiesOrder?: Extract<keyof M, string>[];
115
+ propertiesOrder?: (Extract<keyof M, string> | `subcollection:${string}`)[];
116
116
 
117
117
  /**
118
118
  * If enabled, content is loaded in batches. If `false` all entities in the
@@ -464,7 +464,10 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
464
464
  * view.
465
465
  * @param entity
466
466
  */
467
- value?: (props: { entity: Entity<M>, context: FireCMSContext<any> }) => string | number | Promise<string | number> | undefined;
467
+ value?: (props: {
468
+ entity: Entity<M>,
469
+ context: FireCMSContext<any>
470
+ }) => string | number | Promise<string | number> | undefined;
468
471
  }
469
472
 
470
473
  /**
@@ -12,22 +12,23 @@ 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 object>(target: T, source: any): T {
15
+ export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U): T & U {
16
16
  const targetIsObject = isObject(target);
17
- const output: T = targetIsObject ? { ...target } : target;
17
+ const output = targetIsObject ? { ...target } : target;
18
18
  if (targetIsObject && isObject(source)) {
19
19
  Object.keys(source).forEach(key => {
20
- if (isObject(source[key])) {
20
+ const sourceElement = source[key];
21
+ if (isObject(sourceElement)) {
21
22
  if (!(key in target))
22
- Object.assign(output, { [key]: source[key] });
23
+ Object.assign(output, { [key]: sourceElement });
23
24
  else
24
- (output as any)[key] = mergeDeep((target as any)[key], source[key]);
25
+ (output as any)[key] = mergeDeep((target as any)[key], sourceElement);
25
26
  } else {
26
- Object.assign(output, { [key]: source[key] });
27
+ Object.assign(output, { [key]: sourceElement });
27
28
  }
28
29
  });
29
30
  }
30
- return output;
31
+ return output as T;
31
32
  }
32
33
 
33
34
  export function getValueInPath(o: object | undefined, path: string): any {