@firecms/core 3.0.0-canary.11 → 3.0.0-canary.111

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 (269) 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 +2 -2
  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/PropertyIdCopyTooltip.d.ts +8 -0
  25. package/dist/components/ReferenceWidget.d.ts +3 -1
  26. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  27. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  28. package/dist/components/VirtualTable/VirtualTableProps.d.ts +15 -12
  29. package/dist/components/VirtualTable/types.d.ts +3 -3
  30. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  31. package/dist/components/common/index.d.ts +1 -0
  32. package/dist/components/common/table_height.d.ts +5 -0
  33. package/dist/components/common/types.d.ts +4 -6
  34. package/dist/components/common/useColumnsIds.d.ts +2 -1
  35. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  36. package/dist/components/index.d.ts +3 -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 +18 -4
  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/PropertyFieldBinding.d.ts +1 -1
  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/LabelWithIcon.d.ts +1 -1
  48. package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
  49. package/dist/form/components/StorageItemPreview.d.ts +4 -4
  50. package/dist/form/components/index.d.ts +1 -0
  51. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  52. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  53. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  54. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  55. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  56. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
  57. package/dist/form/field_bindings/MultiSelectBinding.d.ts +1 -1
  58. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  59. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  60. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  61. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -5
  62. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  63. package/dist/form/index.d.ts +2 -4
  64. package/dist/hooks/data/save.d.ts +1 -2
  65. package/dist/hooks/index.d.ts +1 -0
  66. package/dist/hooks/useBuildNavigationController.d.ts +1 -2
  67. package/dist/hooks/useProjectLog.d.ts +2 -2
  68. package/dist/hooks/useValidateAuthenticator.d.ts +4 -8
  69. package/dist/index.d.ts +1 -0
  70. package/dist/index.es.js +15632 -12442
  71. package/dist/index.es.js.map +1 -1
  72. package/dist/index.umd.js +19871 -587
  73. package/dist/index.umd.js.map +1 -1
  74. package/dist/internal/useBuildDataSource.d.ts +1 -16
  75. package/dist/preview/PropertyPreviewProps.d.ts +6 -1
  76. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  77. package/dist/preview/components/ReferencePreview.d.ts +2 -1
  78. package/dist/preview/components/StorageThumbnail.d.ts +2 -1
  79. package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
  80. package/dist/types/auth.d.ts +3 -3
  81. package/dist/types/collections.d.ts +39 -5
  82. package/dist/types/datasource.d.ts +45 -31
  83. package/dist/types/entities.d.ts +6 -1
  84. package/dist/types/entity_actions.d.ts +14 -0
  85. package/dist/types/fields.d.ts +45 -39
  86. package/dist/types/index.d.ts +0 -1
  87. package/dist/types/navigation.d.ts +6 -5
  88. package/dist/types/plugins.d.ts +14 -4
  89. package/dist/types/properties.d.ts +32 -19
  90. package/dist/types/storage.d.ts +11 -3
  91. package/dist/util/entities.d.ts +1 -1
  92. package/dist/util/icon_list.d.ts +5 -1
  93. package/dist/util/icon_synonyms.d.ts +1 -97
  94. package/dist/util/icons.d.ts +2 -2
  95. package/dist/util/index.d.ts +1 -0
  96. package/dist/util/navigation_utils.d.ts +2 -2
  97. package/dist/util/objects.d.ts +1 -1
  98. package/dist/util/plurals.d.ts +0 -2
  99. package/dist/util/resolutions.d.ts +14 -13
  100. package/dist/util/storage.d.ts +23 -2
  101. package/dist/util/useStorageUploadController.d.ts +1 -1
  102. package/package.json +128 -119
  103. package/src/app/AppBar.tsx +18 -0
  104. package/src/app/Drawer.tsx +25 -0
  105. package/src/app/Scaffold.tsx +245 -0
  106. package/src/app/index.ts +4 -0
  107. package/src/app/useApp.tsx +32 -0
  108. package/src/components/ArrayContainer.tsx +9 -7
  109. package/src/components/CircularProgressCenter.tsx +1 -1
  110. package/src/components/ClearFilterSortButton.tsx +41 -0
  111. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +12 -19
  112. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +21 -20
  113. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +10 -6
  114. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +41 -35
  115. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  116. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +22 -12
  117. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +14 -6
  118. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
  119. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -13
  120. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
  121. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +7 -10
  122. package/src/components/EntityCollectionView/EntityCollectionView.tsx +75 -51
  123. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  124. package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
  125. package/src/components/EntityPreview.tsx +21 -15
  126. package/src/components/EntityView.tsx +5 -5
  127. package/src/components/ErrorView.tsx +1 -1
  128. package/src/components/HomePage/DefaultHomePage.tsx +24 -15
  129. package/src/components/HomePage/NavigationCard.tsx +3 -3
  130. package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
  131. package/src/components/HomePage/SmallNavigationCard.tsx +5 -6
  132. package/src/components/PropertyIdCopyTooltip.tsx +48 -0
  133. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +2 -5
  134. package/src/components/ReferenceWidget.tsx +22 -12
  135. package/src/components/SearchIconsView.tsx +11 -7
  136. package/src/components/SelectableTable/SelectableTable.tsx +7 -7
  137. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
  138. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
  139. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +28 -6
  140. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  141. package/src/components/VirtualTable/VirtualTable.tsx +70 -37
  142. package/src/components/VirtualTable/VirtualTableCell.tsx +1 -1
  143. package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
  144. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
  145. package/src/components/VirtualTable/VirtualTableProps.tsx +18 -14
  146. package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
  147. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  148. package/src/components/VirtualTable/types.tsx +2 -3
  149. package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +2 -2
  150. package/src/components/common/index.ts +1 -0
  151. package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
  152. package/src/components/common/types.tsx +4 -6
  153. package/src/components/common/useColumnsIds.tsx +23 -2
  154. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
  155. package/src/components/common/useTableSearchHelper.ts +53 -12
  156. package/src/components/index.tsx +3 -1
  157. package/src/contexts/DialogsProvider.tsx +2 -2
  158. package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +52 -37
  159. package/src/core/DefaultDrawer.tsx +177 -0
  160. package/src/core/DrawerNavigationItem.tsx +64 -0
  161. package/src/core/EntityEditView.tsx +702 -137
  162. package/src/core/EntitySidePanel.tsx +1 -2
  163. package/src/core/FireCMS.tsx +39 -44
  164. package/src/core/NavigationRoutes.tsx +7 -8
  165. package/src/core/SideDialogs.tsx +4 -0
  166. package/src/core/field_configs.tsx +4 -5
  167. package/src/core/index.tsx +3 -4
  168. package/src/form/PropertyFieldBinding.tsx +53 -21
  169. package/src/form/components/CustomIdField.tsx +4 -2
  170. package/src/form/components/FieldHelperText.tsx +4 -4
  171. package/src/form/components/LabelWithIcon.tsx +27 -19
  172. package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
  173. package/src/form/components/StorageItemPreview.tsx +21 -11
  174. package/src/form/components/StorageUploadProgress.tsx +3 -4
  175. package/src/form/components/index.tsx +1 -0
  176. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +15 -11
  177. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +26 -21
  178. package/src/form/field_bindings/BlockFieldBinding.tsx +13 -12
  179. package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
  180. package/src/form/field_bindings/KeyValueFieldBinding.tsx +52 -46
  181. package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
  182. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +138 -0
  183. package/src/form/field_bindings/MultiSelectBinding.tsx +9 -5
  184. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +11 -16
  185. package/src/form/field_bindings/ReferenceFieldBinding.tsx +37 -27
  186. package/src/form/field_bindings/RepeatFieldBinding.tsx +20 -16
  187. package/src/form/field_bindings/SelectFieldBinding.tsx +47 -41
  188. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +31 -52
  189. package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
  190. package/src/form/field_bindings/TextFieldBinding.tsx +26 -22
  191. package/src/form/index.tsx +6 -6
  192. package/src/form/validation.ts +1 -17
  193. package/src/hooks/data/save.ts +6 -1
  194. package/src/hooks/data/useDataSource.tsx +1 -1
  195. package/src/hooks/index.tsx +1 -0
  196. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
  197. package/src/hooks/useBuildModeController.tsx +11 -5
  198. package/src/hooks/useBuildNavigationController.tsx +94 -32
  199. package/src/hooks/useProjectLog.tsx +19 -8
  200. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  201. package/src/hooks/useValidateAuthenticator.tsx +21 -41
  202. package/src/index.ts +1 -0
  203. package/src/internal/useBuildDataSource.ts +84 -62
  204. package/src/internal/useBuildSideEntityController.tsx +90 -21
  205. package/src/internal/useUnsavedChangesDialog.tsx +3 -1
  206. package/src/preview/PropertyPreview.tsx +10 -17
  207. package/src/preview/PropertyPreviewProps.tsx +7 -1
  208. package/src/preview/components/BooleanPreview.tsx +2 -2
  209. package/src/preview/components/EnumValuesChip.tsx +2 -2
  210. package/src/preview/components/ImagePreview.tsx +24 -34
  211. package/src/preview/components/ReferencePreview.tsx +23 -23
  212. package/src/preview/components/StorageThumbnail.tsx +5 -1
  213. package/src/preview/components/UrlComponentPreview.tsx +44 -11
  214. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  215. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +3 -2
  216. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -2
  217. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  218. package/src/preview/property_previews/ArrayOneOfPreview.tsx +3 -4
  219. package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -4
  220. package/src/preview/property_previews/MapPropertyPreview.tsx +6 -6
  221. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  222. package/src/preview/property_previews/StringPropertyPreview.tsx +3 -3
  223. package/src/preview/util.ts +2 -2
  224. package/src/types/auth.tsx +3 -3
  225. package/src/types/collections.ts +48 -7
  226. package/src/types/customization_controller.tsx +0 -1
  227. package/src/types/datasource.ts +53 -39
  228. package/src/types/entities.ts +11 -1
  229. package/src/types/entity_actions.tsx +16 -3
  230. package/src/types/fields.tsx +49 -43
  231. package/src/types/index.ts +0 -1
  232. package/src/types/navigation.ts +7 -7
  233. package/src/types/plugins.tsx +16 -6
  234. package/src/types/properties.ts +37 -20
  235. package/src/types/storage.ts +12 -3
  236. package/src/util/entities.ts +5 -4
  237. package/src/util/enums.ts +1 -1
  238. package/src/util/icon_list.ts +15 -10
  239. package/src/util/icon_synonyms.ts +3 -99
  240. package/src/util/index.ts +1 -0
  241. package/src/util/navigation_utils.ts +6 -6
  242. package/src/util/objects.ts +25 -28
  243. package/src/util/permissions.ts +1 -0
  244. package/src/util/plurals.ts +0 -2
  245. package/src/util/references.ts +3 -0
  246. package/src/util/resolutions.ts +44 -39
  247. package/src/util/storage.ts +76 -22
  248. package/src/util/strings.ts +2 -2
  249. package/src/util/useStorageUploadController.tsx +22 -4
  250. package/src/util/useTraceUpdate.tsx +1 -0
  251. package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
  252. package/dist/components/VirtualTable/common.d.ts +0 -2
  253. package/dist/core/Drawer.d.ts +0 -23
  254. package/dist/core/Scaffold.d.ts +0 -55
  255. package/dist/core/SideEntityView.d.ts +0 -7
  256. package/dist/form/EntityForm.d.ts +0 -77
  257. package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
  258. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  259. package/dist/internal/useLocaleConfig.d.ts +0 -1
  260. package/dist/types/appcheck.d.ts +0 -26
  261. package/src/components/PropertyIdCopyTooltipContent.tsx +0 -28
  262. package/src/core/Drawer.tsx +0 -191
  263. package/src/core/Scaffold.tsx +0 -281
  264. package/src/core/SideEntityView.tsx +0 -38
  265. package/src/form/EntityForm.tsx +0 -728
  266. package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
  267. package/src/internal/useBuildCustomizationController.tsx +0 -5
  268. package/src/internal/useLocaleConfig.tsx +0 -18
  269. 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
  });
