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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +2 -2
  2. package/dist/components/ClearFilterSortButton.d.ts +5 -0
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  5. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
  6. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
  7. package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
  8. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
  9. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
  10. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  11. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  12. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
  13. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
  14. package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
  15. package/dist/components/EntityPreview.d.ts +26 -7
  16. package/dist/components/EntityView.d.ts +11 -0
  17. package/dist/components/FieldCaption.d.ts +5 -0
  18. package/dist/components/FireCMSAppBar.d.ts +4 -2
  19. package/dist/components/HomePage/NavigationCard.d.ts +8 -0
  20. package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
  21. package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
  22. package/dist/components/HomePage/index.d.ts +3 -1
  23. package/dist/components/ReferenceWidget.d.ts +3 -1
  24. package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
  25. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  26. package/dist/components/VirtualTable/VirtualTableProps.d.ts +6 -7
  27. package/dist/components/VirtualTable/types.d.ts +3 -3
  28. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  29. package/dist/components/common/index.d.ts +1 -0
  30. package/dist/components/common/table_height.d.ts +5 -0
  31. package/dist/components/common/types.d.ts +4 -6
  32. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  33. package/dist/components/index.d.ts +5 -2
  34. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  35. package/dist/core/Drawer.d.ts +5 -12
  36. package/dist/core/DrawerNavigationItem.d.ts +9 -0
  37. package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
  38. package/dist/core/NavigationRoutes.d.ts +1 -1
  39. package/dist/core/Scaffold.d.ts +8 -12
  40. package/dist/core/index.d.ts +3 -4
  41. package/dist/form/EntityForm.d.ts +1 -1
  42. package/dist/form/components/ErrorFocus.d.ts +1 -1
  43. package/dist/form/components/StorageItemPreview.d.ts +3 -2
  44. package/dist/form/components/StorageUploadProgress.d.ts +1 -1
  45. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  46. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  47. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +4 -3
  48. package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
  49. package/dist/form/validation.d.ts +1 -1
  50. package/dist/hooks/data/delete.d.ts +2 -2
  51. package/dist/hooks/data/save.d.ts +2 -3
  52. package/dist/hooks/data/useDataSource.d.ts +2 -2
  53. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  54. package/dist/hooks/index.d.ts +2 -0
  55. package/dist/hooks/useBuildNavigationController.d.ts +6 -4
  56. package/dist/hooks/useProjectLog.d.ts +6 -2
  57. package/dist/hooks/useStorageSource.d.ts +2 -2
  58. package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
  59. package/dist/index.es.js +10496 -9945
  60. package/dist/index.es.js.map +1 -1
  61. package/dist/index.umd.js +5 -5
  62. package/dist/index.umd.js.map +1 -1
  63. package/dist/internal/useBuildDataSource.d.ts +1 -16
  64. package/dist/preview/PropertyPreview.d.ts +1 -1
  65. package/dist/preview/PropertyPreviewProps.d.ts +1 -4
  66. package/dist/preview/components/BooleanPreview.d.ts +5 -1
  67. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  68. package/dist/preview/components/ReferencePreview.d.ts +3 -8
  69. package/dist/types/analytics.d.ts +1 -1
  70. package/dist/types/auth.d.ts +37 -1
  71. package/dist/types/collections.d.ts +30 -6
  72. package/dist/types/datasource.d.ts +21 -14
  73. package/dist/types/entities.d.ts +5 -1
  74. package/dist/types/entity_actions.d.ts +14 -0
  75. package/dist/types/entity_callbacks.d.ts +2 -2
  76. package/dist/types/entity_overrides.d.ts +6 -0
  77. package/dist/types/index.d.ts +2 -1
  78. package/dist/types/navigation.d.ts +15 -14
  79. package/dist/types/permissions.d.ts +5 -1
  80. package/dist/types/plugins.d.ts +20 -20
  81. package/dist/types/properties.d.ts +12 -4
  82. package/dist/types/property_config.d.ts +2 -2
  83. package/dist/types/roles.d.ts +31 -0
  84. package/dist/types/storage.d.ts +11 -3
  85. package/dist/types/user.d.ts +5 -0
  86. package/dist/util/collections.d.ts +9 -1
  87. package/dist/util/entities.d.ts +1 -1
  88. package/dist/util/icon_synonyms.d.ts +1 -97
  89. package/dist/util/icons.d.ts +8 -2
  90. package/dist/util/navigation_utils.d.ts +2 -2
  91. package/dist/util/objects.d.ts +1 -1
  92. package/dist/util/permissions.d.ts +4 -4
  93. package/dist/util/references.d.ts +4 -2
  94. package/dist/util/resolutions.d.ts +14 -14
  95. package/dist/util/useTraceUpdate.d.ts +1 -0
  96. package/package.json +139 -119
  97. package/src/components/ClearFilterSortButton.tsx +41 -0
  98. package/src/components/DeleteEntityDialog.tsx +4 -4
  99. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -4
  100. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +276 -279
  101. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
  102. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +48 -45
  103. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  104. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +18 -17
  105. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -5
  106. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
  107. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
  108. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
  109. package/src/components/EntityCollectionView/EntityCollectionView.tsx +73 -72
  110. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
  111. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
  112. package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
  113. package/src/components/EntityPreview.tsx +209 -70
  114. package/src/components/EntityView.tsx +84 -0
  115. package/src/components/FieldCaption.tsx +14 -0
  116. package/src/components/FireCMSAppBar.tsx +40 -15
  117. package/src/components/HomePage/DefaultHomePage.tsx +15 -11
  118. package/src/components/HomePage/NavigationCard.tsx +69 -0
  119. package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
  120. package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
  121. package/src/components/HomePage/index.tsx +3 -1
  122. package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
  123. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
  124. package/src/components/ReferenceWidget.tsx +22 -12
  125. package/src/components/SearchIconsView.tsx +5 -5
  126. package/src/components/SelectableTable/SelectableTable.tsx +5 -3
  127. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
  128. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
  129. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -24
  130. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
  131. package/src/components/VirtualTable/VirtualTable.tsx +38 -29
  132. package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
  133. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
  134. package/src/components/VirtualTable/VirtualTableProps.tsx +7 -7
  135. package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
  136. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  137. package/src/components/VirtualTable/types.tsx +2 -3
  138. package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +11 -7
  139. package/src/components/common/index.ts +1 -0
  140. package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
  141. package/src/components/common/types.tsx +4 -6
  142. package/src/components/common/useColumnsIds.tsx +10 -2
  143. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
  144. package/src/components/common/useTableSearchHelper.ts +39 -9
  145. package/src/components/index.tsx +5 -2
  146. package/src/contexts/AuthControllerContext.tsx +1 -1
  147. package/src/core/Drawer.tsx +78 -103
  148. package/src/core/DrawerNavigationItem.tsx +62 -0
  149. package/src/core/{EntityView.tsx → EntityEditView.tsx} +27 -45
  150. package/src/core/EntitySidePanel.tsx +3 -3
  151. package/src/core/FireCMS.tsx +54 -43
  152. package/src/core/NavigationRoutes.tsx +11 -4
  153. package/src/core/Scaffold.tsx +80 -66
  154. package/src/core/field_configs.tsx +2 -3
  155. package/src/core/index.tsx +3 -4
  156. package/src/form/EntityForm.tsx +49 -33
  157. package/src/form/PropertyFieldBinding.tsx +0 -2
  158. package/src/form/components/StorageItemPreview.tsx +7 -5
  159. package/src/form/components/StorageUploadProgress.tsx +9 -8
  160. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +10 -12
  161. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
  162. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
  163. package/src/form/field_bindings/KeyValueFieldBinding.tsx +19 -19
  164. package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
  165. package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
  166. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +3 -3
  167. package/src/form/field_bindings/ReferenceFieldBinding.tsx +16 -13
  168. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
  169. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +18 -9
  170. package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
  171. package/src/form/validation.ts +3 -4
  172. package/src/hooks/data/delete.ts +3 -3
  173. package/src/hooks/data/save.ts +4 -2
  174. package/src/hooks/data/useCollectionFetch.tsx +1 -1
  175. package/src/hooks/data/useDataSource.tsx +8 -3
  176. package/src/hooks/data/useEntityFetch.tsx +4 -4
  177. package/src/hooks/index.tsx +3 -0
  178. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
  179. package/src/hooks/useBuildModeController.tsx +11 -5
  180. package/src/hooks/useBuildNavigationController.tsx +200 -83
  181. package/src/hooks/useProjectLog.tsx +17 -7
  182. package/src/hooks/useReferenceDialog.tsx +2 -2
  183. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  184. package/src/hooks/useStorageSource.tsx +7 -2
  185. package/src/hooks/useValidateAuthenticator.tsx +115 -0
  186. package/src/internal/useBuildDataSource.ts +54 -47
  187. package/src/internal/useBuildSideEntityController.tsx +88 -21
  188. package/src/preview/PropertyPreview.tsx +5 -15
  189. package/src/preview/PropertyPreviewProps.tsx +1 -11
  190. package/src/preview/components/BooleanPreview.tsx +19 -4
  191. package/src/preview/components/EnumValuesChip.tsx +2 -2
  192. package/src/preview/components/ReferencePreview.tsx +72 -165
  193. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  194. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
  195. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
  196. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  197. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
  198. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
  199. package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
  200. package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
  201. package/src/types/analytics.ts +1 -0
  202. package/src/types/auth.tsx +50 -1
  203. package/src/types/collections.ts +37 -6
  204. package/src/types/datasource.ts +24 -17
  205. package/src/types/entities.ts +9 -1
  206. package/src/types/entity_actions.tsx +17 -0
  207. package/src/types/entity_callbacks.ts +2 -2
  208. package/src/types/entity_overrides.tsx +7 -0
  209. package/src/types/firecms.tsx +0 -1
  210. package/src/types/index.ts +2 -1
  211. package/src/types/navigation.ts +17 -17
  212. package/src/types/permissions.ts +6 -1
  213. package/src/types/plugins.tsx +26 -28
  214. package/src/types/properties.ts +18 -6
  215. package/src/types/property_config.tsx +2 -2
  216. package/src/types/roles.ts +41 -0
  217. package/src/types/side_entity_controller.tsx +1 -0
  218. package/src/types/storage.ts +12 -3
  219. package/src/types/user.ts +7 -0
  220. package/src/util/collections.ts +22 -0
  221. package/src/util/entities.ts +1 -1
  222. package/src/util/enums.ts +1 -1
  223. package/src/util/icon_list.ts +2 -2
  224. package/src/util/icon_synonyms.ts +3 -99
  225. package/src/util/icons.tsx +11 -3
  226. package/src/util/navigation_utils.ts +6 -6
  227. package/src/util/objects.ts +8 -21
  228. package/src/util/permissions.ts +11 -8
  229. package/src/util/references.ts +36 -5
  230. package/src/util/resolutions.ts +32 -31
  231. package/src/util/strings.ts +2 -2
  232. package/src/util/useTraceUpdate.tsx +2 -1
  233. package/dist/components/VirtualTable/common.d.ts +0 -2
  234. package/dist/core/SideEntityView.d.ts +0 -7
  235. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  236. package/dist/internal/useLocaleConfig.d.ts +0 -1
  237. package/dist/types/appcheck.d.ts +0 -26
  238. package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
  239. package/src/core/SideEntityView.tsx +0 -38
  240. package/src/internal/useBuildCustomizationController.tsx +0 -5
  241. package/src/internal/useLocaleConfig.tsx +0 -18
  242. package/src/types/appcheck.ts +0 -29
