@firecms/core 3.0.0-beta.10 → 3.0.0-beta.12

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 (267) hide show
  1. package/dist/components/ArrayContainer.d.ts +22 -6
  2. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
  3. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  4. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +17 -3
  5. package/dist/components/EntityCollectionTable/index.d.ts +1 -1
  6. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
  7. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
  8. package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
  9. package/dist/components/SelectableTable/SelectableTable.d.ts +12 -2
  10. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
  11. package/dist/components/UnsavedChangesDialog.d.ts +8 -0
  12. package/dist/components/VirtualTable/VirtualTableProps.d.ts +13 -0
  13. package/dist/components/common/default_entity_actions.d.ts +0 -2
  14. package/dist/components/common/index.d.ts +1 -1
  15. package/dist/components/common/useColumnsIds.d.ts +1 -0
  16. package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
  17. package/dist/components/common/useDebouncedCallback.d.ts +1 -0
  18. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  19. package/dist/contexts/BreacrumbsContext.d.ts +8 -0
  20. package/dist/core/EntityEditView.d.ts +30 -22
  21. package/dist/core/EntityEditViewFormActions.d.ts +2 -0
  22. package/dist/core/FireCMS.d.ts +1 -1
  23. package/dist/core/FireCMSRouter.d.ts +4 -0
  24. package/dist/core/NavigationRoutes.d.ts +0 -1
  25. package/dist/core/SideDialogs.d.ts +4 -2
  26. package/dist/core/index.d.ts +2 -1
  27. package/dist/form/EntityForm.d.ts +45 -0
  28. package/dist/form/EntityFormActions.d.ts +17 -0
  29. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  30. package/dist/form/components/FormEntry.d.ts +6 -0
  31. package/dist/form/components/FormLayout.d.ts +5 -0
  32. package/dist/form/components/index.d.ts +2 -1
  33. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  34. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  35. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
  39. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  40. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -2
  41. package/dist/form/index.d.ts +16 -16
  42. package/dist/hooks/data/delete.d.ts +4 -4
  43. package/dist/hooks/data/save.d.ts +3 -3
  44. package/dist/hooks/data/useCollectionFetch.d.ts +1 -1
  45. package/dist/hooks/data/useEntityFetch.d.ts +4 -3
  46. package/dist/hooks/useAuthController.d.ts +1 -1
  47. package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
  48. package/dist/hooks/useBuildNavigationController.d.ts +7 -4
  49. package/dist/hooks/useFireCMSContext.d.ts +1 -1
  50. package/dist/hooks/useModeController.d.ts +1 -2
  51. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  52. package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
  53. package/dist/index.es.js +17032 -12909
  54. package/dist/index.es.js.map +1 -1
  55. package/dist/index.umd.js +17019 -12898
  56. package/dist/index.umd.js.map +1 -1
  57. package/dist/internal/useBuildSideEntityController.d.ts +2 -2
  58. package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
  59. package/dist/preview/PropertyPreviewProps.d.ts +1 -1
  60. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  61. package/dist/preview/util.d.ts +3 -3
  62. package/dist/routes/CustomCMSRoute.d.ts +4 -0
  63. package/dist/routes/FireCMSRoute.d.ts +1 -0
  64. package/dist/routes/HomePageRoute.d.ts +3 -0
  65. package/dist/types/auth.d.ts +7 -9
  66. package/dist/types/collections.d.ts +44 -23
  67. package/dist/types/datasource.d.ts +2 -6
  68. package/dist/types/dialogs_controller.d.ts +7 -3
  69. package/dist/types/entities.d.ts +1 -1
  70. package/dist/types/entity_actions.d.ts +14 -4
  71. package/dist/types/entity_callbacks.d.ts +16 -16
  72. package/dist/types/export_import.d.ts +4 -4
  73. package/dist/types/fields.d.ts +27 -4
  74. package/dist/types/firecms.d.ts +2 -2
  75. package/dist/types/firecms_context.d.ts +1 -1
  76. package/dist/types/navigation.d.ts +29 -12
  77. package/dist/types/permissions.d.ts +4 -4
  78. package/dist/types/plugins.d.ts +9 -8
  79. package/dist/types/properties.d.ts +18 -3
  80. package/dist/types/property_config.d.ts +0 -2
  81. package/dist/types/side_entity_controller.d.ts +6 -1
  82. package/dist/types/user.d.ts +1 -0
  83. package/dist/util/builders.d.ts +3 -3
  84. package/dist/util/entities.d.ts +1 -1
  85. package/dist/util/entity_actions.d.ts +2 -0
  86. package/dist/util/entity_cache.d.ts +23 -0
  87. package/dist/util/icon_synonyms.d.ts +0 -1
  88. package/dist/util/icons.d.ts +3 -1
  89. package/dist/util/index.d.ts +1 -0
  90. package/dist/util/navigation_from_path.d.ts +6 -1
  91. package/dist/util/navigation_utils.d.ts +12 -1
  92. package/dist/util/objects.d.ts +1 -0
  93. package/dist/util/permissions.d.ts +4 -4
  94. package/dist/util/property_utils.d.ts +2 -2
  95. package/dist/util/resolutions.d.ts +12 -7
  96. package/package.json +129 -125
  97. package/src/app/Scaffold.tsx +4 -4
  98. package/src/components/ArrayContainer.tsx +115 -34
  99. package/src/components/CircularProgressCenter.tsx +1 -1
  100. package/src/components/ConfirmationDialog.tsx +2 -2
  101. package/src/components/DeleteEntityDialog.tsx +10 -19
  102. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +44 -20
  103. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +23 -17
  104. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +20 -3
  105. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +6 -4
  106. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +8 -9
  107. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -11
  108. package/src/components/EntityCollectionTable/index.tsx +1 -1
  109. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
  110. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -5
  111. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +2 -2
  112. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +77 -73
  113. package/src/components/EntityCollectionView/EntityCollectionView.tsx +90 -49
  114. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -2
  115. package/src/components/EntityCollectionView/useSelectionController.tsx +5 -4
  116. package/src/components/EntityPreview.tsx +39 -30
  117. package/src/components/EntityView.tsx +5 -5
  118. package/src/components/ErrorView.tsx +3 -3
  119. package/src/components/HomePage/DefaultHomePage.tsx +1 -0
  120. package/src/components/HomePage/FavouritesView.tsx +6 -11
  121. package/src/components/HomePage/NavigationCard.tsx +1 -1
  122. package/src/components/HomePage/NavigationCardBinding.tsx +4 -9
  123. package/src/components/HomePage/NavigationGroup.tsx +1 -1
  124. package/src/components/NotFoundPage.tsx +2 -2
  125. package/src/components/PropertyConfigBadge.tsx +1 -1
  126. package/src/components/PropertyIdCopyTooltip.tsx +3 -4
  127. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +13 -8
  128. package/src/components/SelectableTable/SelectableTable.tsx +20 -5
  129. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +4 -2
  130. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +10 -8
  131. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +7 -5
  132. package/src/components/UnsavedChangesDialog.tsx +42 -0
  133. package/src/components/VirtualTable/VirtualTable.tsx +19 -2
  134. package/src/components/VirtualTable/VirtualTableHeader.tsx +8 -8
  135. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
  136. package/src/components/VirtualTable/VirtualTableProps.tsx +15 -0
  137. package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
  138. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  139. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +1 -1
  140. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +2 -0
  141. package/src/components/common/default_entity_actions.tsx +26 -37
  142. package/src/components/common/index.ts +1 -1
  143. package/src/components/common/useColumnsIds.tsx +1 -1
  144. package/src/components/common/useDataSourceTableController.tsx +420 -0
  145. package/src/components/common/useDebouncedCallback.tsx +20 -0
  146. package/src/components/common/useScrollRestoration.tsx +68 -0
  147. package/src/contexts/BreacrumbsContext.tsx +38 -0
  148. package/src/contexts/DialogsProvider.tsx +3 -2
  149. package/src/contexts/ModeController.tsx +1 -3
  150. package/src/contexts/SnackbarProvider.tsx +2 -0
  151. package/src/core/DefaultAppBar.tsx +56 -25
  152. package/src/core/DefaultDrawer.tsx +11 -9
  153. package/src/core/DrawerNavigationItem.tsx +4 -4
  154. package/src/core/EntityEditView.tsx +282 -1006
  155. package/src/core/EntityEditViewFormActions.tsx +199 -0
  156. package/src/core/EntitySidePanel.tsx +85 -15
  157. package/src/core/FireCMS.tsx +12 -9
  158. package/src/core/FireCMSRouter.tsx +17 -0
  159. package/src/core/NavigationRoutes.tsx +23 -32
  160. package/src/core/SideDialogs.tsx +21 -12
  161. package/src/core/field_configs.tsx +4 -4
  162. package/src/core/index.tsx +4 -2
  163. package/src/form/EntityForm.tsx +774 -0
  164. package/src/form/EntityFormActions.tsx +169 -0
  165. package/src/form/PropertyFieldBinding.tsx +39 -30
  166. package/src/form/components/CustomIdField.tsx +2 -0
  167. package/src/form/components/FormEntry.tsx +22 -0
  168. package/src/form/components/FormLayout.tsx +16 -0
  169. package/src/form/components/LabelWithIcon.tsx +6 -3
  170. package/src/form/components/StorageItemPreview.tsx +3 -3
  171. package/src/form/components/StorageUploadProgress.tsx +1 -1
  172. package/src/form/components/index.tsx +2 -1
  173. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +7 -6
  174. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +20 -12
  175. package/src/form/field_bindings/BlockFieldBinding.tsx +45 -25
  176. package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -1
  177. package/src/form/field_bindings/KeyValueFieldBinding.tsx +10 -7
  178. package/src/form/field_bindings/MapFieldBinding.tsx +69 -52
  179. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +9 -6
  180. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +1 -1
  181. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  182. package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -5
  183. package/src/form/field_bindings/RepeatFieldBinding.tsx +30 -22
  184. package/src/form/field_bindings/SelectFieldBinding.tsx +6 -5
  185. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +7 -5
  186. package/src/form/field_bindings/SwitchFieldBinding.tsx +26 -25
  187. package/src/form/field_bindings/TextFieldBinding.tsx +4 -3
  188. package/src/form/index.tsx +16 -32
  189. package/src/form/validation.ts +12 -6
  190. package/src/hooks/data/delete.ts +4 -4
  191. package/src/hooks/data/save.ts +8 -9
  192. package/src/hooks/data/useCollectionFetch.tsx +3 -3
  193. package/src/hooks/data/useEntityFetch.tsx +10 -6
  194. package/src/hooks/useAuthController.tsx +1 -1
  195. package/src/hooks/useBreadcrumbsController.tsx +31 -0
  196. package/src/hooks/useBuildModeController.tsx +15 -28
  197. package/src/hooks/useBuildNavigationController.tsx +74 -29
  198. package/src/hooks/useFireCMSContext.tsx +5 -5
  199. package/src/hooks/useLargeLayout.tsx +0 -35
  200. package/src/hooks/useModeController.tsx +1 -2
  201. package/src/hooks/useResolvedNavigationFrom.tsx +9 -11
  202. package/src/hooks/useValidateAuthenticator.tsx +3 -3
  203. package/src/internal/useBuildDataSource.ts +1 -1
  204. package/src/internal/useBuildSideDialogsController.tsx +3 -2
  205. package/src/internal/useBuildSideEntityController.tsx +124 -83
  206. package/src/internal/useUnsavedChangesDialog.tsx +127 -93
  207. package/src/preview/PropertyPreview.tsx +11 -11
  208. package/src/preview/PropertyPreviewProps.tsx +1 -1
  209. package/src/preview/components/BooleanPreview.tsx +1 -1
  210. package/src/preview/components/EmptyValue.tsx +1 -1
  211. package/src/preview/components/EnumValuesChip.tsx +1 -1
  212. package/src/preview/components/ImagePreview.tsx +5 -6
  213. package/src/preview/components/UrlComponentPreview.tsx +20 -21
  214. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  215. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -2
  216. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +2 -2
  217. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +1 -1
  218. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
  219. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -2
  220. package/src/preview/property_previews/MapPropertyPreview.tsx +7 -6
  221. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +12 -12
  222. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  223. package/src/preview/util.ts +10 -10
  224. package/src/routes/CustomCMSRoute.tsx +21 -0
  225. package/src/routes/FireCMSRoute.tsx +235 -0
  226. package/src/routes/HomePageRoute.tsx +17 -0
  227. package/src/types/auth.tsx +8 -12
  228. package/src/types/collections.ts +52 -26
  229. package/src/types/datasource.ts +2 -6
  230. package/src/types/dialogs_controller.tsx +7 -3
  231. package/src/types/entities.ts +1 -1
  232. package/src/types/entity_actions.tsx +16 -4
  233. package/src/types/entity_callbacks.ts +18 -18
  234. package/src/types/export_import.ts +4 -4
  235. package/src/types/fields.tsx +33 -4
  236. package/src/types/firecms.tsx +2 -2
  237. package/src/types/firecms_context.tsx +1 -1
  238. package/src/types/navigation.ts +36 -16
  239. package/src/types/permissions.ts +5 -5
  240. package/src/types/plugins.tsx +9 -8
  241. package/src/types/properties.ts +21 -3
  242. package/src/types/property_config.tsx +0 -2
  243. package/src/types/side_dialogs_controller.tsx +2 -0
  244. package/src/types/side_entity_controller.tsx +6 -1
  245. package/src/types/user.ts +2 -0
  246. package/src/util/builders.ts +10 -8
  247. package/src/util/entities.ts +3 -1
  248. package/src/util/entity_actions.ts +28 -0
  249. package/src/util/entity_cache.ts +204 -0
  250. package/src/util/icon_list.ts +1 -0
  251. package/src/util/icon_synonyms.ts +0 -1
  252. package/src/util/icons.tsx +12 -8
  253. package/src/util/index.ts +1 -0
  254. package/src/util/join_collections.ts +3 -0
  255. package/src/util/navigation_from_path.ts +13 -6
  256. package/src/util/navigation_utils.ts +53 -1
  257. package/src/util/objects.ts +24 -1
  258. package/src/util/parent_references_from_path.ts +3 -3
  259. package/src/util/permissions.ts +8 -8
  260. package/src/util/property_utils.tsx +10 -3
  261. package/src/util/references.ts +8 -2
  262. package/src/util/resolutions.ts +34 -13
  263. package/src/util/useStorageUploadController.tsx +40 -22
  264. package/dist/form/components/FormikArrayContainer.d.ts +0 -19
  265. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
  266. package/src/form/components/FormikArrayContainer.tsx +0 -47
  267. /package/src/util/{common.tsx → common.ts} +0 -0
