@firecms/core 3.0.0-canary.6 → 3.0.0-canary.60

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 (242) hide show
  1. package/README.md +2 -2
  2. package/dist/components/ClearFilterSortButton.d.ts +5 -0
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  5. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
  6. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
  7. package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
  8. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
  9. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
  10. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  11. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  12. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
  13. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
  14. package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
  15. package/dist/components/EntityPreview.d.ts +26 -7
  16. package/dist/components/EntityView.d.ts +11 -0
  17. package/dist/components/FieldCaption.d.ts +5 -0
  18. package/dist/components/FireCMSAppBar.d.ts +4 -2
  19. package/dist/components/HomePage/NavigationCard.d.ts +8 -0
  20. package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
  21. package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
  22. package/dist/components/HomePage/index.d.ts +3 -1
  23. package/dist/components/ReferenceWidget.d.ts +3 -1
  24. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  25. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  26. package/dist/components/VirtualTable/VirtualTableProps.d.ts +6 -7
  27. package/dist/components/VirtualTable/types.d.ts +3 -3
  28. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  29. package/dist/components/common/index.d.ts +1 -0
  30. package/dist/components/common/table_height.d.ts +5 -0
  31. package/dist/components/common/types.d.ts +4 -6
  32. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  33. package/dist/components/index.d.ts +5 -2
  34. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  35. package/dist/core/Drawer.d.ts +5 -12
  36. package/dist/core/DrawerNavigationItem.d.ts +9 -0
  37. package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
  38. package/dist/core/NavigationRoutes.d.ts +1 -1
  39. package/dist/core/Scaffold.d.ts +8 -12
  40. package/dist/core/index.d.ts +3 -4
  41. package/dist/form/EntityForm.d.ts +1 -1
  42. package/dist/form/components/ErrorFocus.d.ts +1 -1
  43. package/dist/form/components/StorageItemPreview.d.ts +3 -2
  44. package/dist/form/components/StorageUploadProgress.d.ts +1 -1
  45. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  46. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  47. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -3
  48. package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
  49. package/dist/form/validation.d.ts +1 -1
  50. package/dist/hooks/data/delete.d.ts +2 -2
  51. package/dist/hooks/data/save.d.ts +2 -3
  52. package/dist/hooks/data/useDataSource.d.ts +2 -2
  53. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  54. package/dist/hooks/index.d.ts +2 -0
  55. package/dist/hooks/useBuildNavigationController.d.ts +6 -4
  56. package/dist/hooks/useProjectLog.d.ts +6 -2
  57. package/dist/hooks/useStorageSource.d.ts +2 -2
  58. package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
  59. package/dist/index.es.js +10496 -9945
  60. package/dist/index.es.js.map +1 -1
  61. package/dist/index.umd.js +5 -5
  62. package/dist/index.umd.js.map +1 -1
  63. package/dist/internal/useBuildDataSource.d.ts +1 -16
  64. package/dist/preview/PropertyPreview.d.ts +1 -1
  65. package/dist/preview/PropertyPreviewProps.d.ts +1 -4
  66. package/dist/preview/components/BooleanPreview.d.ts +5 -1
  67. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  68. package/dist/preview/components/ReferencePreview.d.ts +3 -8
  69. package/dist/types/analytics.d.ts +1 -1
  70. package/dist/types/auth.d.ts +37 -1
  71. package/dist/types/collections.d.ts +30 -6
  72. package/dist/types/datasource.d.ts +21 -14
  73. package/dist/types/entities.d.ts +5 -1
  74. package/dist/types/entity_actions.d.ts +14 -0
  75. package/dist/types/entity_callbacks.d.ts +2 -2
  76. package/dist/types/entity_overrides.d.ts +6 -0
  77. package/dist/types/index.d.ts +2 -1
  78. package/dist/types/navigation.d.ts +15 -14
  79. package/dist/types/permissions.d.ts +5 -1
  80. package/dist/types/plugins.d.ts +20 -20
  81. package/dist/types/properties.d.ts +12 -4
  82. package/dist/types/property_config.d.ts +2 -2
  83. package/dist/types/roles.d.ts +31 -0
  84. package/dist/types/storage.d.ts +11 -3
  85. package/dist/types/user.d.ts +5 -0
  86. package/dist/util/collections.d.ts +9 -1
  87. package/dist/util/entities.d.ts +1 -1
  88. package/dist/util/icon_synonyms.d.ts +1 -97
  89. package/dist/util/icons.d.ts +8 -2
  90. package/dist/util/navigation_utils.d.ts +2 -2
  91. package/dist/util/objects.d.ts +1 -1
  92. package/dist/util/permissions.d.ts +4 -4
  93. package/dist/util/references.d.ts +4 -2
  94. package/dist/util/resolutions.d.ts +14 -14
  95. package/dist/util/useTraceUpdate.d.ts +1 -0
  96. package/package.json +139 -119
  97. package/src/components/ClearFilterSortButton.tsx +41 -0
  98. package/src/components/DeleteEntityDialog.tsx +4 -4
  99. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -4
  100. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +276 -279
  101. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
  102. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +48 -45
  103. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  104. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +18 -17
  105. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -5
  106. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
  107. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
  108. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
  109. package/src/components/EntityCollectionView/EntityCollectionView.tsx +73 -72
  110. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
  111. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  112. package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
  113. package/src/components/EntityPreview.tsx +209 -70
  114. package/src/components/EntityView.tsx +84 -0
  115. package/src/components/FieldCaption.tsx +14 -0
  116. package/src/components/FireCMSAppBar.tsx +40 -15
  117. package/src/components/HomePage/DefaultHomePage.tsx +15 -11
  118. package/src/components/HomePage/NavigationCard.tsx +69 -0
  119. package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
  120. package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
  121. package/src/components/HomePage/index.tsx +3 -1
  122. package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
  123. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
  124. package/src/components/ReferenceWidget.tsx +22 -12
  125. package/src/components/SearchIconsView.tsx +5 -5
  126. package/src/components/SelectableTable/SelectableTable.tsx +5 -3
  127. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
  128. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
  129. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -24
  130. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  131. package/src/components/VirtualTable/VirtualTable.tsx +38 -29
  132. package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
  133. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
  134. package/src/components/VirtualTable/VirtualTableProps.tsx +7 -7
  135. package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
  136. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  137. package/src/components/VirtualTable/types.tsx +2 -3
  138. package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +11 -7
  139. package/src/components/common/index.ts +1 -0
  140. package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
  141. package/src/components/common/types.tsx +4 -6
  142. package/src/components/common/useColumnsIds.tsx +10 -2
  143. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
  144. package/src/components/common/useTableSearchHelper.ts +39 -9
  145. package/src/components/index.tsx +5 -2
  146. package/src/contexts/AuthControllerContext.tsx +1 -1
  147. package/src/core/Drawer.tsx +78 -103
  148. package/src/core/DrawerNavigationItem.tsx +62 -0
  149. package/src/core/{EntityView.tsx → EntityEditView.tsx} +27 -45
  150. package/src/core/EntitySidePanel.tsx +3 -3
  151. package/src/core/FireCMS.tsx +54 -43
  152. package/src/core/NavigationRoutes.tsx +11 -4
  153. package/src/core/Scaffold.tsx +80 -66
  154. package/src/core/field_configs.tsx +2 -3
  155. package/src/core/index.tsx +3 -4
  156. package/src/form/EntityForm.tsx +49 -33
  157. package/src/form/PropertyFieldBinding.tsx +0 -2
  158. package/src/form/components/StorageItemPreview.tsx +7 -5
  159. package/src/form/components/StorageUploadProgress.tsx +9 -8
  160. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +10 -12
  161. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
  162. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
  163. package/src/form/field_bindings/KeyValueFieldBinding.tsx +19 -19
  164. package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
  165. package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
  166. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +3 -3
  167. package/src/form/field_bindings/ReferenceFieldBinding.tsx +16 -13
  168. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
  169. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +18 -9
  170. package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
  171. package/src/form/validation.ts +3 -4
  172. package/src/hooks/data/delete.ts +3 -3
  173. package/src/hooks/data/save.ts +4 -2
  174. package/src/hooks/data/useCollectionFetch.tsx +1 -1
  175. package/src/hooks/data/useDataSource.tsx +8 -3
  176. package/src/hooks/data/useEntityFetch.tsx +4 -4
  177. package/src/hooks/index.tsx +3 -0
  178. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
  179. package/src/hooks/useBuildModeController.tsx +11 -5
  180. package/src/hooks/useBuildNavigationController.tsx +200 -83
  181. package/src/hooks/useProjectLog.tsx +17 -7
  182. package/src/hooks/useReferenceDialog.tsx +2 -2
  183. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  184. package/src/hooks/useStorageSource.tsx +7 -2
  185. package/src/hooks/useValidateAuthenticator.tsx +115 -0
  186. package/src/internal/useBuildDataSource.ts +54 -47
  187. package/src/internal/useBuildSideEntityController.tsx +88 -21
  188. package/src/preview/PropertyPreview.tsx +5 -15
  189. package/src/preview/PropertyPreviewProps.tsx +1 -11
  190. package/src/preview/components/BooleanPreview.tsx +19 -4
  191. package/src/preview/components/EnumValuesChip.tsx +2 -2
  192. package/src/preview/components/ReferencePreview.tsx +72 -165
  193. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  194. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
  195. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
  196. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  197. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
  198. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
  199. package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
  200. package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
  201. package/src/types/analytics.ts +1 -0
  202. package/src/types/auth.tsx +50 -1
  203. package/src/types/collections.ts +37 -6
  204. package/src/types/datasource.ts +24 -17
  205. package/src/types/entities.ts +9 -1
  206. package/src/types/entity_actions.tsx +17 -0
  207. package/src/types/entity_callbacks.ts +2 -2
  208. package/src/types/entity_overrides.tsx +7 -0
  209. package/src/types/firecms.tsx +0 -1
  210. package/src/types/index.ts +2 -1
  211. package/src/types/navigation.ts +17 -17
  212. package/src/types/permissions.ts +6 -1
  213. package/src/types/plugins.tsx +26 -28
  214. package/src/types/properties.ts +18 -6
  215. package/src/types/property_config.tsx +2 -2
  216. package/src/types/roles.ts +41 -0
  217. package/src/types/side_entity_controller.tsx +1 -0
  218. package/src/types/storage.ts +12 -3
  219. package/src/types/user.ts +7 -0
  220. package/src/util/collections.ts +22 -0
  221. package/src/util/entities.ts +1 -1
  222. package/src/util/enums.ts +1 -1
  223. package/src/util/icon_list.ts +2 -2
  224. package/src/util/icon_synonyms.ts +3 -99
  225. package/src/util/icons.tsx +11 -3
  226. package/src/util/navigation_utils.ts +6 -6
  227. package/src/util/objects.ts +8 -21
  228. package/src/util/permissions.ts +11 -8
  229. package/src/util/references.ts +36 -5
  230. package/src/util/resolutions.ts +32 -31
  231. package/src/util/strings.ts +2 -2
  232. package/src/util/useTraceUpdate.tsx +2 -1
  233. package/dist/components/VirtualTable/common.d.ts +0 -2
  234. package/dist/core/SideEntityView.d.ts +0 -7
  235. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  236. package/dist/internal/useLocaleConfig.d.ts +0 -1
  237. package/dist/types/appcheck.d.ts +0 -26
  238. package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
  239. package/src/core/SideEntityView.tsx +0 -38
  240. package/src/internal/useBuildCustomizationController.tsx +0 -5
  241. package/src/internal/useLocaleConfig.tsx +0 -18
  242. package/src/types/appcheck.ts +0 -29
