@firecms/core 3.0.0-canary.9 → 3.0.0-canary.91

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 (247) hide show
  1. package/README.md +1 -1
  2. package/dist/app/AppBar.d.ts +12 -0
  3. package/dist/app/Drawer.d.ts +17 -0
  4. package/dist/app/Scaffold.d.ts +30 -0
  5. package/dist/app/index.d.ts +4 -0
  6. package/dist/app/useApp.d.ts +16 -0
  7. package/dist/components/CircularProgressCenter.d.ts +1 -1
  8. package/dist/components/ClearFilterSortButton.d.ts +5 -0
  9. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -12
  10. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
  11. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
  12. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +1 -0
  13. package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
  14. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
  15. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
  16. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  17. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  18. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -2
  19. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
  20. package/dist/components/EntityPreview.d.ts +5 -4
  21. package/dist/components/ErrorView.d.ts +1 -1
  22. package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
  23. package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
  24. package/dist/components/ReferenceWidget.d.ts +3 -1
  25. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  26. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  27. package/dist/components/VirtualTable/VirtualTableProps.d.ts +15 -12
  28. package/dist/components/VirtualTable/types.d.ts +3 -3
  29. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  30. package/dist/components/common/index.d.ts +1 -0
  31. package/dist/components/common/table_height.d.ts +5 -0
  32. package/dist/components/common/types.d.ts +4 -6
  33. package/dist/components/common/useColumnsIds.d.ts +2 -1
  34. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  35. package/dist/components/index.d.ts +2 -1
  36. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  37. package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +6 -9
  38. package/dist/core/DefaultDrawer.d.ts +19 -0
  39. package/dist/core/DrawerNavigationItem.d.ts +9 -0
  40. package/dist/core/EntityEditView.d.ts +17 -3
  41. package/dist/core/FireCMS.d.ts +1 -1
  42. package/dist/core/NavigationRoutes.d.ts +3 -3
  43. package/dist/core/index.d.ts +3 -4
  44. package/dist/form/PropertiesForm.d.ts +8 -0
  45. package/dist/form/components/ErrorFocus.d.ts +1 -1
  46. package/dist/form/components/FieldHelperText.d.ts +3 -3
  47. package/dist/form/components/StorageItemPreview.d.ts +4 -4
  48. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  49. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -4
  50. package/dist/form/index.d.ts +0 -2
  51. package/dist/hooks/data/delete.d.ts +2 -2
  52. package/dist/hooks/data/save.d.ts +2 -3
  53. package/dist/hooks/data/useDataSource.d.ts +1 -1
  54. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  55. package/dist/hooks/index.d.ts +2 -0
  56. package/dist/hooks/useBuildNavigationController.d.ts +1 -2
  57. package/dist/hooks/useProjectLog.d.ts +2 -2
  58. package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.es.js +15825 -12165
  61. package/dist/index.es.js.map +1 -1
  62. package/dist/index.umd.js +19684 -7
  63. package/dist/index.umd.js.map +1 -1
  64. package/dist/internal/useBuildDataSource.d.ts +1 -16
  65. package/dist/internal/useRestoreScroll.d.ts +1 -1
  66. package/dist/preview/PropertyPreviewProps.d.ts +6 -4
  67. package/dist/preview/components/ReferencePreview.d.ts +2 -1
  68. package/dist/preview/components/StorageThumbnail.d.ts +2 -1
  69. package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
  70. package/dist/types/auth.d.ts +26 -2
  71. package/dist/types/collections.d.ts +31 -7
  72. package/dist/types/datasource.d.ts +34 -20
  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/fields.d.ts +31 -30
  77. package/dist/types/index.d.ts +0 -1
  78. package/dist/types/navigation.d.ts +5 -5
  79. package/dist/types/plugins.d.ts +16 -6
  80. package/dist/types/properties.d.ts +17 -4
  81. package/dist/types/storage.d.ts +11 -3
  82. package/dist/util/collections.d.ts +1 -1
  83. package/dist/util/entities.d.ts +1 -1
  84. package/dist/util/icon_synonyms.d.ts +1 -97
  85. package/dist/util/icons.d.ts +2 -2
  86. package/dist/util/navigation_utils.d.ts +2 -2
  87. package/dist/util/objects.d.ts +1 -1
  88. package/dist/util/plurals.d.ts +0 -2
  89. package/dist/util/resolutions.d.ts +13 -13
  90. package/dist/util/storage.d.ts +23 -2
  91. package/dist/util/useStorageUploadController.d.ts +1 -1
  92. package/dist/util/useTraceUpdate.d.ts +1 -0
  93. package/package.json +130 -119
  94. package/src/app/AppBar.tsx +18 -0
  95. package/src/app/Drawer.tsx +25 -0
  96. package/src/app/Scaffold.tsx +249 -0
  97. package/src/app/index.ts +4 -0
  98. package/src/app/useApp.tsx +32 -0
  99. package/src/components/CircularProgressCenter.tsx +1 -1
  100. package/src/components/ClearFilterSortButton.tsx +41 -0
  101. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +9 -18
  102. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +21 -20
  103. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +10 -6
  104. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +38 -34
  105. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  106. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +11 -2
  107. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +14 -6
  108. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
  109. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
  110. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -5
  111. package/src/components/EntityCollectionView/EntityCollectionView.tsx +69 -45
  112. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  113. package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
  114. package/src/components/EntityPreview.tsx +15 -9
  115. package/src/components/EntityView.tsx +5 -5
  116. package/src/components/ErrorView.tsx +1 -1
  117. package/src/components/HomePage/DefaultHomePage.tsx +3 -3
  118. package/src/components/HomePage/NavigationCard.tsx +3 -3
  119. package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
  120. package/src/components/HomePage/SmallNavigationCard.tsx +5 -5
  121. package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
  122. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
  123. package/src/components/ReferenceWidget.tsx +22 -12
  124. package/src/components/SearchIconsView.tsx +5 -5
  125. package/src/components/SelectableTable/SelectableTable.tsx +7 -7
  126. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
  127. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
  128. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +28 -6
  129. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  130. package/src/components/VirtualTable/VirtualTable.tsx +70 -37
  131. package/src/components/VirtualTable/VirtualTableCell.tsx +1 -1
  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 +18 -14
  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 +2 -2
  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 +23 -2
  143. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
  144. package/src/components/common/useTableSearchHelper.ts +52 -12
  145. package/src/components/index.tsx +2 -1
  146. package/src/contexts/AuthControllerContext.tsx +1 -1
  147. package/src/contexts/DialogsProvider.tsx +2 -2
  148. package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +52 -37
  149. package/src/core/DefaultDrawer.tsx +177 -0
  150. package/src/core/DrawerNavigationItem.tsx +62 -0
  151. package/src/core/EntityEditView.tsx +711 -139
  152. package/src/core/EntitySidePanel.tsx +1 -2
  153. package/src/core/FireCMS.tsx +39 -44
  154. package/src/core/NavigationRoutes.tsx +7 -8
  155. package/src/core/field_configs.tsx +2 -3
  156. package/src/core/index.tsx +3 -4
  157. package/src/form/PropertiesForm.tsx +81 -0
  158. package/src/form/PropertyFieldBinding.tsx +29 -7
  159. package/src/form/components/FieldHelperText.tsx +3 -3
  160. package/src/form/components/StorageItemPreview.tsx +20 -11
  161. package/src/form/components/StorageUploadProgress.tsx +3 -3
  162. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
  163. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -5
  164. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
  165. package/src/form/field_bindings/KeyValueFieldBinding.tsx +44 -39
  166. package/src/form/field_bindings/MapFieldBinding.tsx +11 -3
  167. package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
  168. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -9
  169. package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
  170. package/src/form/field_bindings/RepeatFieldBinding.tsx +10 -7
  171. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
  172. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +22 -43
  173. package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -1
  174. package/src/form/index.tsx +4 -4
  175. package/src/form/validation.ts +1 -17
  176. package/src/hooks/data/delete.ts +3 -3
  177. package/src/hooks/data/save.ts +4 -2
  178. package/src/hooks/data/useDataSource.tsx +2 -2
  179. package/src/hooks/data/useEntityFetch.tsx +3 -3
  180. package/src/hooks/index.tsx +3 -0
  181. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
  182. package/src/hooks/useBuildModeController.tsx +11 -5
  183. package/src/hooks/useBuildNavigationController.tsx +137 -61
  184. package/src/hooks/useProjectLog.tsx +21 -8
  185. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  186. package/src/hooks/useValidateAuthenticator.tsx +115 -0
  187. package/src/index.ts +1 -0
  188. package/src/internal/useBuildDataSource.ts +56 -49
  189. package/src/internal/useBuildSideEntityController.tsx +88 -21
  190. package/src/preview/PropertyPreview.tsx +9 -16
  191. package/src/preview/PropertyPreviewProps.tsx +4 -8
  192. package/src/preview/components/BooleanPreview.tsx +4 -2
  193. package/src/preview/components/EnumValuesChip.tsx +1 -1
  194. package/src/preview/components/ImagePreview.tsx +21 -33
  195. package/src/preview/components/ReferencePreview.tsx +23 -23
  196. package/src/preview/components/StorageThumbnail.tsx +5 -1
  197. package/src/preview/components/UrlComponentPreview.tsx +44 -11
  198. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  199. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
  200. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
  201. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  202. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
  203. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
  204. package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
  205. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  206. package/src/types/auth.tsx +35 -2
  207. package/src/types/collections.ts +37 -8
  208. package/src/types/customization_controller.tsx +0 -1
  209. package/src/types/datasource.ts +41 -24
  210. package/src/types/entities.ts +9 -1
  211. package/src/types/entity_actions.tsx +16 -3
  212. package/src/types/entity_callbacks.ts +2 -2
  213. package/src/types/fields.tsx +33 -33
  214. package/src/types/index.ts +0 -1
  215. package/src/types/navigation.ts +6 -7
  216. package/src/types/plugins.tsx +18 -8
  217. package/src/types/properties.ts +22 -6
  218. package/src/types/storage.ts +12 -3
  219. package/src/util/collections.ts +1 -1
  220. package/src/util/entities.ts +5 -4
  221. package/src/util/enums.ts +1 -1
  222. package/src/util/icon_list.ts +2 -2
  223. package/src/util/icon_synonyms.ts +3 -99
  224. package/src/util/navigation_utils.ts +6 -6
  225. package/src/util/objects.ts +25 -28
  226. package/src/util/permissions.ts +1 -0
  227. package/src/util/plurals.ts +0 -2
  228. package/src/util/resolutions.ts +32 -31
  229. package/src/util/storage.ts +75 -21
  230. package/src/util/strings.ts +2 -2
  231. package/src/util/useStorageUploadController.tsx +21 -3
  232. package/src/util/useTraceUpdate.tsx +2 -1
  233. package/dist/components/VirtualTable/common.d.ts +0 -2
  234. package/dist/core/Drawer.d.ts +0 -23
  235. package/dist/core/Scaffold.d.ts +0 -55
  236. package/dist/core/SideEntityView.d.ts +0 -7
  237. package/dist/form/EntityForm.d.ts +0 -77
  238. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  239. package/dist/internal/useLocaleConfig.d.ts +0 -1
  240. package/dist/types/appcheck.d.ts +0 -26
  241. package/src/core/Drawer.tsx +0 -191
  242. package/src/core/Scaffold.tsx +0 -281
  243. package/src/core/SideEntityView.tsx +0 -38
  244. package/src/form/EntityForm.tsx +0 -728
  245. package/src/internal/useBuildCustomizationController.tsx +0 -5
  246. package/src/internal/useLocaleConfig.tsx +0 -18
  247. package/src/types/appcheck.ts +0 -29