@@ -0,0 +1,116 @@
1
+ import { useNavigate } from "react-router-dom";
2
+
3
+ import { useCustomizationController, useFireCMSContext } from "../../hooks";
4
+ import { PluginHomePageActionsProps, TopNavigationEntry } from "../../types";
5
+ import { IconForView } from "../../util";
6
+ import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
7
+ import { IconButton, StarBorderIcon, StarIcon } from "@firecms/ui";
8
+ import { NavigationCard } from "./NavigationCard";
9
+ import { SmallNavigationCard } from "./SmallNavigationCard";
10
+
11
+ /**
12
+ * This is the component used in the home page to render a card for each
13
+ * collection or view.
14
+ * @group Components
15
+ * @param view
16
+ * @param path
17
+ * @param collection
18
+ * @param url
19
+ * @param name
20
+ * @param description
21
+ * @param onClick
22
+ * @constructor
23
+ */
24
+ export function NavigationCardBinding({
25
+ path,
26
+ collection,
27
+ view,
28
+ url,
29
+ name,
30
+ description,
31
+ onClick,
32
+ type
33
+ }: TopNavigationEntry & {
34
+ onClick?: () => void
35
+ }) {
36
+
37
+ const userConfigurationPersistence = useUserConfigurationPersistence();
38
+ const collectionIcon = <IconForView collectionOrView={collection ?? view}/>;
39
+
40
+ const navigate = useNavigate();
41
+ const context = useFireCMSContext();
42
+ const customizationController = useCustomizationController();
43
+
44
+ const favourite = (userConfigurationPersistence?.favouritePaths ?? []).includes(path);
45
+
46
+ const actionsArray: React.ReactNode[] = userConfigurationPersistence
47
+ ? [
48
+ <IconButton
49
+ key={"favourite"}
50
+ onClick={(e) => {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ if (favourite) {
54
+ userConfigurationPersistence.setFavouritePaths(
55
+ userConfigurationPersistence.favouritePaths.filter(p => p !== path)
56
+ );
57
+ } else {
58
+ userConfigurationPersistence.setFavouritePaths(
59
+ [...userConfigurationPersistence.favouritePaths, path]
60
+ );
61
+ }
62
+ }}>
63
+ {
64
+ favourite
65
+ ? <StarIcon
66
+ size={18}
67
+ className={"text-secondary"}/>
68
+ : <StarBorderIcon
69
+ size={18}
70
+ className={"text-gray-400 dark:text-gray-500"}/>}
71
+ </IconButton>
72
+ ]
73
+ : [];
74
+
75
+ if (customizationController.plugins && collection) {
76
+ const actionProps: PluginHomePageActionsProps = {
77
+ path,
78
+ collection,
79
+ context
80
+ };
81
+ customizationController.plugins.forEach((plugin, i) => (
82
+ actionsArray.push(plugin.homePage?.CollectionActions
83
+ ? <plugin.homePage.CollectionActions
84
+ key={`actions_${i}`}
85
+ {...actionProps}
86
+ extraProps={plugin.homePage.extraProps}
87
+ />
88
+ : null
89
+ )))
90
+ }
91
+
92
+ const actions: React.ReactNode | undefined = <>
93
+ {actionsArray}
94
+ </>
95
+
96
+ if (type === "admin") {
97
+ return <SmallNavigationCard icon={collectionIcon}
98
+ name={name}
99
+ url={url}/>
100
+ }
101
+
102
+ return <NavigationCard
103
+ icon={collectionIcon}
104
+ name={name}
105
+ description={description}
106
+ actions={actions}
107
+ onClick={() => {
108
+ onClick?.();
109
+ navigate(url);
110
+ if (userConfigurationPersistence) {
111
+ userConfigurationPersistence.setRecentlyVisitedPaths(
112
+ [path, ...(userConfigurationPersistence.recentlyVisitedPaths ?? []).filter(p => p !== path)]
113
+ );
114
+ }
115
+ }}/>;
116
+ }
@@ -0,0 +1,45 @@
1
+ import { ArrowForwardIcon, cardClickableMixin, cardMixin, cls, focusedMixin, Typography, } from "@firecms/ui";
2
+
3
+ import { Link } from "react-router-dom";
4
+
5
+ export type SmallNavigationCardProps = {
6
+ name: string,
7
+ url: string;
8
+ icon: React.ReactElement;
9
+ };
10
+
11
+ export function SmallNavigationCard({
12
+ name,
13
+ url,
14
+ icon,
15
+ }: SmallNavigationCardProps) {
16
+
17
+ return (
18
+ <>
19
+
20
+ <Link
21
+ tabIndex={0}
22
+ className={cls(cardMixin,
23
+ cardClickableMixin,
24
+ focusedMixin,
25
+ "cursor-pointer flex flex-row items-center px-4 py-2 text-inherit dark:text-inherit visited:text-inherit visited:dark:text-inherit hover:text-inherit hover:dark:text-inherit ")}
26
+ to={url}
27
+ >
28
+
29
+ <div className="flex flex-row items-center flex-grow gap-2 ">
30
+ {icon}
31
+
32
+ <Typography gutterBottom variant="h5"
33
+ component="h2"
34
+ className="mb-0 ml-4">
35
+ {name}
36
+ </Typography>
37
+ </div>
38
+
39
+ <div className={"p-4"}>
40
+ <ArrowForwardIcon color="primary"/>
41
+ </div>
42
+ </Link>
43
+
44
+ </>);
45
+ }
@@ -1,3 +1,5 @@
1
1
  export * from "./DefaultHomePage";