@@ -1,11 +1,12 @@
1
- import { EntityCollection, PropertyConfig } from "../types";
1
+ import { EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
2
2
  import { isReferenceProperty } from "./property_utils";
3
3
  import { isPropertyBuilder } from "./entities";
4
+ import { getFieldConfig } from "../core";
4
5
 
5
- export function getReferencePreviewKeys(targetCollection: EntityCollection<any>,
6
- fields: Record<string, PropertyConfig>,
7
- previewProperties?: string[],
8
- limit = 3) {
6
+ export function getEntityPreviewKeys(targetCollection: EntityCollection<any>,
7
+ fields: Record<string, PropertyConfig>,
8
+ previewProperties?: string[],
9
+ limit = 3) {
9
10
  const allProperties = Object.keys(targetCollection.properties);
10
11
  let listProperties = previewProperties?.filter(p => allProperties.includes(p as string));
11
12
  if (listProperties && listProperties.length > 0) {
@@ -18,3 +19,33 @@ export function getReferencePreviewKeys(targetCollection: EntityCollection<any>,
18
19
  }).slice(0, limit);
19
20
  }
20
21
  }
22
+
23
+ export function getEntityTitlePropertyKey<M extends Record<string, any>>(collection: EntityCollection<M>, propertyConfigs: Record<string, PropertyConfig<any>>): string | undefined {
24
+ if (collection.titleProperty) {
25
+ return collection.titleProperty as string;
26
+ }
27
+ // find first text field property
28
+ for (const key in collection.properties) {
29
+ const property = collection.properties[key];
30
+ if (!isPropertyBuilder(property)) {
31
+ const field = getFieldConfig(property, propertyConfigs);
32
+ if (field?.key === "text_field") {
33
+ return key;
34
+ }
35
+ }
36
+ }
37
+ return undefined;
38
+ }
39
+
40
+ export function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined {
41
+
42
+ // find first text field property
43
+ for (const key in collection.properties) {
44
+ const property = collection.properties[key];
45
+ if (property.dataType === "string" && property.storage?.acceptedFiles?.includes("image/*")) {
46
+ return key;
47
+ }
48
+
49
+ }
50
+ return undefined;
51
+ }
@@ -26,7 +26,7 @@ import { getDefaultValuesFor, isPropertyBuilder } from "./entities";
26
26
  import { DEFAULT_ONE_OF_TYPE } from "./common";
27
27
  import { getIn } from "@firecms/formex";
28
28
  import { enumToObjectEntries } from "./enums";
29
- import { isDefaultFieldConfigId } from "../core";
29
+ import { isDefaultFieldConfigId } from "../core/field_configs";
30
30
 
31
31
  // import util from "util";
32
32
 
@@ -38,7 +38,8 @@ export const resolveCollection = <M extends Record<string, any>, >
38
38
  values,
39
39
  previousValues,
40
40
  userConfigPersistence,
41
- fields
41
+ fields,
42
+ ignoreMissingFields = false
42
43
  }: {
43
44
  collection: EntityCollection<M> | ResolvedEntityCollection<M>;
44
45
  path: string,
@@ -47,6 +48,7 @@ export const resolveCollection = <M extends Record<string, any>, >
47
48
  previousValues?: Partial<EntityValues<M>>,
48
49
  userConfigPersistence?: UserConfigurationPersistence;
49
50
  fields?: Record<string, PropertyConfig>;
51
+ ignoreMissingFields?: boolean;
50
52
  }): ResolvedEntityCollection<M> => {
51
53
 
52
54
  const collectionOverride = userConfigPersistence?.getCollectionConfig<M>(path);
@@ -58,16 +60,15 @@ export const resolveCollection = <M extends Record<string, any>, >
58
60
 
59
61
  const resolvedProperties = Object.entries(collection.properties)
60
62
  .map(([key, propertyOrBuilder]) => {
61
- const propertyValue = usedValues ? getIn(usedValues, key) : undefined;
62
63
  const childResolvedProperty = resolveProperty({
63
64
  propertyKey: key,
64
65
  propertyOrBuilder: propertyOrBuilder as PropertyOrBuilder | ResolvedProperty,
65
66
  values: usedValues,
66
67
  previousValues: usedPreviousValues,
67
68
  path,
68
- propertyValue,
69
69
  entityId,
70
- fields
70
+ fields,
71
+ ignoreMissingFields
71
72
  });
72
73
  if (!childResolvedProperty) return {};
73
74
  return ({
@@ -95,17 +96,15 @@ export const resolveCollection = <M extends Record<string, any>, >
95
96
  * Resolve property builders, enums and arrays.
96
97
  * @param propertyOrBuilder
97
98
  * @param propertyValue
98
- * @param values
99
99
  */
100
100
  export function resolveProperty<T extends CMSType = CMSType, M extends Record<string, any> = any>({
101
101
  propertyOrBuilder,
102
- propertyValue,
103
102
  fromBuilder = false,
103
+ ignoreMissingFields = false,
104
104
  ...props
105
105
  }: {
106
106
  propertyKey?: string,
107
107
  propertyOrBuilder: PropertyOrBuilder<T, M> | ResolvedProperty<T>,
108
- propertyValue?: unknown,
109
108
  values?: Partial<M>,
110
109
  previousValues?: Partial<M>,
111
110
  path?: string,
@@ -113,6 +112,7 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
113
112
  index?: number,
114
113
  fromBuilder?: boolean;
115
114
  fields?: Record<string, PropertyConfig<any>>;
115
+ ignoreMissingFields?: boolean;
116
116
  }): ResolvedProperty<T> | null {
117
117
 
118
118
  if (typeof propertyOrBuilder === "object" && "resolved" in propertyOrBuilder) {
@@ -128,10 +128,11 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
128
128
  if (!path)
129
129
  throw Error("Trying to resolve a property builder without specifying the entity path");
130
130
 
131
+ const usedPropertyValue = props.propertyKey ? getIn(props.values, props.propertyKey) : undefined;
131
132
  const result: Property<T> | null = propertyOrBuilder({
132
133
  ...props,
133
134
  path,
134
- propertyValue,
135
+ propertyValue: usedPropertyValue,
135
136
  values: props.values ?? {},
136
137
  previousValues: props.previousValues ?? props.values ?? {}
137
138
  });
@@ -142,17 +143,17 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
142
143
 
143
144
  resolvedProperty = resolveProperty({
144
145
  ...props,
145
- propertyValue,
146
146
  propertyOrBuilder: result,
147
- fromBuilder: true
147
+ fromBuilder: true,
148
+ ignoreMissingFields
148
149
  });
149
150
  } else {
150
151
  const property = propertyOrBuilder as Property<T>;
151
152
  if (property.dataType === "map" && property.properties) {
152
153
  const properties = resolveProperties({
154
+ ignoreMissingFields,
153
155
  ...props,
154
156
  properties: property.properties,
155
- propertyValue
156
157
  });
157
158
  resolvedProperty = {
158
159
  ...property,
@@ -163,8 +164,8 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
163
164
  } else if (property.dataType === "array") {
164
165
  resolvedProperty = resolveArrayProperty({
165
166
  property,
166
- propertyValue,
167
167
  fromBuilder,
168
+ ignoreMissingFields,
168
169
  ...props
169
170
  }) as ResolvedProperty<any>;
170
171
  } else if ((property.dataType === "string" || property.dataType === "number") && property.enumValues) {
@@ -182,12 +183,12 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
182
183
 
183
184
  if (resolvedProperty.propertyConfig && !isDefaultFieldConfigId(resolvedProperty.propertyConfig)) {
184
185
  const cmsFields = props.fields;
185
- if (!cmsFields) {
186
- throw Error(`Trying to resolve a property with key ${resolvedProperty.propertyConfig} that inherits from a custom property config but no custom property configs were provided. Use the property \`propertyConfigs\` in your app config to provide them`);
186
+ if (!cmsFields && !ignoreMissingFields) {
187
+ throw Error(`Trying to resolve a property with key '${resolvedProperty.propertyConfig}' that inherits from a custom property config but no custom property configs were provided. Use the property 'propertyConfigs' in your app config to provide them`);
187
188
  }
188
- const customField: PropertyConfig<any> = cmsFields[resolvedProperty.propertyConfig];
189
+ const customField: PropertyConfig | undefined = cmsFields?.[resolvedProperty.propertyConfig];
189
190
  if (!customField) {
190
- console.warn(`Trying to resolve a property with key ${resolvedProperty.propertyConfig} that inherits from a custom property config but no custom property config with that key was found. Check the \`propertyConfigs\` in your app config`)
191
+ console.warn(`Trying to resolve a property with key '${resolvedProperty.propertyConfig}' that inherits from a custom property config but no custom property config with that key was found. Check the 'propertyConfigs' in your app config`)
191
192
  console.warn("Available property configs", cmsFields);
192
193
  return null;
193
194
  }
@@ -198,7 +199,7 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
198
199
  }
199
200
  const customFieldProperty = resolveProperty<any>({
200
201
  propertyOrBuilder: configPropertyOrBuilder,
201
- propertyValue,
202
+ ignoreMissingFields,
202
203
  ...props
203
204
  });
204
205
  if (customFieldProperty) {
@@ -219,12 +220,11 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
219
220
  export function resolveArrayProperty<T extends any[], M>({
220
221
  propertyKey,
221
222
  property,
222
- propertyValue,
223
+ ignoreMissingFields = false,
223
224
  ...props
224
225
  }: {
225
226
  propertyKey?: string,
226
227
  property: ArrayProperty<T> | ResolvedArrayProperty<T>,
227
- propertyValue: any,
228
228
  values?: Partial<M>,
229
229
  previousValues?: Partial<M>,
230
230
  path?: string,
@@ -232,7 +232,9 @@ export function resolveArrayProperty<T extends any[], M>({
232
232
  index?: number,
233
233
  fromBuilder?: boolean;
234
234
  fields?: Record<string, PropertyConfig>;
235
+ ignoreMissingFields?: boolean;
235
236
  }): ResolvedArrayProperty {
237
+ const propertyValue = propertyKey ? getIn(props.values, propertyKey) : undefined;
236
238
 
237
239
  if (property.of) {
238
240
  if (Array.isArray(property.of)) {
@@ -244,7 +246,7 @@ export function resolveArrayProperty<T extends any[], M>({
244
246
  return resolveProperty({
245
247
  propertyKey: `${propertyKey}.${index}`,
246
248
  propertyOrBuilder: p as Property<any>,
247
- propertyValue: Array.isArray(propertyValue) ? propertyValue[index] : undefined,
249
+ ignoreMissingFields,
248
250
  ...props,
249
251
  index
250
252
  });
@@ -256,7 +258,7 @@ export function resolveArrayProperty<T extends any[], M>({
256
258
  ? propertyValue.map((v: any, index: number) => resolveProperty({
257
259
  propertyKey: `${propertyKey}.${index}`,
258
260
  propertyOrBuilder: of,
259
- propertyValue: v,
261
+ ignoreMissingFields,
260
262
  ...props,
261
263
  index
262
264
  })).filter(e => Boolean(e)) as ResolvedProperty[]
@@ -264,10 +266,10 @@ export function resolveArrayProperty<T extends any[], M>({
264
266
  const ofProperty = resolveProperty({
265
267
  propertyKey: `${propertyKey}`,
266
268
  propertyOrBuilder: of,
267
- propertyValue: undefined,
269
+ ignoreMissingFields,
268
270
  ...props
269
271
  });
270
- if (!ofProperty)
272
+ if (!ofProperty && !ignoreMissingFields)
271
273
  throw Error("When using a property builder as the 'of' prop of an ArrayProperty, you must return a valid child property")
272
274
  return {
273
275
  ...property,
@@ -287,14 +289,14 @@ export function resolveArrayProperty<T extends any[], M>({
287
289
  return resolveProperty({
288
290
  propertyKey: `${propertyKey}.${index}`,
289
291
  propertyOrBuilder: childProperty,
290
- propertyValue,
292
+ ignoreMissingFields,
291
293
  ...props
292
294
  });
293
295
  }).filter(e => Boolean(e)) as ResolvedProperty[]
294
296
  : [];
295
297
  const properties = resolveProperties<any>({
296
298
  properties: property.oneOf.properties,
297
- propertyValue: undefined,
299
+ ignoreMissingFields,
298
300
  ...props
299
301
  });
300
302
  return {
@@ -326,11 +328,10 @@ export function resolveArrayProperty<T extends any[], M>({
326
328
  */
327
329
  export function resolveProperties<M extends Record<string, any>>({
328
330
  properties,
329
- propertyValue,
331
+ ignoreMissingFields,
330
332
  ...props
331
333
  }: {
332
334
  properties: PropertiesOrBuilders<M>,
333
- propertyValue: unknown,
334
335
  values?: Partial<M>,
335
336
  previousValues?: Partial<M>,
336
337
  path?: string,
@@ -338,14 +339,14 @@ export function resolveProperties<M extends Record<string, any>>({
338
339
  index?: number,
339
340
  fromBuilder?: boolean;
340
341
  fields?: Record<string, PropertyConfig>;
342
+ ignoreMissingFields?: boolean;
341
343
  }): ResolvedProperties<M> {
342
344
  return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
343
345
  .map(([key, property]) => {
344
- const thisPropertyValue = propertyValue && typeof propertyValue === "object" ? getValueInPath(propertyValue, key) : undefined;
345
346
  const childResolvedProperty = resolveProperty({
346
347
  propertyKey: key,
347
348
  propertyOrBuilder: property,
348
- propertyValue: thisPropertyValue,
349
+ ignoreMissingFields,
349
350
  ...props
350
351
  });
351
352
  if (!childResolvedProperty) return {};
@@ -367,7 +368,7 @@ export function resolvePropertyEnum(property: StringProperty | NumberProperty, f
367
368
  return {
368
369
  ...property,
369
370
  resolved: true,
370
- enumValues: enumToObjectEntries(property.enumValues)?.filter((value) => value && value.id && value.label) ?? [],
371
+ enumValues: enumToObjectEntries(property.enumValues)?.filter((value) => value && (value.id || value.id === 0) && value.label) ?? [],
371
372
  fromBuilder: fromBuilder ?? false
372
373
  }
373
374
  }
@@ -56,8 +56,8 @@ export function unslugify(slug?: string): string {
56
56
  const result = slug.replace(/[-_]/g, " ");
57
57
  return result.replace(/\w\S*/g, function (txt) {
58
58
  return txt.charAt(0).toUpperCase() + txt.substr(1);
59
- });
59
+ }).trim();
60
60
  } else {
61
- return slug;
61
+ return slug.trim();
62
62
  }
63
63
  }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
 
3
- function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: number) {
3
+ export function printChanged(props: any, prev: any, path: string | undefined = "", depth: number | undefined = 0, maxDepth: number | undefined = 10) {
4
4
  if (depth > maxDepth) {
5
5
  return;
6
6
  }
@@ -17,6 +17,7 @@ function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: num
17
17
  export function useTraceUpdate(props: any, maxDepth = 3) {
18
18
  const prev = useRef(props);
19
19
  useEffect(() => {
20
+ console.log("Changed props:");
20
21
  printChanged(props, prev.current, "", 0, maxDepth);
21
22
  prev.current = props;
22
23
  });
@@ -1,2 +0,0 @@
1
- import { VirtualTableSize } from "./VirtualTableProps";
2
- export declare function getRowHeight(size: VirtualTableSize): number;
@@ -1,7 +0,0 @@
1
- import { EntityViewProps } from "./EntityView";
2
- import { User } from "../types";
3
- export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
4
- formWidth?: number | string;
5
- onClose?: () => void;
6
- };
7
- export declare function SideEntityView<M extends Record<string, any>, UserType extends User>({ path, entityId, selectedSubPath, copy, collection, parentCollectionIds, onValuesAreModified, formWidth, onUpdate, onClose }: SideEntityViewProps<M>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import { CustomizationController } from "../types/customization_controller";
2
- export declare function useBuildCustomizationController(controller: CustomizationController): CustomizationController;
@@ -1 +0,0 @@
1
- export declare function useLocaleConfig(locale?: string): void;
@@ -1,26 +0,0 @@
1
- import { FirebaseApp } from "firebase/app";
2
- /**
3
- * @group Firebase
4
- */
5
- export interface AppCheck {
6
- firebaseApp?: FirebaseApp;
7
- }
8
- /**
9
- * @group Firebase
10
- */
11
- export interface AppCheckOptions {
12
- providerKey: string;
13
- useEnterpriseRecaptcha: boolean;
14
- isTokenAutoRefreshEnabled?: boolean;
15
- debugToken?: string;
16
- forceRefresh?: boolean;
17
- }
18
- /**
19
- * @group Firebase
20
- */
21
- export declare interface AppCheckTokenResult {
22
- /**
23
- * The token string in JWT format.
24
- */
25
- readonly token: string;
26
- }
@@ -1,146 +0,0 @@
1
- import { useNavigate } from "react-router-dom";
2
-
3
- import { useCustomizationController, useFireCMSContext } from "../../hooks";
4
- import { PluginHomePageActionsProps, TopNavigationEntry } from "../../types";
5
- import { IconForView } from "../../util";
6
- import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
7
- import { ArrowForwardIcon, Card, cn, IconButton, Markdown, StarBorderIcon, StarIcon, Typography } from "@firecms/ui";
8
-
9
- /**
10
- * This is the component used in the home page to render a card for each
11
- * collection.
12
- * @group Components
13
- * @param view
14
- * @param path
15
- * @param collection
16
- * @param url
17
- * @param name
18
- * @param description
19
- * @param onClick
20
- * @constructor
21
- */
22
- export function NavigationCollectionCard({
23
- view,
24
- path,
25
- collection,
26
- url,
27
- name,
28
- description,
29
- onClick
30
- }: TopNavigationEntry & {
31
- onClick?: () => void
32
- }) {
33
-
34
- const userConfigurationPersistence = useUserConfigurationPersistence();
35
- const collectionIcon = <IconForView collectionOrView={collection ?? view}/>;
36
-
37
- const navigate = useNavigate();
38
- const context = useFireCMSContext();
39
- const customizationController = useCustomizationController();
40
-
41
- const favourite = (userConfigurationPersistence?.favouritePaths ?? []).includes(path);
42
-
43
- let actions: React.ReactNode | undefined;
44
- if (customizationController.plugins && collection) {
45
- const actionProps: PluginHomePageActionsProps = {
46
- path,
47
- collection,
48
- context
49
- };
50
- actions = <>
51
- {customizationController.plugins.map((plugin, i) => (
52
- plugin.homePage?.CollectionActions
53
- ? <plugin.homePage.CollectionActions
54
- key={`actions_${i}`}
55
- {...actionProps}
56
- extraProps={plugin.homePage.extraProps}
57
- />
58
- : null
59
- ))}
60
- </>
61
- ;
62
- }
63
-
64
- return (
65
- <Card
66
- className={cn("h-full p-4 cursor-pointer min-h-[230px]")}
67
- onClick={() => {
68
- onClick?.();
69
- navigate(url);
70
- if (userConfigurationPersistence) {
71
- userConfigurationPersistence.setRecentlyVisitedPaths(
72
- [path, ...(userConfigurationPersistence.recentlyVisitedPaths ?? []).filter(p => p !== path)]
73
- );
74
- }
75
- }}>
76
-
77
- <div className="flex flex-col items-start h-full">
78
- <div
79
- className="flex-grow w-full">
80
-
81
- <div
82
- className="h-10 flex items-center w-full justify-between text-gray-300 dark:text-gray-600">
83
-
84
- {collectionIcon}
85
-
86
- <div
87
- className="flex items-center gap-1"
88
- onClick={(event: React.MouseEvent) => {
89
- event.preventDefault();
90
- event.stopPropagation();
91
- }}>
92
-
93
- {actions}
94
-
95
- {userConfigurationPersistence &&
96
- <IconButton
97
- onClick={(e) => {
98
- e.preventDefault();
99
- e.stopPropagation();
100
- if (favourite) {
101
- userConfigurationPersistence.setFavouritePaths(
102
- userConfigurationPersistence.favouritePaths.filter(p => p !== path)
103
- );
104
- } else {
105
- userConfigurationPersistence.setFavouritePaths(
106
- [...userConfigurationPersistence.favouritePaths, path]
107
- );
108
- }
109
- }}>
110
- {
111
- favourite
112
- ? <StarIcon
113
- size={18}
114
- className={"text-secondary"}/>
115
- : <StarBorderIcon
116
- size={18}
117
- className={"text-gray-400 dark:text-gray-500"}/>}
118
- </IconButton>}
119
-
120
- </div>
121
-
122
- </div>
123
-
124
- <Typography gutterBottom variant="h5"
125
- component="h2">
126
- {name}
127
- </Typography>
128
-
129
- {description && <Typography variant="body2"
130
- color="secondary"
131
- component="div">
132
- <Markdown source={description}/>
133
- </Typography>}
134
- </div>
135
-
136
- <div style={{ alignSelf: "flex-end" }}>
137
-
138
- <div className={"p-4"}>
139
- <ArrowForwardIcon className="text-primary"/>
140
- </div>
141
- </div>
142
-
143
- </div>
144
-
145
- </Card>);
146
- }
@@ -1,38 +0,0 @@
1
- import { EntityViewProps } from "./EntityView";
2
- import { User } from "../types";
3
- import { useSideDialogContext } from "./SideDialogs";
4
- import { useSideEntityController } from "../hooks";
5
- import { FORM_CONTAINER_WIDTH } from "../internal/common";
6
-
7
- export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
8
- formWidth?: number | string;
9
- onClose?: () => void;
10
- }
11
-
12
- export function SideEntityView<M extends Record<string, any>, UserType extends User>({
13
- path,
14
- entityId,
15
- selectedSubPath,
16
- copy,
17
- collection,
18
- parentCollectionIds,
19
- onValuesAreModified,
20
- formWidth,
21
- onUpdate,
22
- onClose
23
- }: SideEntityViewProps<M>) {
24
-
25
- const sideDialogContext = useSideDialogContext();
26
- const sideEntityController = useSideEntityController();
27
- const resolvedFormWidth: string = typeof formWidth === "number" ? `${formWidth}px` : formWidth ?? FORM_CONTAINER_WIDTH;
28
-
29
- const onCloseHandler = () => {
30
- if (onClose) {
31
- onClose();
32
- } else {
33
- sideDialogContext.close();
34
- }
35
- }
36
-
37
- return <></>;
38
- }
@@ -1,5 +0,0 @@
1
- import { CustomizationController } from "../types/customization_controller";
2
-
3
- export function useBuildCustomizationController(controller: CustomizationController): CustomizationController {
4
- return controller;
5
- }
@@ -1,18 +0,0 @@
1
- import * as locales from "date-fns/locale";
2
- // @ts-ignore
3
- import { registerLocale, setDefaultLocale } from "react-datepicker";
4
- import { useEffect } from "react";
5
-
6
- export function useLocaleConfig(locale?: string) {
7
- useEffect(() => {
8
- if (!locale) {
9
- return;
10
- }
11
- // @ts-ignore
12
- const dateFnsLocale = locales[locale];
13
- if (dateFnsLocale) {
14
- registerLocale(locale, dateFnsLocale);
15
- setDefaultLocale(locale);
16
- }
17
- }, [locale])
18
- }
@@ -1,29 +0,0 @@
1
- import { FirebaseApp } from "firebase/app";
2
-
3
- /**
4
- * @group Firebase
5
- */
6
- export interface AppCheck {
7
- firebaseApp?: FirebaseApp;
8
- }
9
-
10
- /**
11
- * @group Firebase
12
- */
13
- export interface AppCheckOptions {
14
- providerKey: string;
15
- useEnterpriseRecaptcha: boolean;
16
- isTokenAutoRefreshEnabled?: boolean;
17
- debugToken?: string;
18
- forceRefresh?: boolean;
19
- }
20
-
21
- /**
22
- * @group Firebase
23
- */
24
- export declare interface AppCheckTokenResult {
25
- /**
26
- * The token string in JWT format.
27
- */
28
- readonly token: string;
29
- }