@@ -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
  }
@@ -7,15 +7,28 @@ import {
7
7
  } from "../types";
8
8
  import { randomString } from "./strings";
9
9
 
10
+ interface ResolveFilenameStringParams<M extends object> {
11
+ input: string | ((context: UploadedFileContext) => (Promise<string> | string));
12
+ storage: StorageConfig;
13
+ values: EntityValues<M>;
14
+ entityId: string;
15
+ path?: string;
16
+ property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
17
+ file: File;
18
+ propertyKey: string;
19
+ }
20
+
10
21
  export async function resolveFilenameString<M extends object>(
11
- input: string | ((context: UploadedFileContext) => Promise<string> | string),
12
- storage: StorageConfig,
13
- values: EntityValues<M>,
14
- entityId: string,
15
- path: string,
16
- property: ResolvedStringProperty | ResolvedArrayProperty<string[]>,
17
- file: File,
18
- propertyKey: string): Promise<string> {
22
+ {
23
+ input,
24
+ storage,
25
+ values,
26
+ entityId,
27
+ path,
28
+ property,
29
+ file,
30
+ propertyKey
31
+ }: ResolveFilenameStringParams<M>): Promise<string> {
19
32
  let result;
20
33
  if (typeof input === "function") {
21
34
  result = await input({
@@ -30,7 +43,13 @@ export async function resolveFilenameString<M extends object>(
30
43
  if (!result)
31
44
  console.warn("Storage callback returned empty result. Using default name value")
32
45
  } else {
33
- result = replacePlaceholders(file, input, entityId, propertyKey, path);
46
+ result = replacePlaceholders({
47
+ file,
48
+ input,
49
+ entityId,
50
+ propertyKey,
51
+ path
52
+ });
34
53
  }
35
54
 
36
55
  if (!result)
@@ -39,15 +58,28 @@ export async function resolveFilenameString<M extends object>(
39
58
  return result;
40
59
  }
41
60
 
61
+ interface ResolveStoragePathStringParams<M extends object> {
62
+ input: string | ((context: UploadedFileContext) => string);
63
+ storage: StorageConfig;
64
+ values: EntityValues<M>;
65
+ entityId: string;
66
+ path?: string;
67
+ property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
68
+ file: File;
69
+ propertyKey: string;
70
+ }
71
+
42
72
  export function resolveStoragePathString<M extends object>(
43
- input: string | ((context: UploadedFileContext) => string),
44
- storage: StorageConfig,
45
- values: EntityValues<M>,
46
- entityId: string,
47
- path: string,
48
- property: ResolvedStringProperty | ResolvedArrayProperty<string[]>,
49
- file: File,
50
- propertyKey: string): string {
73
+ {
74
+ input,
75
+ storage,
76
+ values,
77
+ entityId,
78
+ path,
79
+ property,
80
+ file,
81
+ propertyKey
82
+ }: ResolveStoragePathStringParams<M>): string {
51
83
  let result;
52
84
  if (typeof input === "function") {
53
85
  result = input({
@@ -62,7 +94,13 @@ export function resolveStoragePathString<M extends object>(
62
94
  if (!result)
63
95
  console.warn("Storage callback returned empty result. Using default name value")
64
96
  } else {
65
- result = replacePlaceholders(file, input, entityId, propertyKey, path);
97
+ result = replacePlaceholders({
98
+ file,
99
+ input,
100
+ entityId,
101
+ propertyKey,
102
+ path
103
+ });
66
104
  }
67
105
 
68
106
  if (!result)
@@ -71,14 +109,30 @@ export function resolveStoragePathString<M extends object>(
71
109
  return result;
72
110
  }
73
111
 
74
- function replacePlaceholders(file: File, input: string, entityId: string, propertyKey: string, path: string) {
112
+ interface Placeholders {
113
+ file: File;
114
+ input: string;
115
+ entityId: string;
116
+ propertyKey: string;
117
+ path?: string;
118
+ }
119
+
120
+ function replacePlaceholders({
121
+ file,
122
+ input,
123
+ entityId,
124
+ propertyKey,
125
+ path
126
+ }: Placeholders) {
75
127
  const ext = file.name.split(".").pop();
76
128
  let result = input.replace("{entityId}", entityId)
77
129
  .replace("{propertyKey}", propertyKey)
78
130
  .replace("{rand}", randomString())
79
131
  .replace("{file}", file.name)
80
- .replace("{file.type}", file.type)
81
- .replace("{path}", path);
132
+ .replace("{file.type}", file.type);
133
+ if (path) {
134
+ result = result.replace("{path}", path);
135
+ }
82
136
  if (ext) {
83
137
  result = result.replace("{file.ext}", ext);
84
138
  const name = file.name.replace(`.${ext}`, "");
@@ -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
  }
@@ -46,7 +46,7 @@ export function useStorageUploadController<M extends object>({
46
46
  entityId: string,
47
47
  entityValues: EntityValues<M>,
48
48
  value: string | string[] | null;
49
- path: string,
49
+ path?: string,
50
50
  propertyKey: string,
51
51
  property: ResolvedStringProperty | ResolvedArrayProperty<string[]>,
52
52
  storageSource: StorageSource,
@@ -95,7 +95,16 @@ export function useStorageUploadController<M extends object>({
95
95
 
96
96
  const fileNameBuilder = useCallback(async (file: File) => {
97
97
  if (storage.fileName) {
98
- const fileName = await resolveFilenameString(storage.fileName, storage, entityValues, entityId, path, property, file, propertyKey);
98
+ const fileName = await resolveFilenameString({
99
+ input: storage.fileName,
100
+ storage,
101
+ values: entityValues,
102
+ entityId,
103
+ path,
104
+ property,
105
+ file,
106
+ propertyKey
107
+ });
99
108
  if (!fileName || fileName.length === 0) {
100
109
  throw Error("You need to return a valid filename");
101
110
  }
@@ -105,7 +114,16 @@ export function useStorageUploadController<M extends object>({
105
114
  }, [entityId, entityValues, path, property, propertyKey, storage]);
106
115
 
107
116
  const storagePathBuilder = useCallback((file: File) => {
108
- return resolveStoragePathString(storage.storagePath, storage, entityValues, entityId, path, property, file, propertyKey) ?? "/";
117
+ return resolveStoragePathString({
118
+ input: storage.storagePath,
119
+ storage,
120
+ values: entityValues,
121
+ entityId,
122
+ path,
123
+ property,
124
+ file,
125
+ propertyKey
126
+ }) ?? "/";
109
127
  }, [entityId, entityValues, path, property, propertyKey, storage]);
110
128
 
111
129
  const onFileUploadComplete = useCallback(async (uploadedPath: string,
@@ -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,23 +0,0 @@
1
- import React from "react";
2
- /**
3
- * Props used in case you need to override the default drawer
4
- * @group Core
5
- */
6
- export type DrawerProps<T = {}> = T & {
7
- hovered: boolean;
8
- drawerOpen: boolean;
9
- closeDrawer: () => any;
10
- };
11
- /**
12
- * Default drawer used in the CMS
13
- * @group Core
14
- */
15
- export declare function Drawer({ hovered, drawerOpen, closeDrawer }: DrawerProps): import("react/jsx-runtime").JSX.Element;
16
- export declare function DrawerNavigationItem({ name, icon, drawerOpen, tooltipsOpen, url, onClick }: {
17
- icon: React.ReactElement;
18
- name: string;
19
- tooltipsOpen: boolean;
20
- drawerOpen: boolean;
21
- url: string;
22
- onClick?: () => void;
23
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,55 +0,0 @@
1
- import React from "react";
2
- import { DrawerProps } from "./Drawer";
3
- import { FireCMSAppBarProps } from "../components";
4
- export declare const DRAWER_WIDTH = 280;
5
- /**
6
- * @group Core
7
- */
8
- export interface ScaffoldProps<ExtraDrawerProps = object, ExtraAppbarProps = object> {
9
- /**
10
- * Name of the app, displayed as the main title and in the tab title
11
- */
12
- name: string;
13
- /**
14
- * Logo to be displayed in the drawer of the CMS
15
- */
16
- logo?: string;
17
- /**
18
- * Whether to include the drawer in the scaffold
19
- */
20
- includeDrawer?: boolean;
21
- /**
22
- * In case you need to override the view that gets rendered as a drawer
23
- * @see DefaultDrawer
24
- */
25
- Drawer?: React.ComponentType<DrawerProps<ExtraDrawerProps>>;
26
- /**
27
- * Additional props passed to the custom Drawer
28
- */
29
- drawerProps?: Partial<DrawerProps> & ExtraDrawerProps;
30
- /**
31
- * Open the drawer on hover
32
- */
33
- autoOpenDrawer?: boolean;
34
- /**
35
- * A component that gets rendered on the upper side of the main toolbar.
36
- * `toolbarExtraWidget` has no effect if this is set.
37
- */
38
- FireCMSAppBar?: React.ComponentType<FireCMSAppBarProps<ExtraAppbarProps>>;
39
- /**
40
- * Additional props passed to the custom AppBar
41
- */
42
- fireCMSAppBarProps?: Partial<FireCMSAppBarProps> & ExtraAppbarProps;
43
- }
44
- /**
45
- * This view acts as a scaffold for FireCMS.
46
- *
47
- * It is in charge of displaying the navigation drawer, top bar and main
48
- * collection views.
49
- * This component needs a parent {@link FireCMS}
50
- *
51
- * @param props
52
- * @constructor
53
- * @group Core
54
- */
55
- export declare const Scaffold: React.NamedExoticComponent<React.PropsWithChildren<ScaffoldProps<object, object>>>;
@@ -1,7 +0,0 @@
1
- import { User } from "../types";
2
- import { EntityEditViewProps } from "./EntityEditView";
3
- export type SideEntityViewProps<M extends Record<string, any>> = EntityEditViewProps<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,77 +0,0 @@
1
- import { Entity, EntityCollection, EntityStatus, EntityValues, FormContext, ResolvedEntityCollection } from "../types";
2
- import { ValidationError } from "yup";
3
- /**
4
- * @group Components
5
- */
6
- export interface EntityFormProps<M extends Record<string, any>> {
7
- /**
8
- * New or existing status
9
- */
10
- status: EntityStatus;
11
- /**
12
- * Path of the collection this entity is located
13
- */
14
- path: string;
15
- /**
16
- * The collection is used to build the fields of the form
17
- */
18
- collection: EntityCollection<M>;
19
- /**
20
- * The updated entity is passed from the parent component when the underlying data
21
- * has changed in the datasource
22
- */
23
- entity?: Entity<M>;
24
- /**
25
- * The callback function called when Save is clicked and validation is correct
26
- */
27
- onEntitySaveRequested: (props: EntityFormSaveParams<M>) => Promise<void>;
28
- /**
29
- * The callback function called when discard is clicked
30
- */
31
- onDiscard?: () => void;
32
- /**
33
- * The callback function when the form is dirty, so the values are different
34
- * from the original ones
35
- */
36
- onModified?: (dirty: boolean) => void;
37
- /**
38
- * The callback function when the form original values have been modified
39
- */
40
- onValuesChanged?: (values?: EntityValues<M>) => void;
41
- /**
42
- *
43
- * @param id
44
- */
45
- onIdChange?: (id: string) => void;
46
- currentEntityId?: string;
47
- onFormContextChange?: (formContext: FormContext<M>) => void;
48
- hideId?: boolean;
49
- autoSave?: boolean;
50
- onIdUpdateError?: (error: any) => void;
51
- }
52
- export type EntityFormSaveParams<M extends Record<string, any>> = {
53
- collection: ResolvedEntityCollection<M>;
54
- path: string;
55
- entityId: string | undefined;
56
- values: EntityValues<M>;
57
- previousValues?: EntityValues<M>;
58
- closeAfterSave: boolean;
59
- autoSave: boolean;
60
- };
61
- /**
62
- * This is the form used internally by the CMS
63
- * @param status
64
- * @param path
65
- * @param collection
66
- * @param entity
67
- * @param onEntitySave
68
- * @param onDiscard
69
- * @param onModified
70
- * @param onValuesChanged
71
- * @constructor
72
- * @group Components
73
- */
74
- export declare const EntityForm: typeof EntityFormInternal;
75
- declare function EntityFormInternal<M extends Record<string, any>>({ status, path, collection: inputCollection, entity, onEntitySaveRequested, onDiscard, onModified, onValuesChanged, onIdChange, onFormContextChange, hideId, autoSave, onIdUpdateError, }: EntityFormProps<M>): import("react/jsx-runtime").JSX.Element;
76
- export declare function yupToFormErrors(yupError: ValidationError): Record<string, any>;
77
- export {};
@@ -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
- }