@@ -253,21 +255,22 @@ export function resolveArrayProperty<T extends any[], M>({
253
255
  } else {
254
256
  const of = property.of;
255
257
  const resolvedProperties: ResolvedProperty[] = Array.isArray(propertyValue)
256
- ? propertyValue.map((v: any, index: number) => resolveProperty({
257
- propertyKey: `${propertyKey}.${index}`,
258
- propertyOrBuilder: of,
259
- propertyValue: v,
260
- ...props,
261
- index
262
- })).filter(e => Boolean(e)) as ResolvedProperty[]
258
+ ? propertyValue.map((v: any, index: number) => {
259
+ return resolveProperty({
260
+ propertyKey: `${propertyKey}.${index}`,
261
+ propertyOrBuilder: of,
262
+ ignoreMissingFields,
263
+ ...props,
264
+ index
265
+ });
266
+ }).filter(e => Boolean(e)) as ResolvedProperty[]
263
267
  : [];
264
268
  const ofProperty = resolveProperty({
265
- propertyKey: `${propertyKey}`,
266
269
  propertyOrBuilder: of,
267
- propertyValue: undefined,
270
+ ignoreMissingFields,
268
271
  ...props
269
272
  });
270
- if (!ofProperty)
273
+ if (!ofProperty && !ignoreMissingFields)
271
274
  throw Error("When using a property builder as the 'of' prop of an ArrayProperty, you must return a valid child property")
272
275
  return {
273
276
  ...property,
@@ -287,14 +290,15 @@ export function resolveArrayProperty<T extends any[], M>({
287
290
  return resolveProperty({
288
291
  propertyKey: `${propertyKey}.${index}`,
289
292
  propertyOrBuilder: childProperty,
290
- propertyValue,
293
+ ignoreMissingFields,
291
294
  ...props
292
295
  });
293
296
  }).filter(e => Boolean(e)) as ResolvedProperty[]
294
297
  : [];
295
298
  const properties = resolveProperties<any>({
299
+ propertyKey,
296
300
  properties: property.oneOf.properties,
297
- propertyValue: undefined,
301
+ ignoreMissingFields,
298
302
  ...props
299
303
  });
300
304
  return {
@@ -325,12 +329,13 @@ export function resolveArrayProperty<T extends any[], M>({
325
329
  * @param value
326
330
  */
327
331
  export function resolveProperties<M extends Record<string, any>>({
332
+ propertyKey,
328
333
  properties,
329
- propertyValue,
334
+ ignoreMissingFields,
330
335
  ...props
331
336
  }: {
337
+ propertyKey?: string,
332
338
  properties: PropertiesOrBuilders<M>,
333
- propertyValue: unknown,
334
339
  values?: Partial<M>,
335
340
  previousValues?: Partial<M>,
336
341
  path?: string,
@@ -338,14 +343,14 @@ export function resolveProperties<M extends Record<string, any>>({
338
343
  index?: number,
339
344
  fromBuilder?: boolean;
340
345
  fields?: Record<string, PropertyConfig>;
346
+ ignoreMissingFields?: boolean;
341
347
  }): ResolvedProperties<M> {
342
348
  return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
343
349
  .map(([key, property]) => {
344
- const thisPropertyValue = propertyValue && typeof propertyValue === "object" ? getValueInPath(propertyValue, key) : undefined;
345
350
  const childResolvedProperty = resolveProperty({
346
- propertyKey: key,
351
+ propertyKey: propertyKey ? `${propertyKey}.${key}` : undefined,
347
352
  propertyOrBuilder: property,
348
- propertyValue: thisPropertyValue,
353
+ ignoreMissingFields,
349
354
  ...props
350
355
  });
351
356
  if (!childResolvedProperty) return {};
@@ -367,7 +372,7 @@ export function resolvePropertyEnum(property: StringProperty | NumberProperty, f
367
372
  return {
368
373
  ...property,
369
374
  resolved: true,
370
- enumValues: enumToObjectEntries(property.enumValues)?.filter((value) => value && value.id && value.label) ?? [],
375
+ enumValues: enumToObjectEntries(property.enumValues)?.filter((value) => value && (value.id || value.id === 0) && value.label) ?? [],
371
376
  fromBuilder: fromBuilder ?? false
372
377
  }
373
378
  }
@@ -7,15 +7,28 @@ import {
7
7
  } from "../types";
8
8
  import { randomString } from "./strings";
9
9
 
10
- 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> {
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
+
21
+ export async function resolveStorageFilenameString<M extends object>(
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
  }
@@ -14,7 +14,7 @@ import {
14
14
  import { useCallback, useEffect, useState } from "react";
15
15
  import { PreviewSize } from "../preview";
16
16
  import { randomString } from "./strings";
17
- import { resolveFilenameString, resolveStoragePathString } from "./storage";
17
+ import { resolveStorageFilenameString, resolveStoragePathString } from "./storage";
18
18
 
19
19
  /**
20
20
  * Internal representation of an item in the storage
@@ -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 resolveStorageFilenameString({
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,
@@ -17,6 +17,7 @@ export function printChanged(props: any, prev: any, path: string | undefined = "
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,3 +0,0 @@
1
- export declare function PropertyIdCopyTooltipContent({ propertyId }: {
2
- propertyId: string;
3
- }): import("react/jsx-runtime").JSX.Element;
@@ -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,9 +0,0 @@
1
- import { FieldProps } from "../../types";
2
- /**
3
- * Render a markdown field that allows edition and seeing the preview.
4
- *
5
- * This is one of the internal components that get mapped natively inside forms
6
- * and tables to the specified properties.
7
- * @group Form fields
8
- */
9
- export declare function MarkdownFieldBinding({ propertyKey, value, setValue, error, showError, disabled, autoFocus, touched, property, tableMode, includeDescription, context }: FieldProps<string>): 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;