@firecms/core 3.0.0-rc.1 → 3.0.0-rc.3

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 (96) hide show
  1. package/dist/components/HomePage/HomePageDnD.d.ts +2 -1
  2. package/dist/components/PropertyCollectionView.d.ts +23 -0
  3. package/dist/components/UserDisplay.d.ts +7 -0
  4. package/dist/components/VirtualTable/fields/VirtualTableUserSelect.d.ts +12 -0
  5. package/dist/contexts/InternalUserManagementContext.d.ts +3 -0
  6. package/dist/core/EntityEditView.d.ts +10 -4
  7. package/dist/core/FireCMS.d.ts +0 -1
  8. package/dist/core/field_configs.d.ts +1 -1
  9. package/dist/form/EntityForm.d.ts +5 -2
  10. package/dist/form/components/LocalChangesMenu.d.ts +11 -0
  11. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +12 -0
  12. package/dist/form/index.d.ts +2 -1
  13. package/dist/hooks/index.d.ts +2 -0
  14. package/dist/hooks/useCollapsedGroups.d.ts +9 -0
  15. package/dist/hooks/useInternalUserManagementController.d.ts +12 -0
  16. package/dist/index.es.js +1983 -650
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +1981 -648
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/preview/components/UserPreview.d.ts +8 -0
  21. package/dist/preview/index.d.ts +1 -0
  22. package/dist/types/collections.d.ts +13 -0
  23. package/dist/types/entities.d.ts +5 -1
  24. package/dist/types/firecms.d.ts +15 -0
  25. package/dist/types/firecms_context.d.ts +16 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/internal_user_management.d.ts +20 -0
  28. package/dist/types/plugins.d.ts +2 -0
  29. package/dist/types/properties.d.ts +41 -6
  30. package/dist/types/property_config.d.ts +1 -1
  31. package/dist/types/user.d.ts +1 -1
  32. package/dist/util/collections.d.ts +1 -0
  33. package/dist/util/entity_cache.d.ts +6 -1
  34. package/dist/util/make_properties_editable.d.ts +1 -2
  35. package/dist/util/objects.d.ts +1 -0
  36. package/dist/util/useStorageUploadController.d.ts +1 -0
  37. package/package.json +6 -6
  38. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +47 -47
  39. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +12 -0
  40. package/src/components/EntityCollectionView/EntityCollectionView.tsx +6 -1
  41. package/src/components/EntityView.tsx +29 -40
  42. package/src/components/ErrorView.tsx +1 -1
  43. package/src/components/HomePage/DefaultHomePage.tsx +21 -34
  44. package/src/components/HomePage/HomePageDnD.tsx +143 -83
  45. package/src/components/HomePage/RenameGroupDialog.tsx +9 -3
  46. package/src/components/PropertyCollectionView.tsx +329 -0
  47. package/src/components/PropertyConfigBadge.tsx +2 -2
  48. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +2 -1
  49. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +1 -2
  50. package/src/components/UserDisplay.tsx +55 -0
  51. package/src/components/VirtualTable/fields/VirtualTableUserSelect.tsx +99 -0
  52. package/src/components/common/useColumnsIds.tsx +1 -8
  53. package/src/contexts/InternalUserManagementContext.tsx +4 -0
  54. package/src/core/EntityEditView.tsx +27 -14
  55. package/src/core/EntityEditViewFormActions.tsx +33 -18
  56. package/src/core/EntitySidePanel.tsx +9 -3
  57. package/src/core/FireCMS.tsx +22 -13
  58. package/src/core/field_configs.tsx +15 -1
  59. package/src/form/EntityForm.tsx +173 -42
  60. package/src/form/EntityFormActions.tsx +30 -15
  61. package/src/form/PropertyFieldBinding.tsx +4 -0
  62. package/src/form/components/ErrorFocus.tsx +22 -29
  63. package/src/form/components/LocalChangesMenu.tsx +144 -0
  64. package/src/form/field_bindings/UserSelectFieldBinding.tsx +94 -0
  65. package/src/form/index.tsx +5 -1
  66. package/src/hooks/index.tsx +3 -0
  67. package/src/hooks/useBrowserTitleAndIcon.tsx +1 -1
  68. package/src/hooks/useBuildNavigationController.tsx +104 -31
  69. package/src/hooks/useCollapsedGroups.ts +64 -0
  70. package/src/hooks/useFireCMSContext.tsx +6 -2
  71. package/src/hooks/useInternalUserManagementController.tsx +16 -0
  72. package/src/preview/PropertyPreview.tsx +8 -0
  73. package/src/preview/components/ReferencePreview.tsx +4 -2
  74. package/src/preview/components/UserPreview.tsx +27 -0
  75. package/src/preview/index.ts +1 -0
  76. package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
  77. package/src/preview/property_previews/MapPropertyPreview.tsx +2 -2
  78. package/src/preview/property_previews/NumberPropertyPreview.tsx +2 -2
  79. package/src/types/collections.ts +14 -0
  80. package/src/types/entities.ts +7 -1
  81. package/src/types/firecms.tsx +16 -0
  82. package/src/types/firecms_context.tsx +17 -0
  83. package/src/types/index.ts +1 -0
  84. package/src/types/internal_user_management.ts +24 -0
  85. package/src/types/plugins.tsx +3 -0
  86. package/src/types/properties.ts +45 -6
  87. package/src/types/property_config.tsx +1 -0
  88. package/src/types/user.ts +1 -1
  89. package/src/util/collections.ts +8 -0
  90. package/src/util/createFormexStub.tsx +4 -0
  91. package/src/util/entities.ts +1 -1
  92. package/src/util/entity_cache.ts +72 -53
  93. package/src/util/join_collections.ts +3 -3
  94. package/src/util/make_properties_editable.ts +0 -22
  95. package/src/util/objects.ts +40 -2
  96. package/src/util/useStorageUploadController.tsx +71 -34