@@ -4,7 +4,7 @@ import { EnumType, FieldProps } from "../../types";
4
4
  import { FieldHelperText, LabelWithIcon } from "../components";
5
5
  import { EnumValuesChip } from "../../preview";
6
6
  import { getIconForProperty, resolveEnumValues } from "../../util";
7
- import { ClearIcon, cls, IconButton, Select, SelectItem } from "@firecms/ui";
7
+ import { CloseIcon, cls, IconButton, Select, SelectItem } from "@firecms/ui";
8
8
  import { useClearRestoreValue } from "../useClearRestoreValue";
9
9
  import { PropertyIdCopyTooltip } from "../../components";
10
10
 
@@ -29,7 +29,7 @@ export function SelectFieldBinding<T extends EnumType>({
29
29
  touched,
30
30
  property,
31
31
  includeDescription,
32
- size = "medium"
32
+ size = "large"
33
33
  }: SelectProps<T>) {
34
34
 
35
35
  const enumValues = resolveEnumValues(property.enumValues ?? []);
@@ -50,9 +50,10 @@ export function SelectFieldBinding<T extends EnumType>({
50
50
  <>
51
51
 
52
52
  <Select
53
- size={size === "medium" ? "medium" : "small"}
54
53
  value={value !== undefined && value != null ? value.toString() : ""}
55
54
  disabled={disabled}
55
+ size={size}
56
+ fullWidth={true}
56
57
  position="item-aligned"
57
58
  inputClassName={cls("w-full")}
58
59
  label={
@@ -61,13 +62,13 @@ export function SelectFieldBinding<T extends EnumType>({
61
62
  icon={getIconForProperty(property, "small")}
62
63
  required={property.validation?.required}
63
64
  title={property.name}
64
- className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}
65
+ className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5 my-0"}
65
66
  />
66
67
  </PropertyIdCopyTooltip>}
67
68
  endAdornment={
68
69
  property.clearable && <IconButton
69
70
  onClick={handleClearClick}>
70
- <ClearIcon/>
71
+ <CloseIcon/>
71
72
  </IconButton>
72
73
  }
73
74
  onValueChange={(updatedValue: string) => {
@@ -28,7 +28,7 @@ import {
28
28
  import { useClearRestoreValue } from "../useClearRestoreValue";
29
29
 
30
30
  const dropZoneClasses = "box-border relative pt-[2px] items-center border border-transparent min-h-[254px] outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid";
31
- const disabledClasses = "border-dotted-gray"
31
+ const disabledClasses = fieldBackgroundDisabledMixin;
32
32
  const nonActiveDropClasses = fieldBackgroundHoverMixin
33
33
  const activeDropClasses = "pt-0 border-2 border-solid"
34
34
  const acceptDropClasses = "transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-2 border-solid border-green-500"
@@ -103,7 +103,7 @@ export function StorageUploadFieldBinding({
103
103
  icon={getIconForProperty(property, "small")}
104
104
  required={property.validation?.required}
105
105
  title={property.name}
106
- className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
106
+ className={"h-8text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
107
107
 
108
108
  <StorageUpload
109
109
  value={internalValue}
@@ -206,6 +206,7 @@ function FileDropComponent({
206
206
  className={cls(
207
207
  fieldBackgroundMixin,
208
208
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
209
+ disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : "",
209
210
  dropZoneClasses,
210
211
  multipleFilesSupported && internalValue.length ? "" : "flex",
211
212
  {
@@ -248,7 +249,7 @@ function FileDropComponent({
248
249
  metadata={metadata}
249
250
  storagePath={storagePathBuilder(entry.file)}
250
251
  onFileUploadComplete={onFileUploadComplete}
251
- imageSize={size === "medium" ? 220 : 118}
252
+ imageSize={size === "large" ? 220 : 118}
252
253
  simple={false}
253
254
  />
254
255
  );
@@ -285,7 +286,8 @@ function FileDropComponent({
285
286
  <div
286
287
  className="flex-grow min-h-[38px] box-border m-2 text-center">
287
288
  <Typography align={"center"}
288
- variant={"label"}>
289
+ variant={"label"}
290
+ className={disabled ? "text-surface-accent-600 dark:text-surface-accent-500" : ""}>
289
291
  {helpText}
290
292
  </Typography>
291
293
  </div>
@@ -339,7 +341,7 @@ export function StorageUpload({
339
341
  }
340
342
 
341
343
  const metadata: Record<string, unknown> | undefined = storage?.metadata;
342
- const size = multipleFilesSupported ? "small" : "medium";
344
+ const size = multipleFilesSupported ? "medium" : "large";
343
345
 
344
346
  const moveItem = useCallback((fromIndex: number, toIndex: number) => {
345
347
  if (!multipleFilesSupported) return;
@@ -16,18 +16,18 @@ type SwitchFieldProps = FieldProps<boolean>;
16
16
  * and tables to the specified properties.
17
17
  * @group Form fields
18
18
  */
19
- export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
20
- propertyKey,
21
- value,
22
- setValue,
23
- error,
24
- showError,
25
- autoFocus,
26
- disabled,
27
- size = "medium",
28
- property,
29
- includeDescription
30
- }: SwitchFieldProps, ref) {
19
+ export const SwitchFieldBinding = function SwitchFieldBinding({
20
+ propertyKey,
21
+ value,
22
+ setValue,
23
+ error,
24
+ showError,
25
+ autoFocus,
26
+ disabled,
27
+ size = "large",
28
+ property,
29
+ includeDescription
30
+ }: SwitchFieldProps) {
31
31
 
32
32
  useClearRestoreValue({
33
33
  property,
@@ -39,18 +39,19 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
39
39
  <>
40
40
 
41
41
  <PropertyIdCopyTooltip propertyKey={propertyKey}>
42
- <BooleanSwitchWithLabel
43
- value={value}
44
- onValueChange={(v) => setValue(v)}
45
- error={showError}
46
- label={<LabelWithIcon
47
- icon={getIconForProperty(property, "small")}
48
- required={property.validation?.required}
49
- title={property.name}/>}
50
- disabled={disabled}
51
- autoFocus={autoFocus}
52
- size={size}
53
- />
42
+ <BooleanSwitchWithLabel
43
+ value={value}
44
+ onValueChange={(v) => setValue(v)}
45
+ error={showError}
46
+ className={property.widthPercentage !== undefined ? "mt-8" : undefined}
47
+ label={<LabelWithIcon
48
+ icon={getIconForProperty(property, "small")}
49
+ required={property.validation?.required}
50
+ title={property.name}/>}
51
+ disabled={disabled}
52
+ autoFocus={autoFocus}
53
+ size={size}
54
+ />
54
55
  </PropertyIdCopyTooltip>
55
56
 
56
57
  <FieldHelperText includeDescription={includeDescription}
@@ -61,4 +62,4 @@ export const SwitchFieldBinding = React.forwardRef(function SwitchFieldBinding({
61
62
  </>
62
63
 
63
64
  );
64
- });
65
+ };
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from "react";
2
2
 
3
- import { ClearIcon, Collapse, IconButton, TextField } from "@firecms/ui";
3
+ import { CloseIcon, Collapse, IconButton, TextField } from "@firecms/ui";
4
4
  import { FieldProps, PreviewType } from "../../types";
5
5
  import { FieldHelperText, LabelWithIcon } from "../components";
6
6
  import { getIconForProperty } from "../../util";
@@ -28,7 +28,7 @@ export function TextFieldBinding<T extends string | number>({
28
28
  autoFocus,
29
29
  property,
30
30
  includeDescription,
31
- size = "medium"
31
+ size = "large"
32
32
  }: TextFieldBindingProps<T>) {
33
33
 
34
34
  let multiline: boolean | undefined;
@@ -75,6 +75,7 @@ export function TextFieldBinding<T extends string | number>({
75
75
  value={value}
76
76
  onChange={onChange}
77
77
  autoFocus={autoFocus}
78
+ className={property.widthPercentage !== undefined ? "mt-8" : undefined}
78
79
  label={<LabelWithIcon
79
80
  icon={getIconForProperty(property, "small")}
80
81
  required={property.validation?.required}
@@ -85,7 +86,7 @@ export function TextFieldBinding<T extends string | number>({
85
86
  endAdornment={
86
87
  property.clearable && <IconButton
87
88
  onClick={handleClearClick}>
88
- <ClearIcon/>
89
+ <CloseIcon/>
89
90
  </IconButton>
90
91
  }
91
92
  error={showError ? error : undefined}
@@ -1,36 +1,20 @@
1
- import { SelectFieldBinding } from "./field_bindings/SelectFieldBinding";
2
- import { MultiSelectFieldBinding } from "./field_bindings/MultiSelectFieldBinding";
3
- import { ArrayOfReferencesFieldBinding } from "./field_bindings/ArrayOfReferencesFieldBinding";
4
- import { StorageUploadFieldBinding } from "./field_bindings/StorageUploadFieldBinding";
5
- import { TextFieldBinding } from "./field_bindings/TextFieldBinding";
6
- import { SwitchFieldBinding } from "./field_bindings/SwitchFieldBinding";
7
- import { DateTimeFieldBinding } from "./field_bindings/DateTimeFieldBinding";
8
- import { ReferenceFieldBinding } from "./field_bindings/ReferenceFieldBinding";
9
- import { MapFieldBinding } from "./field_bindings/MapFieldBinding";
10
- import { KeyValueFieldBinding } from "./field_bindings/KeyValueFieldBinding";
11
- import { RepeatFieldBinding } from "./field_bindings/RepeatFieldBinding";
12
- import { BlockFieldBinding } from "./field_bindings/BlockFieldBinding";
13
- import { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding";
14
- import { MarkdownEditorFieldBinding } from "./field_bindings/MarkdownEditorFieldBinding";
15
- import { ArrayCustomShapedFieldBinding } from "./field_bindings/ArrayCustomShapedFieldBinding";
1
+ export * from "./EntityForm";
16
2
 
17
- export {
18
- ArrayCustomShapedFieldBinding,
19
- RepeatFieldBinding,
20
- MultiSelectFieldBinding,
21
- ArrayOfReferencesFieldBinding,
22
- BlockFieldBinding,
23
- DateTimeFieldBinding,
24
- ReadOnlyFieldBinding,
25
- MapFieldBinding,
26
- KeyValueFieldBinding,
27
- ReferenceFieldBinding,
28
- SelectFieldBinding,
29
- StorageUploadFieldBinding,
30
- SwitchFieldBinding,
31
- MarkdownEditorFieldBinding,
32
- TextFieldBinding
33
- };
3
+ export { SelectFieldBinding } from "./field_bindings/SelectFieldBinding";
4
+ export { MultiSelectFieldBinding } from "./field_bindings/MultiSelectFieldBinding";
5
+ export { ArrayOfReferencesFieldBinding } from "./field_bindings/ArrayOfReferencesFieldBinding";
6
+ export { StorageUploadFieldBinding } from "./field_bindings/StorageUploadFieldBinding";
7
+ export { TextFieldBinding } from "./field_bindings/TextFieldBinding";
8
+ export { SwitchFieldBinding } from "./field_bindings/SwitchFieldBinding";
9
+ export { DateTimeFieldBinding } from "./field_bindings/DateTimeFieldBinding";
10
+ export { ReferenceFieldBinding } from "./field_bindings/ReferenceFieldBinding";
11
+ export { MapFieldBinding } from "./field_bindings/MapFieldBinding";
12
+ export { KeyValueFieldBinding } from "./field_bindings/KeyValueFieldBinding";
13
+ export { RepeatFieldBinding } from "./field_bindings/RepeatFieldBinding";
14
+ export { BlockFieldBinding } from "./field_bindings/BlockFieldBinding";
15
+ export { ReadOnlyFieldBinding } from "./field_bindings/ReadOnlyFieldBinding";
16
+ export { MarkdownEditorFieldBinding } from "./field_bindings/MarkdownEditorFieldBinding";
17
+ export { ArrayCustomShapedFieldBinding } from "./field_bindings/ArrayCustomShapedFieldBinding";
34
18
 
35
19
  export * from "./components";
36
20
 
@@ -90,11 +90,11 @@ export function mapPropertyToYup<T extends CMSType>(propertyContext: PropertyCon
90
90
  }
91
91
 
92
92
  export function getYupMapObjectSchema({
93
- property,
94
- entityId,
95
- customFieldValidator,
96
- name
97
- }: PropertyContext<Record<string, any>>): ObjectSchema<any> {
93
+ property,
94
+ entityId,
95
+ customFieldValidator,
96
+ name
97
+ }: PropertyContext<Record<string, any>>): ObjectSchema<any> {
98
98
  const objectSchema: any = {};
99
99
  const validation = property.validation;
100
100
  if (property.properties)
@@ -159,7 +159,13 @@ function getYupStringSchema({
159
159
  if (validation.lowercase) collection = collection.lowercase();
160
160
  if (validation.uppercase) collection = collection.uppercase();
161
161
  if (property.email) collection = collection.email(`${property.name} must be an email`);
162
- if (property.url) collection = collection.url(`${property.name} must be a url`);
162
+ if (property.url) {
163
+ if (!property.storage || property.storage?.storeUrl) {
164
+ collection = collection.url(`${property.name} must be a url`);
165
+ } else {
166
+ console.warn(`Property ${property.name} has a url validation but its storage configuration is not set to store urls`);
167
+ }
168
+ }
163
169
  } else {
164
170
  collection = collection.notRequired().nullable(true);
165
171
  }
@@ -12,10 +12,10 @@ import {
12
12
  /**
13
13
  * @group Hooks and utilities
14
14
  */
15
- export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, UserType extends User = User> =
15
+ export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, USER extends User = User> =
16
16
  DeleteEntityProps<M>
17
17
  & {
18
- callbacks?: EntityCallbacks<M, UserType>;
18
+ callbacks?: EntityCallbacks<M, USER>;
19
19
  onDeleteSuccess?: (entity: Entity<M>) => void;
20
20
  onDeleteFailure?: (entity: Entity<M>, e: Error) => void;
21
21
  onPreDeleteHookError?: (entity: Entity<M>, e: Error) => void;
@@ -43,7 +43,7 @@ export type DeleteEntityWithCallbacksProps<M extends Record<string, any>, UserTy
43
43
  * @param context
44
44
  * @group Hooks and utilities
45
45
  */
46
- export async function deleteEntityWithCallbacks<M extends Record<string, any>, UserType extends User>({
46
+ export async function deleteEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
47
47
  dataSource,
48
48
  entity,
49
49
  collection,
@@ -56,7 +56,7 @@ export async function deleteEntityWithCallbacks<M extends Record<string, any>, U
56
56
  }: DeleteEntityWithCallbacksProps<M> & {
57
57
  collection: ResolvedEntityCollection<M>,
58
58
  dataSource: DataSource,
59
- context: FireCMSContext<UserType>
59
+ context: FireCMSContext<USER>
60
60
  }
61
61
  ): Promise<boolean> {
62
62
 
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  DataSource,
3
3
  Entity,
4
- EntityCallbacks,
5
4
  EntityCollection,
6
5
  EntityValues,
7
6
  FireCMSContext,
@@ -49,7 +48,7 @@ export type SaveEntityWithCallbacksProps<M extends Record<string, any>> =
49
48
  * @see useDataSource
50
49
  * @group Hooks and utilities
51
50
  */
52
- export async function saveEntityWithCallbacks<M extends Record<string, any>, UserType extends User>({
51
+ export async function saveEntityWithCallbacks<M extends Record<string, any>, USER extends User>({
53
52
  collection,
54
53
  path,
55
54
  entityId,
@@ -63,9 +62,9 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
63
62
  onPreSaveHookError,
64
63
  onSaveSuccessHookError
65
64
  }: SaveEntityWithCallbacksProps<M> & {
66
- collection: EntityCollection<M, UserType>,
65
+ collection: EntityCollection<M, USER>,
67
66
  dataSource: DataSource,
68
- context: FireCMSContext<UserType>,
67
+ context: FireCMSContext<USER>,
69
68
  }
70
69
  ): Promise<void> {
71
70
 
@@ -76,7 +75,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
76
75
 
77
76
  const customizationController = context.customizationController;
78
77
 
79
- const resolvedPath = context.navigation.resolveAliasesFrom(path);
78
+ const resolvedPath = context.navigation.resolveIdsFrom(path);
80
79
 
81
80
  const callbacks = collection.callbacks;
82
81
  if (callbacks?.onPreSave) {
@@ -86,7 +85,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
86
85
  path,
87
86
  values: previousValues as EntityValues<M>,
88
87
  entityId,
89
- fields: customizationController.propertyConfigs
88
+ propertyConfigs: customizationController.propertyConfigs
90
89
  });
91
90
  updatedValues = await callbacks.onPreSave({
92
91
  collection: resolvedCollection,
@@ -108,7 +107,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
108
107
  updatedValues = values;
109
108
  }
110
109
 
111
- console.log("Saving entity", {
110
+ console.debug("Saving entity", {
112
111
  entityId,
113
112
  updatedValues,
114
113
  collection
@@ -128,7 +127,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
128
127
  path,
129
128
  values: updatedValues as EntityValues<M>,
130
129
  entityId,
131
- fields: customizationController.propertyConfigs
130
+ propertyConfigs: customizationController.propertyConfigs
132
131
  });
133
132
  callbacks.onSaveSuccess({
134
133
  collection: resolvedCollection,
@@ -157,7 +156,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
157
156
  path,
158
157
  values: updatedValues as EntityValues<M>,
159
158
  entityId,
160
- fields: customizationController.propertyConfigs
159
+ propertyConfigs: customizationController.propertyConfigs
161
160
  });
162
161
  callbacks.onSaveFailure({
163
162
  collection: resolvedCollection,
@@ -60,7 +60,7 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
60
60
  * @param searchString
61
61
  * @group Hooks and utilities
62
62
  */
63
- export function useCollectionFetch<M extends Record<string, any>, UserType extends User>(
63
+ export function useCollectionFetch<M extends Record<string, any>, USER extends User>(
64
64
  {
65
65
  path: inputPath,
66
66
  collection,
@@ -73,12 +73,12 @@ export function useCollectionFetch<M extends Record<string, any>, UserType exten
73
73
  const dataSource = useDataSource(collection);
74
74
  const navigationController = useNavigationController();
75
75
 
76
- const path = navigationController.resolveAliasesFrom(inputPath);
76
+ const path = navigationController.resolveIdsFrom(inputPath);
77
77
 
78
78
  const sortByProperty = sortBy ? sortBy[0] : undefined;
79
79
  const currentSort = sortBy ? sortBy[1] : undefined;
80
80
 
81
- const context: FireCMSContext<UserType> = useFireCMSContext();
81
+ const context: FireCMSContext<USER> = useFireCMSContext();
82
82
 
83
83
  const [data, setData] = useState<Entity<M>[]>([]);
84
84
 
@@ -7,10 +7,11 @@ import { useFireCMSContext } from "../useFireCMSContext";
7
7
  /**
8
8
  * @group Hooks and utilities
9
9
  */
10
- export interface EntityFetchProps<M extends Record<string, any>, UserType extends User = User> {
10
+ export interface EntityFetchProps<M extends Record<string, any>, USER extends User = User> {
11
11
  path: string;
12
12
  entityId?: string;
13
- collection: EntityCollection<M, UserType>;
13
+ databaseId?: string;
14
+ collection: EntityCollection<M, USER>;
14
15
  useCache?: boolean;
15
16
  }
16
17
 
@@ -35,20 +36,21 @@ const CACHE: Record<string, Entity<any> | undefined> = {};
35
36
  * @group Hooks and utilities
36
37
  */
37
38
 
38
- export function useEntityFetch<M extends Record<string, any>, UserType extends User>(
39
+ export function useEntityFetch<M extends Record<string, any>, USER extends User>(
39
40
  {
40
41
  path: inputPath,
41
42
  entityId,
42
43
  collection,
44
+ databaseId,
43
45
  useCache = false
44
- }: EntityFetchProps<M, UserType>): EntityFetchResult<M> {
46
+ }: EntityFetchProps<M, USER>): EntityFetchResult<M> {
45
47
 
46
48
  const dataSource = useDataSource(collection);
47
49
  const navigationController = useNavigationController();
48
50
 
49
- const path = navigationController.resolveAliasesFrom(inputPath);
51
+ const path = navigationController.resolveIdsFrom(inputPath);
50
52
 
51
- const context: FireCMSContext<UserType> = useFireCMSContext();
53
+ const context: FireCMSContext<USER> = useFireCMSContext();
52
54
 
53
55
  const [entity, setEntity] = useState<Entity<M> | undefined>();
54
56
  const [dataLoading, setDataLoading] = useState<boolean>(true);
@@ -96,6 +98,7 @@ export function useEntityFetch<M extends Record<string, any>, UserType extends U
96
98
  return dataSource.listenEntity<M>({
97
99
  path,
98
100
  entityId,
101
+ databaseId,
99
102
  collection,
100
103
  onUpdate: onEntityUpdate,
101
104
  onError
@@ -104,6 +107,7 @@ export function useEntityFetch<M extends Record<string, any>, UserType extends U
104
107
  dataSource.fetchEntity<M>({
105
108
  path,
106
109
  entityId,
110
+ databaseId,
107
111
  collection
108
112
  })
109
113
  .then(onEntityUpdate)
@@ -11,4 +11,4 @@ import { AuthControllerContext } from "../contexts/AuthControllerContext";
11
11
  * @see AuthController
12
12
  * @group Hooks and utilities
13
13
  */
14
- export const useAuthController = <UserType extends User = User, AuthControllerType extends AuthController<UserType> = AuthController<UserType>>(): AuthControllerType => useContext(AuthControllerContext) as AuthControllerType;
14
+ export const useAuthController = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): AuthControllerType => useContext(AuthControllerContext) as AuthControllerType;
@@ -0,0 +1,31 @@
1
+ import { useContext } from "react";
2
+ import { BreadcrumbContext } from "../contexts/BreacrumbsContext";
3
+
4
+ /**
5
+ * @group Hooks and utilities
6
+ */
7
+ export interface BreadcrumbsController {
8
+ breadcrumbs: BreadcrumbEntry[];
9
+ set: (props: {
10
+ breadcrumbs: BreadcrumbEntry[];
11
+ }) => void;
12
+ }
13
+
14
+ /**
15
+ * @group Hooks and utilities
16
+ */
17
+ export interface BreadcrumbEntry {
18
+ title: string;
19
+ url: string;
20
+ }
21
+
22
+ /**
23
+ * Hook to retrieve the BreadcrumbsController.
24
+ *
25
+ * Consider that in order to use this hook you need to have a parent
26
+ * `FireCMS`
27
+ *
28
+ * @see BreadcrumbsController
29
+ * @group Hooks and utilities
30
+ */
31
+ export const useBreadcrumbsController = (): BreadcrumbsController => useContext(BreadcrumbContext);
@@ -16,7 +16,7 @@ export function useBuildModeController(): ModeController {
16
16
  }, []);
17
17
 
18
18
  const prefersDarkModeStorage: boolean | null = localStorage.getItem("prefers-dark-mode") != null ? localStorage.getItem("prefers-dark-mode") === "true" : null;
19
- const prefersDarkMode = prefersDarkModeStorage ?? prefersDarkModeQuery;
19
+ const prefersDarkMode = prefersDarkModeStorage ?? prefersDarkModeQuery();
20
20
  const [mode, setMode] = useState<"light" | "dark">(prefersDarkMode ? "dark" : "light");
21
21
 
22
22
  useEffect(() => {
@@ -24,43 +24,30 @@ export function useBuildModeController(): ModeController {
24
24
  setDocumentMode(prefersDarkMode ? "dark" : "light");
25
25
  }, [prefersDarkMode]);
26
26
 
27
- // color-scheme: dark;
28
- const setDarkMode = useCallback(() => {
29
- setMode("dark");
30
- setDocumentMode("dark");
31
- }, []);
32
-
33
- const setLightMode = useCallback(() => {
34
- setMode("light");
35
- setDocumentMode("light");
36
- }, []);
37
-
38
27
  const setDocumentMode = (mode: "light" | "dark") => {
39
28
  document.body.style.setProperty("color-scheme", mode);
40
29
  document.documentElement.dataset.theme = mode;
41
30
  };
42
31
 
43
- const toggleMode = useCallback(() => {
44
-
45
- const prefersDarkModeQueryResult = prefersDarkModeQuery();
32
+ const setModeInternal = useCallback((mode: "light" | "dark" | "system") => {
46
33
  if (mode === "light") {
47
- if (!prefersDarkModeQueryResult)
48
- localStorage.setItem("prefers-dark-mode", "true");
49
- else
50
- localStorage.removeItem("prefers-dark-mode");
51
- setDarkMode();
34
+ setDocumentMode("light");
35
+ localStorage.setItem("prefers-dark-mode", "false");
36
+ setMode("light");
37
+ } else if (mode === "dark") {
38
+ setDocumentMode("dark");
39
+ localStorage.setItem("prefers-dark-mode", "true");
40
+ setMode("dark");
52
41
  } else {
53
- if (prefersDarkModeQueryResult)
54
- localStorage.setItem("prefers-dark-mode", "false");
55
- else
56
- localStorage.removeItem("prefers-dark-mode");
57
- setLightMode();
42
+ const preferredMode = prefersDarkModeQuery() ? "dark" : "light";
43
+ setDocumentMode(preferredMode);
44
+ localStorage.removeItem("prefers-dark-mode");
45
+ setMode(preferredMode);
58
46
  }
59
- }, [mode, prefersDarkModeQuery]);
47
+ }, [prefersDarkModeQuery]);
60
48
 
61
49
  return {
62
50
  mode,
63
- setMode,
64
- toggleMode
51
+ setMode: setModeInternal
65
52
  };
66
53
  }