2
- export * from "./NavigationCollectionCard";
2
+ export * from "./NavigationCardBinding";
3
3
  export * from "./NavigationGroup";
4
+ export * from "./NavigationCard";
5
+ export * from "./SmallNavigationCard";
@@ -1,4 +1,4 @@
1
- import { ContentPasteIcon, IconButton, Typography } from "@firecms/ui";
1
+ import { ContentCopyIcon, IconButton, Typography } from "@firecms/ui";
2
2
  import { useCallback, useState } from "react";
3
3
 
4
4
  export function PropertyIdCopyTooltipContent({ propertyId }: { propertyId: string }) {
@@ -12,9 +12,8 @@ export function PropertyIdCopyTooltipContent({ propertyId }: { propertyId: strin
12
12
  color={"disabled"}>{copied ? "Copied" : "Property ID"}</Typography>
13
13
  <Typography variant={"caption"} className={"text-white"}><code>{propertyId}</code></Typography>
14
14
  </div>
15
- {/* Copy to clipboard button*/}
16
15
  <IconButton size={"small"}>
17
- <ContentPasteIcon size={"smallest"}
16
+ <ContentCopyIcon size={"smallest"}
18
17
  className={"text-white"}
19
18
  onClick={useCallback(() => {
20
19
  navigator.clipboard.writeText(propertyId);
@@ -17,7 +17,7 @@ import {
17
17
  import { ErrorView } from "../ErrorView";
18
18
  import { AddIcon, Button, DialogActions, Typography } from "@firecms/ui";
19
19
  import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "../../util";
20
- import { useSelectionController } from "../EntityCollectionView/EntityCollectionView";
20
+ import { useSelectionController } from "../EntityCollectionView/useSelectionController";
21
21
  import { useColumnIds, useTableSearchHelper } from "../common";
22
22
  import { useSideDialogContext } from "../../core";
23
23
  import { useAnalyticsController } from "../../hooks/useAnalyticsController";
@@ -109,7 +109,7 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
109
109
 
110
110
  const fullPath = navigation.resolveAliasesFrom(pathInput);
111
111
 
112
- const dataSource = useDataSource();
112
+ const dataSource = useDataSource(collection);
113
113
 
114
114
  const [entitiesDisplayedFirst, setEntitiesDisplayedFirst] = useState<Entity<any>[]>([]);
115
115
 
@@ -291,6 +291,7 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
291
291
  displayedColumnIds={displayedColumnIds}
292
292
  onEntityClick={onEntityClick}
293
293
  tableController={tableController}
294
+ enablePopupIcon={false}
294
295
  tableRowActionsBuilder={tableRowActionsBuilder}
295
296
  title={<Typography variant={"subtitle2"}>
296
297
  {collection.singularName ? `Select ${collection.singularName}` : `Select from ${collection.name}`}
@@ -349,7 +350,7 @@ function ReferenceDialogActions({
349
350
  onNewClick();
350
351
  }
351
352
  : undefined;
352
- const addButton = canCreateEntity(collection, authController, fullPathToCollectionSegments(path), null) &&
353
+ const addButton = canCreateEntity(collection, authController, path, null) &&
353
354
  onClick && (largeLayout
354
355
  ? <Button
355
356
  onClick={onClick}
@@ -360,7 +361,6 @@ function ReferenceDialogActions({
360
361
  </Button>
361
362
  : <Button
362
363
  onClick={onClick}
363
- size="medium"
364
364
  variant="outlined"
365
365
  color="primary"
366
366
  >
@@ -4,7 +4,7 @@ import { Entity, EntityCollection, EntityReference, FilterValues } from "../type
4
4
  import { getReferenceFrom } from "../util";
5
5
  import { PreviewSize, ReferencePreview } from "../preview";
6
6
  import { useNavigationController, useReferenceDialog } from "../hooks";
7
- import { Button, cn } from "@firecms/ui";
7
+ import { Button, cls } from "@firecms/ui";
8
8
 
9
9
  export type ReferenceWidgetProps<M extends Record<string, any>> = {
10
10
  name?: string,
@@ -27,6 +27,8 @@ export type ReferenceWidgetProps<M extends Record<string, any>> = {
27
27
  forceFilter?: FilterValues<string>;
28
28
  size: PreviewSize;
29
29
  className?: string;
30
+ includeId?: boolean;
31
+ includeEntityLink?: boolean;
30
32
  };
31
33
 
32
34
  /**
@@ -43,25 +45,26 @@ export function ReferenceWidget<M extends Record<string, any>>({
43
45
  previewProperties,
44
46
  forceFilter,
45
47
  size,
46
- className
48
+ className,
49
+ includeId,
50
+ includeEntityLink
47
51
  }: ReferenceWidgetProps<M>) {
48
52
 
49
53
  const navigationController = useNavigationController();
50
54
 
51
55
  const collection: EntityCollection | undefined = useMemo(() => {
52
56
  return navigationController.getCollection(path);
53
- }, [path, navigationController]);
54
-
55
- if (!collection) {
56
- throw Error(`Couldn't find the corresponding collection for the path: ${path}`);
57
- }
57
+ }, [path, navigationController.getCollection]);
58
58
 
59
59
  const onSingleEntitySelected = useCallback((entity: Entity<M> | null) => {
60
60
  if (disabled)
61
61
  return;
62
62
  if (onReferenceSelected) {
63
63
  const reference = entity ? getReferenceFrom(entity) : null;
64
- onReferenceSelected?.({ reference, entity });
64
+ onReferenceSelected?.({
65
+ reference,
66
+ entity
67
+ });
65
68
  }
66
69
  }, [disabled, onReferenceSelected]);
67
70
 
@@ -70,7 +73,10 @@ export function ReferenceWidget<M extends Record<string, any>>({
70
73
  return;
71
74
  if (onMultipleReferenceSelected) {
72
75
  const references = entities ? entities.map(e => getReferenceFrom(e)) : null;
73
- onMultipleReferenceSelected({ references, entities });
76
+ onMultipleReferenceSelected({
77
+ references,
78
+ entities
79
+ });
74
80
  }
75
81
  }, [disabled, onReferenceSelected]);
76
82
 
@@ -110,7 +116,9 @@ export function ReferenceWidget<M extends Record<string, any>>({
110
116
  reference={ref}
111
117
  disabled={disabled}
112
118
  previewProperties={previewProperties}
113
- size={size}/>
119
+ size={size}
120
+ includeId={includeId}
121
+ includeEntityLink={includeEntityLink}/>
114
122
  })}
115
123
  </div>
116
124
  } else if (value?.isEntityReference && value?.isEntityReference()) {
@@ -119,10 +127,12 @@ export function ReferenceWidget<M extends Record<string, any>>({
119
127
  onClick={onEntryClick}
120
128
  disabled={disabled}
121
129
  previewProperties={previewProperties}
122
- size={size}/>
130
+ size={size}
131
+ includeId={includeId}
132
+ includeEntityLink={includeEntityLink}/>
123
133
 
124
134
  }
125
- return <div className={cn("text-sm font-medium text-gray-500",
135
+ return <div className={cls("text-sm font-medium",
126
136
  "min-w-80 flex flex-col gap-4",
127
137
  "relative transition-colors duration-200 ease-in rounded font-medium",
128
138
  disabled ? "bg-opacity-50" : "hover:bg-opacity-75",
@@ -1,14 +1,14 @@
1
1
  import React from "react";
2
2
 
3
3
  import { coolIconKeys, debounce, Icon, IconButton, iconKeys, SearchBar, Tooltip } from "@firecms/ui";
4
- import { icon_synonyms, iconsSearch } from "../util";
4
+ import { iconSynonyms, iconsSearch } from "../util";
5
5
 
6
6
  const UPDATE_SEARCH_INDEX_WAIT_MS = 220;
7
7
 
8
- if (process.env.NODE_ENV !== "production") {
9
- Object.keys(icon_synonyms).forEach((icon: string) => {
8
+ if (iconSynonyms && process.env.NODE_ENV !== "production") {
9
+ Object.keys(iconSynonyms).forEach((icon: string) => {
10
10
  if (!iconKeys.includes(icon)) {
11
- console.warn(`The icon ${icon} no longer exists. Remove it from \`icon_synonyms\``);
11
+ console.warn(`The icon ${icon} no longer exists. Remove it from \`iconSynonyms\``);
12
12
  }
13
13
  });
14
14
  }
@@ -48,7 +48,7 @@ export function SearchIconsView({
48
48
  return (
49
49
  <>
50
50
  <SearchBar
51
- autoFocus
51
+ autoFocus={false}
52
52
  innerClassName={"w-full sticky top-0 z-10"}
53
53
  onTextSearch={(value?: string) => setQuery(value ?? "")}
54
54
  placeholder="Search for more icons…"
@@ -10,7 +10,7 @@ import {
10
10
  } from "../../types";
11
11
  import { CellRendererParams, VirtualTable, VirtualTableColumn } from "../VirtualTable";
12
12
  import { enumToObjectEntries } from "../../util";
13
- import { OnCellValueChange, OnColumnResizeParams } from "../common/types";
13
+ import { OnCellValueChange, OnColumnResizeParams } from "../common";
14
14
  import { FilterFormFieldProps } from "../VirtualTable/VirtualTableHeader";
15
15
  import { ReferenceFilterField } from "./filters/ReferenceFilterField";
16
16
  import { StringNumberFilterField } from "./filters/StringNumberFilterField";
@@ -18,6 +18,7 @@ import { BooleanFilterField } from "./filters/BooleanFilterField";
18
18
  import { DateTimeFilterField } from "./filters/DateTimeFilterField";
19
19
  import { useOutsideAlerter } from "@firecms/ui";
20
20
  import { SelectableTableContext } from "./SelectableTableContext";
21
+ import { getRowHeight } from "../common/table_height";
21
22
 
22
23
  export type SelectableTableProps<M extends Record<string, any>> = {
23
24
 
@@ -115,7 +116,7 @@ export const SelectableTable = React.memo<SelectableTableProps<any>>(
115
116
  onEntityClick,
116
117
  onColumnResize,
117
118
  hoverRow = true,
118
- size,
119
+ size = "m",
119
120
  inlineEditing = false,
120
121
  tableController:
121
122
  {
@@ -224,7 +225,7 @@ export const SelectableTable = React.memo<SelectableTableProps<any>>(
224
225
  error={dataLoadingError}
225
226
  paginationEnabled={paginationEnabled}
226
227
  onColumnResize={onColumnResize}
227
- size={size}
228
+ rowHeight={getRowHeight(size)}
228
229
  loading={dataLoading}
229
230
  filter={filterValues}
230
231
  onFilterUpdate={setFilterValues ? onFilterUpdate : undefined}
@@ -280,6 +281,7 @@ function createFilterField({
280
281
  isArray={isArray}
281
282
  path={baseProperty.path}
282
283
  title={resolvedProperty?.name}
284
+ includeId={baseProperty.includeId}
283
285
  previewProperties={baseProperty?.previewProperties}
284
286
  hidden={hidden}
285
287
  setHidden={setHidden}/>;
@@ -32,7 +32,7 @@ export function BooleanFilterField({
32
32
  const valueSet = !!value;
33
33
 
34
34
  return (
35
- <div className="w-[200px]">
35
+ <div className="w-[300px]">
36
36
  <BooleanSwitchWithLabel
37
37
  value={valueSetToTrue}
38
38
  allowIndeterminate={true}
@@ -44,6 +44,5 @@ export function BooleanFilterField({
44
44
  : `${title} is false`}
45
45
  />
46
46
  </div>
47
- )
48
- ;
47
+ );
49
48
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from "react";
2
2
  import { VirtualTableWhereFilterOp } from "../../VirtualTable";
3
- import { DateTimeField, Select, SelectItem } from "@firecms/ui";
3
+ import { Checkbox, DateTimeField, Label, Select, SelectItem } from "@firecms/ui";
4
4
  import { useCustomizationController } from "../../../hooks";
5
5
 
6
6
  interface DateTimeFilterFieldProps {
@@ -43,10 +43,10 @@ export function DateTimeFilterField({
43
43
 
44
44
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
45
45
  const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
46
- const [internalValue, setInternalValue] = useState<Date | undefined>(fieldValue);
46
+ const [internalValue, setInternalValue] = useState<Date | null | undefined>(fieldValue);
47
47
 
48
- function updateFilter(op: VirtualTableWhereFilterOp, val: Date | undefined) {
49
- let newValue: Date | undefined = val;
48
+ function updateFilter(op: VirtualTableWhereFilterOp, val: Date | undefined | null) {
49
+ let newValue: Date | null | undefined = val;
50
50
  const prevOpIsArray = multipleSelectOperations.includes(operation);
51
51
  const newOpIsArray = multipleSelectOperations.includes(op);
52
52
  if (prevOpIsArray !== newOpIsArray) {
@@ -73,7 +73,7 @@ export function DateTimeFilterField({
73
73
 
74
74
  return (
75
75
 
76
- <div className="flex w-[440px] items-center">
76
+ <div className="flex w-[440px]">
77
77
  <div className="w-[80px]">
78
78
  <Select value={operation}
79
79
  onValueChange={(value) => {
@@ -88,19 +88,34 @@ export function DateTimeFilterField({
88
88
  </Select>
89
89
  </div>
90
90
 
91
- <div className="flex-grow ml-2">
91
+ <div className="flex-grow ml-2 flex flex-col gap-2">
92
92
 
93
93
  <DateTimeField
94
94
  mode={mode}
95
95
  size={"medium"}
96
96
  locale={locale}
97
- value={internalValue}
98
- onChange={(dateValue: Date | null) => {
97
+ value={internalValue ?? undefined}
98
+ onChange={(dateValue: Date | undefined) => {
99
99
  updateFilter(operation, dateValue === null ? undefined : dateValue);
100
100
  }}
101
101
  clearable={true}
102
102
  />
103
103
 
104
+ <Label
105
+ className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
106
+ htmlFor="null-filter"
107
+ >
108
+ <Checkbox id="null-filter"
109
+ checked={internalValue === null}
110
+ size={"small"}
111
+ onCheckedChange={(checked) => {
112
+ if (internalValue !== null)
113
+ updateFilter(operation, null);
114
+ else updateFilter(operation, undefined);
115
+ }}/>
116
+ Filter for null values
117
+ </Label>
118
+
104
119
  </div>
105
120
 
106
121
  </div>
@@ -4,7 +4,7 @@ import { Entity, EntityCollection, EntityReference } from "../../../types";
4
4
  import { ReferencePreview } from "../../../preview";
5
5
  import { getReferenceFrom } from "../../../util";
6
6
  import { useNavigationController, useReferenceDialog } from "../../../hooks";
7
- import { Button, Select, SelectItem } from "@firecms/ui";
7
+ import { Button, Checkbox, Label, Select, SelectItem } from "@firecms/ui";
8
8
 
9
9
  interface ReferenceFilterFieldProps {
10
10
  name: string,
@@ -13,6 +13,7 @@ interface ReferenceFilterFieldProps {
13
13
  isArray?: boolean;
14
14
  path?: string;
15
15
  title?: string;
16
+ includeId?: boolean;
16
17
  previewProperties?: string[];
17
18
  hidden: boolean;
18
19
  setHidden: (hidden: boolean) => void;
@@ -40,6 +41,7 @@ export function ReferenceFilterField({
40
41
  isArray,
41
42
  path,
42
43
  title,
44
+ includeId = true,
43
45
  previewProperties,
44
46
  setHidden
45
47
  }: ReferenceFilterFieldProps) {
@@ -48,33 +50,31 @@ export function ReferenceFilterField({
48
50
  ? ["array-contains"]
49
51
  : ["==", "!=", ">", "<", ">=", "<="];
50
52
 
51
- const [onHover, setOnHover] = React.useState(false);
52
-
53
53
  isArray
54
54
  ? possibleOperations.push("array-contains-any")
55
55
  : possibleOperations.push("in", "not-in");
56
56
 
57
57
  const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];
58
58
  const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);
59
- const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined>(fieldValue);
59
+ const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined | null>(fieldValue);
60
60
 
61
61
  const selectedEntityIds = internalValue
62
62
  ? (Array.isArray(internalValue) ? internalValue.map((ref) => {
63
- if (!(ref.isEntityReference && ref.isEntityReference())) {
63
+ if (!(ref?.isEntityReference && ref?.isEntityReference())) {
64
64
  return null;
65
65
  }
66
66
  return ref.id;
67
67
  }).filter(Boolean) as string[] : [internalValue.id])
68
68
  : [];
69
69
 
70
- function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[]) {
70
+ function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[] | null) {
71
71
 
72
72
  const prevOpIsArray = multipleSelectOperations.includes(operation);
73
73
  const newOpIsArray = multipleSelectOperations.includes(op);
74
74
  let newValue = val;
75
75
  if (prevOpIsArray !== newOpIsArray) {
76
76
  // @ts-ignore
77
- newValue = newOpIsArray ? (newValue.isEntityReference && newValue.isEntityReference() ? [newValue] : []) : undefined
77
+ newValue = newOpIsArray ? (newValue?.isEntityReference && newValue?.isEntityReference() ? [newValue] : []) : undefined
78
78
  }
79
79
 
80
80
  setOperation(op);
@@ -129,28 +129,23 @@ export function ReferenceFilterField({
129
129
 
130
130
  const buildEntry = (reference: EntityReference) => {
131
131
  return (
132
- <div
133
- className="mb-0.5"
134
- onMouseEnter={() => setOnHover(true)}
135
- onMouseMove={() => setOnHover(true)}
136
- onMouseLeave={() => setOnHover(false)}>
137
- <ReferencePreview
138
- disabled={!path}
139
- previewProperties={previewProperties}
140
- size={"medium"}
141
- onClick={doOpenDialog}
142
- reference={reference}
143
- onHover={onHover}
144
- allowEntityNavigation={false}
145
- />
146
- </div>
132
+ <ReferencePreview
133
+ disabled={!path}
134
+ previewProperties={previewProperties}
135
+ size={"medium"}
136
+ onClick={doOpenDialog}
137
+ reference={reference}
138
+ hover={true}
139
+ includeId={includeId}
140
+ includeEntityLink={false}
141
+ />
147
142
  );
148
143
  };
149
144
 
150
145
  return (
151
146
 
152
147
  <div className="flex w-[440px] flex-row">
153
- <div className="w-[120px]">
148
+ <div className="w-[140px]">
154
149
  <Select value={operation}
155
150
  onValueChange={(value) => {
156
151
  updateFilter(value as VirtualTableWhereFilterOp, internalValue);
@@ -164,21 +159,40 @@ export function ReferenceFilterField({
164
159
  </Select>
165
160
  </div>
166
161
 
167
- <div className="flex-grow ml-2 h-full">
162
+ <div className="flex-grow ml-2 h-full gap-2 flex flex-col">
168
163
 
169
164
  {internalValue && Array.isArray(internalValue) && <div>
170
165
  {internalValue.map((ref, index) => buildEntry(ref))}
171
166
  </div>}
167
+
172
168
  {internalValue && !Array.isArray(internalValue) && <div>
173
169
  {buildEntry(internalValue)}
174
170
  </div>}
171
+
175
172
  {(!internalValue || (Array.isArray(internalValue) && internalValue.length === 0)) &&
176
173
  <Button onClick={doOpenDialog}
177
174
  variant={"outlined"}
175
+ size={"large"}
178
176
  className="h-full w-full">
179
177
  {multiple ? "Select references" : "Select reference"}
180
178
  </Button>
181
179
  }
180
+
181
+ {!isArray && <Label
182
+ className="border cursor-pointer rounded-md p-2 flex items-center gap-2 [&:has(:checked)]:bg-gray-100 dark:[&:has(:checked)]:bg-gray-800"
183
+ htmlFor="null-filter"
184
+ >
185
+ <Checkbox id="null-filter"
186
+ checked={internalValue === null}
187
+ size={"small"}
188
+ onCheckedChange={(checked) => {
189
+ if (internalValue !== null)
190
+ updateFilter(operation, null);
191
+ else updateFilter(operation, undefined);
192
+ }}/>
193
+ Filter for null values
194
+ </Label>}
195
+
182
196
  </div>
183
197
 
184
198
  </div>