@@ -16,7 +16,7 @@ export declare function SortableNavigationGroup({ groupName, children, disabled
16
16
  children: React.ReactNode;
17
17
  disabled?: boolean;
18
18
  }): import("react/jsx-runtime").JSX.Element;
19
- export declare function useHomePageDnd({ items: dndItems, setItems: setDndItems, disabled, onCardMovedBetweenGroups, onGroupMoved, onNewGroupDrop, onPersist }: {
19
+ export declare function useHomePageDnd({ items, setItems, disabled, onCardMovedBetweenGroups, onGroupMoved, onNewGroupDrop, onPersist }: {
20
20
  items: {
21
21
  name: string;
22
22
  entries: NavigationEntry[];
@@ -67,6 +67,7 @@ export declare function useHomePageDnd({ items: dndItems, setItems: setDndItems,
67
67
  dialogOpenForGroup: string | null;
68
68
  setDialogOpenForGroup: React.Dispatch<React.SetStateAction<string | null>>;
69
69
  handleRenameGroup: (oldName: string, newName: string) => void;
70
+ handleDialogClose: () => void;
70
71
  isHoveringNewGroupDropZone: boolean;
71
72
  setIsHoveringNewGroupDropZone: React.Dispatch<React.SetStateAction<boolean>>;
72
73
  };
@@ -0,0 +1,23 @@
1
+ import { PreviewSize } from "../preview";
2
+ import { ResolvedProperties, ResolvedProperty } from "../types";
3
+ /**
4
+ * Build a readable label for a path and resolve the property
5
+ * Supports map and array (including arrays of maps)
6
+ */
7
+ export declare function buildPropertyLabelAndGetProperty(properties: ResolvedProperties, key: string): {
8
+ label: string;
9
+ property: ResolvedProperty | undefined;
10
+ };
11
+ /**
12
+ * Improved simple layout for nested changes:
13
+ * - Map or Array-of-Map -> section header + indented rows
14
+ * - Leaf or Array-of-Primitives -> single row with label and value
15
+ */
16
+ export declare const PropertyCollectionView: ({ data, properties, baseKey, suppressHeader, size }: {
17
+ data: any;
18
+ properties: ResolvedProperties;
19
+ baseKey?: string;
20
+ suppressHeader?: boolean;
21
+ size?: PreviewSize;
22
+ }) => import("react/jsx-runtime").JSX.Element | null;
23
+ export declare function buildDataFromPaths(values: object, paths: string[]): object;
@@ -0,0 +1,7 @@
1
+ import { User } from "../types";
2
+ /**
3
+ * Component to render a single user with name and email
4
+ */
5
+ export declare function UserDisplay({ user, }: {
6
+ user: User | null;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export declare function VirtualTableUserSelect(props: {
3
+ name: string;
4
+ error: Error | undefined;
5
+ multiple: boolean;
6
+ disabled: boolean;
7
+ small: boolean;
8
+ internalValue: string | string[] | undefined;
9
+ updateValue: (newValue: (string | string[] | null)) => void;
10
+ focused: boolean;
11
+ onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { InternalUserManagement } from "../types";
3
+ export declare const InternalUserManagementContext: React.Context<InternalUserManagement<any>>;
@@ -11,6 +11,12 @@ export type OnUpdateParams = {
11
11
  selectedTab?: string;
12
12
  collection: EntityCollection<any>;
13
13
  };
14
+ export type BarActionsParams = {
15
+ values: object;
16
+ status: EntityStatus;
17
+ path: string;
18
+ entityId?: string;
19
+ };
14
20
  export type OnTabChangeParams<M extends Record<string, any>> = {
15
21
  path: string;
16
22
  entityId?: string;
@@ -32,11 +38,11 @@ export interface EntityEditViewProps<M extends Record<string, any>> {
32
38
  copy?: boolean;
33
39
  selectedTab?: string;
34
40
  parentCollectionIds: string[];
35
- onValuesModified?: (modified: boolean) => void;
41
+ onValuesModified?: (modified: boolean, values: M) => void;
36
42
  onSaved?: (params: OnUpdateParams) => void;
37
43
  onTabChange?: (props: OnTabChangeParams<M>) => void;
38
44
  layout?: "side_panel" | "full_screen";
39
- barActions?: React.ReactNode;
45
+ barActions?: (params: BarActionsParams) => React.ReactNode;
40
46
  formProps?: Partial<EntityFormProps<M>>;
41
47
  }
42
48
  /**
@@ -44,9 +50,9 @@ export interface EntityEditViewProps<M extends Record<string, any>> {
44
50
  * an entity is opened.
45
51
  */
46
52
  export declare function EntityEditView<M extends Record<string, any>, USER extends User>({ entityId, ...props }: EntityEditViewProps<M>): import("react/jsx-runtime").JSX.Element;
47
- export declare function EntityEditViewInner<M extends Record<string, any>>({ path, fullIdPath, entityId, selectedTab: selectedTabProp, collection, parentCollectionIds, onValuesModified, onSaved, onTabChange, entity, cachedDirtyValues, dataLoading, layout, barActions, status, setStatus, formProps, canEdit }: EntityEditViewProps<M> & {
53
+ export declare function EntityEditViewInner<M extends Record<string, any>>({ path, fullIdPath, entityId, selectedTab: selectedTabProp, collection, parentCollectionIds, onValuesModified, onSaved, onTabChange, entity, initialDirtyValues, dataLoading, layout, barActions, status, setStatus, formProps, canEdit }: EntityEditViewProps<M> & {
48
54
  entity?: Entity<M>;
49
- cachedDirtyValues?: Partial<M>;
55
+ initialDirtyValues?: Partial<M>;
50
56
  dataLoading: boolean;
51
57
  status: EntityStatus;
52
58
  setStatus: (status: EntityStatus) => void;
@@ -8,7 +8,6 @@ import { FireCMSProps, User } from "../types";
8
8
  *
9
9
  * You only need to use this component if you are building a custom app.
10
10
  *
11
-
12
11
  * @group Core
13
12
  */
14
13
  export declare function FireCMS<USER extends User>(props: FireCMSProps<USER>): import("react/jsx-runtime").JSX.Element;
@@ -3,5 +3,5 @@ export declare function isDefaultFieldConfigId(id: string): boolean;
3
3
  export declare const DEFAULT_FIELD_CONFIGS: Record<string, PropertyConfig<any>>;
4
4
  export declare function getDefaultFieldConfig(property: Property | ResolvedProperty): PropertyConfig | undefined;
5
5
  export declare function getFieldConfig(property: Property | ResolvedProperty, propertyConfigs: Record<string, PropertyConfig<any>>): PropertyConfig | undefined;
6
- export declare function getDefaultFieldId(property: Property | ResolvedProperty): "reference" | "date_time" | "text_field" | "multiline" | "markdown" | "url" | "email" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference_as_string" | "multi_references" | "switch" | "repeat" | "custom_array" | "block" | undefined;
6
+ export declare function getDefaultFieldId(property: Property | ResolvedProperty): "reference" | "date_time" | "text_field" | "multiline" | "markdown" | "url" | "email" | "user_select" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference_as_string" | "multi_references" | "switch" | "repeat" | "custom_array" | "block" | undefined;
7
7
  export declare function getFieldId(property: Property | ResolvedProperty): string | undefined;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
2
+ import { AuthController, Entity, EntityCollection, EntityCustomViewParams, EntityStatus, EntityValues, FormContext, PropertyConfig } from "../types";
3
3
  import { FormexController } from "@firecms/formex";
4
4
  import { ValidationError } from "yup";
5
5
  import { EntityFormActionsProps } from "./EntityFormActions";
@@ -19,7 +19,7 @@ export type EntityFormProps<M extends Record<string, any>> = {
19
19
  entity?: Entity<M>;
20
20
  databaseId?: string;
21
21
  onIdChange?: (id: string) => void;
22
- onValuesModified?: (modified: boolean) => void;
22
+ onValuesModified?: (modified: boolean, values: M) => void;
23
23
  onSaved?: (params: OnUpdateParams) => void;
24
24
  initialDirtyValues?: Partial<M>;
25
25
  onFormContextReady?: (formContext: FormContext) => void;
@@ -46,5 +46,8 @@ export type EntityFormProps<M extends Record<string, any>> = {
46
46
  Builder?: React.ComponentType<EntityCustomViewParams<M>>;
47
47
  children?: React.ReactNode;
48
48
  };
49
+ export declare function extractTouchedValues(values: any, touched: Record<string, boolean>): Record<string, any>;
50
+ export declare function getChanges<T extends object>(source: Partial<T>, comparison: Partial<T>): Partial<T>;
49
51
  export declare function EntityForm<M extends Record<string, any>>({ path, fullIdPath, entityId: entityIdProp, collection, onValuesModified, onIdChange, onSaved, entity, initialDirtyValues, onFormContextReady, forceActionsAtTheBottom, initialStatus, className, onStatusChange, onEntityChange, openEntityMode, formex: formexProp, disabled: disabledProp, Builder, EntityFormActionsComponent, showDefaultActions, showEntityPath, children }: EntityFormProps<M>): import("react/jsx-runtime").JSX.Element;
52
+ export declare function getInitialEntityValues<M extends object>(authController: AuthController, collection: EntityCollection, path: string, status: "new" | "existing" | "copy", entity: Entity<M> | undefined, propertyConfigs?: Record<string, PropertyConfig>): Partial<EntityValues<M>>;
50
53
  export declare function yupToFormErrors(yupError: ValidationError): Record<string, any>;
@@ -0,0 +1,11 @@
1
+ import { FormexController } from "@firecms/formex";
2
+ import { ResolvedProperties } from "../../types";
3
+ interface LocalChangesMenuProps<M extends object> {
4
+ cacheKey: string;
5
+ localChangesData: Partial<M>;
6
+ formex: FormexController<M>;
7
+ onClearLocalChanges?: () => void;
8
+ properties: ResolvedProperties<M>;
9
+ }
10
+ export declare function LocalChangesMenu<M extends object>({ localChangesData, formex, onClearLocalChanges, cacheKey, properties }: LocalChangesMenuProps<M>): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,12 @@
1
+ import { FieldProps } from "../../types";
2
+ type UserSelectProps = FieldProps<string>;
3
+ /**
4
+ * Field binding for selecting a user from the internal user management system.
5
+ * Renders a select dropdown with user information including name and email.
6
+ *
7
+ * This is one of the internal components that get mapped natively inside forms
8
+ * and tables to the specified properties.
9
+ * @group Form fields
10
+ */
11
+ export declare function UserSelectFieldBinding({ propertyKey, value, setValue, error, showError, disabled, autoFocus, touched, property, includeDescription, size }: UserSelectProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -1,4 +1,5 @@
1
- export * from "./EntityForm";
1
+ export { EntityForm, yupToFormErrors, } from "./EntityForm";
2
+ export type { EntityFormProps } from "./EntityForm";
2
3
  export { SelectFieldBinding } from "./field_bindings/SelectFieldBinding";
3
4
  export { MultiSelectFieldBinding } from "./field_bindings/MultiSelectFieldBinding";
4
5
  export { ArrayOfReferencesFieldBinding } from "./field_bindings/ArrayOfReferencesFieldBinding";
@@ -15,6 +15,8 @@ export * from "./useSnackbarController";
15
15
  export * from "./useModeController";
16
16
  export * from "./useClipboard";
17
17
  export * from "./useLargeLayout";
18
+ export * from "./useCollapsedGroups";
19
+ export * from "./useInternalUserManagementController";
18
20
  export * from "./useReferenceDialog";
19
21
  export * from "./useBrowserTitleAndIcon";
20
22
  export * from "./useCustomizationController";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Custom hook for managing collapsed/expanded state of navigation groups
3
+ * with localStorage persistence. Automatically cleans up stale group entries
4
+ * when groups are removed from the navigation.
5
+ */
6
+ export declare function useCollapsedGroups(groupNames: string[]): {
7
+ isGroupCollapsed: (name: string) => boolean;
8
+ toggleGroupCollapsed: (name: string) => void;
9
+ };
@@ -0,0 +1,12 @@
1
+ import { InternalUserManagement, User } from "../types";
2
+ /**
3
+ * Use this hook to get the internal user management of the app.
4
+ * Note that this is different from the user management plugin controller.
5
+ * This controller will be eventually replaced by the one provided
6
+ * by the user management plugin.
7
+ *
8
+ * Use at your own risk!
9
+ *
10
+ * @group Hooks and utilities
11
+ */
12
+ export declare const useInternalUserManagementController: <USER extends User = User>() => InternalUserManagement<USER>;