@firecms/core 3.0.0-beta.2-pre.2 → 3.0.0-beta.2-pre.4

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 (79) hide show
  1. package/README.md +2 -3
  2. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +0 -3
  3. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -8
  4. package/dist/components/EntityCollectionTable/index.d.ts +2 -4
  5. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  6. package/dist/components/{ReferenceSelectionInner.d.ts → ReferenceTable/ReferenceSelectionTable.d.ts} +2 -2
  7. package/dist/components/{EntityCollectionTable/SimpleTable.d.ts → SelectableTable/SelectableTable.d.ts} +3 -4
  8. package/dist/components/SelectableTable/SelectableTableContext.d.ts +4 -0
  9. package/dist/components/common/index.d.ts +5 -0
  10. package/dist/components/{EntityCollectionTable → common}/types.d.ts +7 -0
  11. package/dist/components/common/useTableSearchHelper.d.ts +12 -0
  12. package/dist/components/index.d.ts +5 -2
  13. package/dist/form/EntityForm.d.ts +2 -0
  14. package/dist/form/components/index.d.ts +0 -1
  15. package/dist/hooks/index.d.ts +1 -0
  16. package/dist/{internal → hooks}/useBuildNavigationController.d.ts +11 -4
  17. package/dist/hooks/useSnackbarController.d.ts +1 -0
  18. package/dist/index.es.js +4081 -4049
  19. package/dist/index.es.js.map +1 -1
  20. package/dist/index.umd.js +5 -5
  21. package/dist/index.umd.js.map +1 -1
  22. package/dist/types/fields.d.ts +0 -1
  23. package/dist/types/firecms.d.ts +6 -25
  24. package/dist/types/navigation.d.ts +2 -2
  25. package/dist/types/plugins.d.ts +0 -8
  26. package/package.json +4 -4
  27. package/src/components/ArrayContainer.tsx +11 -4
  28. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +16 -22
  29. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -5
  30. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -2
  31. package/src/components/EntityCollectionTable/column_utils.tsx +1 -1
  32. package/src/components/EntityCollectionTable/index.tsx +1 -9
  33. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +133 -136
  34. package/src/components/EntityCollectionView/EntityCollectionView.tsx +20 -41
  35. package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx} +31 -15
  36. package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx} +8 -9
  37. package/src/components/SelectableTable/SelectableTableContext.tsx +6 -0
  38. package/src/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.tsx +0 -1
  39. package/src/components/VirtualTable/VirtualTableHeader.tsx +10 -4
  40. package/src/components/common/index.ts +5 -0
  41. package/src/components/{EntityCollectionTable → common}/types.tsx +5 -0
  42. package/src/components/common/useTableSearchHelper.ts +47 -0
  43. package/src/components/index.tsx +6 -2
  44. package/src/core/EntitySidePanel.tsx +7 -5
  45. package/src/core/FireCMS.tsx +1 -16
  46. package/src/form/EntityForm.tsx +237 -196
  47. package/src/form/PropertyFieldBinding.tsx +7 -7
  48. package/src/form/components/CustomIdField.tsx +35 -34
  49. package/src/form/components/ErrorFocus.tsx +3 -3
  50. package/src/form/components/index.tsx +0 -1
  51. package/src/form/field_bindings/BlockFieldBinding.tsx +13 -12
  52. package/src/hooks/index.tsx +1 -0
  53. package/src/{internal → hooks}/useBuildNavigationController.tsx +23 -17
  54. package/src/hooks/useFireCMSContext.tsx +51 -3
  55. package/src/hooks/useReferenceDialog.tsx +2 -2
  56. package/src/hooks/useSnackbarController.tsx +1 -2
  57. package/src/internal/useBuildSideEntityController.tsx +1 -1
  58. package/src/types/fields.tsx +1 -1
  59. package/src/types/firecms.tsx +7 -28
  60. package/src/types/navigation.ts +2 -2
  61. package/src/types/plugins.tsx +0 -9
  62. package/src/util/resolutions.ts +1 -1
  63. package/dist/form/components/SubmitListener.d.ts +0 -1
  64. package/dist/form/components/SwitchControl.d.ts +0 -8
  65. package/src/form/components/SubmitListener.tsx +0 -32
  66. package/src/form/components/SwitchControl.tsx +0 -39
  67. /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.d.ts +0 -0
  68. /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.d.ts +0 -0
  69. /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.d.ts +0 -0
  70. /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.d.ts +0 -0
  71. /package/dist/components/{EntityCollectionView → common}/useColumnsIds.d.ts +0 -0
  72. /package/dist/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.d.ts +0 -0
  73. /package/dist/components/{EntityCollectionTable → common}/useDebouncedData.d.ts +0 -0
  74. /package/src/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.tsx +0 -0
  75. /package/src/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.tsx +0 -0
  76. /package/src/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.tsx +0 -0
  77. /package/src/components/{EntityCollectionView → common}/useColumnsIds.tsx +0 -0
  78. /package/src/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.tsx +0 -0
  79. /package/src/components/{EntityCollectionTable → common}/useDebouncedData.ts +0 -0
@@ -20,7 +20,6 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
20
20
  /**
21
21
  * Initial value of this field
22
22
  */
23
- initialValue: T | undefined;
24
23
  /**
25
24
  * Set value of field directly
26
25
  */
@@ -3,7 +3,7 @@ import { User } from "./user";
3
3
  import { AuthController } from "./auth";
4
4
  import { DataSourceDelegate } from "./datasource";
5
5
  import { EntityCollection, EntityCustomView } from "./collections";
6
- import { CMSView } from "./navigation";
6
+ import { CMSView, NavigationController } from "./navigation";
7
7
  import { FireCMSContext } from "./firecms_context";
8
8
  import { PropertyConfig } from "./property_config";
9
9
  import { Locale } from "./locales";
@@ -62,24 +62,17 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
62
62
  */
63
63
  loading: boolean;
64
64
  }) => React.ReactNode;
65
- /**
66
- * List of the mapped collections in the CMS.
67
- * Each entry relates to a collection in the root database.
68
- * Each of the navigation entries in this field
69
- * generates an entry in the main menu.
70
- */
71
- collections?: EC[] | EntityCollectionsBuilder<EC>;
72
- /**
73
- * Custom additional views created by the developer, added to the main
74
- * navigation
75
- */
76
- views?: CMSView[] | CMSViewsBuilder;
77
65
  /**
78
66
  * Record of custom form fields to be used in the CMS.
79
67
  * You can use the key to reference the custom field in
80
68
  * the `propertyConfig` prop of a property in a collection.
81
69
  */
82
70
  propertyConfigs?: Record<string, PropertyConfig>;
71
+ /**
72
+ * This controller is in charge of the navigation of the CMS.
73
+ * It is in charge of resolving the collection and entity paths.
74
+ */
75
+ navigationController: NavigationController;
83
76
  /**
84
77
  * List of additional custom views for entities.
85
78
  * You can use the key to reference the custom view in
@@ -109,18 +102,6 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
109
102
  * Delegate for implementing your auth operations.
110
103
  */
111
104
  authController: AuthController<UserType>;
112
- /**
113
- * Path under the navigation routes of the CMS will be created. Defaults to `/`.
114
- * Internally FireCMS uses `react-router` to create the routes, the base path is attached to the
115
- * `BrowserRouter` component. If you are using FireCMS in a subpath of your website, you can use
116
- * this prop to specify the base path.
117
- */
118
- basePath?: string;
119
- /**
120
- * Path under the collection routes of the CMS will be created.
121
- * Defaults to `/c`.
122
- */
123
- baseCollectionPath?: string;
124
105
  /**
125
106
  * Use this controller to access the configuration that is stored locally,
126
107
  * and not defined in code
@@ -12,12 +12,12 @@ export type NavigationController = {
12
12
  * Each of the navigation entries in this field
13
13
  * generates an entry in the main menu.
14
14
  */
15
- collections: EntityCollection[];
15
+ collections?: EntityCollection[];
16
16
  /**
17
17
  * Custom additional views created by the developer, added to the main
18
18
  * navigation
19
19
  */
20
- views: CMSView[];
20
+ views?: CMSView[];
21
21
  /**
22
22
  * Configuration for the views that should be displayed at the top
23
23
  * level of the navigation (e.g. in the home page or the navigation
@@ -22,14 +22,6 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
22
22
  */
23
23
  loading?: boolean;
24
24
  collections?: {
25
- /**
26
- * Use this method to inject collections to the CMS.
27
- * You receive the current collections as a parameter, and you can return
28
- * a new list of collections.
29
- * @see {@link joinCollectionLists}
30
- * @param collections
31
- */
32
- injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
33
25
  /**
34
26
  * Use this component to add custom actions to the entity collections
35
27
  * toolbar.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.2-pre.2",
4
+ "version": "3.0.0-beta.2-pre.4",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -38,12 +38,12 @@
38
38
  "generateIcons": "ts-node --esm src/icons/generateIcons.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@firecms/ui": "^3.0.0-beta.2-pre.2",
41
+ "@firecms/formex": "^3.0.0-beta.2-pre.4",
42
+ "@firecms/ui": "^3.0.0-beta.2-pre.4",
42
43
  "@fontsource/ibm-plex-mono": "^5.0.8",
43
44
  "@fontsource/roboto": "^5.0.8",
44
45
  "@hello-pangea/dnd": "^16.5.0",
45
46
  "date-fns": "^3.3.1",
46
- "formik": "^2.4.5",
47
47
  "history": "^5.3.0",
48
48
  "js-search": "^2.0.1",
49
49
  "markdown-it": "^13.0.2",
@@ -107,7 +107,7 @@
107
107
  "dist",
108
108
  "src"
109
109
  ],
110
- "gitHead": "f3f62fc3cbc4f0d9d1a26817a14cff06393b7c2b",
110
+ "gitHead": "a947c08aada0e374aec7dff2b0dc9e540e170834",
111
111
  "publishConfig": {
112
112
  "access": "public"
113
113
  }
@@ -48,7 +48,7 @@ export function ArrayContainer<T>({
48
48
  value,
49
49
  disabled = false,
50
50
  buildEntry,
51
- size,
51
+ size = "medium",
52
52
  onInternalIdAdded,
53
53
  includeAddButton,
54
54
  newDefaultEntry,
@@ -274,7 +274,7 @@ export function ArrayItemOptions({
274
274
  const iconRef = React.useRef<HTMLDivElement>(null);
275
275
  useOutsideAlerter(iconRef, () => setMenuOpen(false));
276
276
 
277
- return <div className={`ml-2 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`}
277
+ return <div className={`pl-2 pt-1 pb-4 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`}
278
278
  ref={iconRef}
279
279
  {...provided.dragHandleProps}>
280
280
  <Tooltip
@@ -302,14 +302,21 @@ export function ArrayItemOptions({
302
302
  </IconButton>
303
303
 
304
304
  <Menu
305
+ portalContainer={iconRef.current}
305
306
  open={menuOpen}
306
307
  trigger={<div/>}>
307
308
 
308
- <MenuItem dense onClick={() => remove(index)}>
309
+ <MenuItem dense onClick={(e) => {
310
+ setMenuOpen(false);
311
+ remove(index);
312
+ }}>
309
313
  <RemoveIcon size={"small"}/>
310
314
  Remove
311
315
  </MenuItem>
312
- <MenuItem dense onClick={() => copy(index)}>
316
+ <MenuItem dense onClick={() => {
317
+ setMenuOpen(false);
318
+ copy(index);
319
+ }}>
313
320
  <ContentCopyIcon size={"small"}/>
314
321
  Copy
315
322
  </MenuItem>
@@ -8,7 +8,7 @@ import { CellRendererParams, VirtualTableColumn } from "../VirtualTable";
8
8
  import { getValueInPath } from "../../util";
9
9
  import { getRowHeight } from "../VirtualTable/common";
10
10
  import { EntityCollectionRowActions } from "./EntityCollectionRowActions";
11
- import { EntityCollectionTableController } from "./types";
11
+ import { EntityCollectionTableController } from "../common/types";
12
12
  import { CollectionTableToolbar } from "./internal/CollectionTableToolbar";
13
13
  import { EntityCollectionTableProps } from "./EntityCollectionTableProps";
14
14
  import { EntityTableCell } from "./internal/EntityTableCell";
@@ -16,13 +16,8 @@ import { CustomFieldValidator } from "../../form/validation";
16
16
  import { renderSkeletonText } from "../../preview";
17
17
  import { propertiesToColumns } from "./column_utils";
18
18
  import { ErrorView } from "../ErrorView";
19
- import { SimpleTable } from "./SimpleTable";
19
+ import { SelectableTable } from "../SelectableTable/SelectableTable";
20
20
 
21
- const DEFAULT_STATE = {} as any;
22
-
23
- export const EntityCollectionTableContext = React.createContext<EntityCollectionTableController<any>>(DEFAULT_STATE);
24
-
25
- export const useEntityCollectionTableController = () => useContext<EntityCollectionTableController<any>>(EntityCollectionTableContext);
26
21
 
27
22
  /**
28
23
  * This component is in charge of rendering a collection table with a high
@@ -313,21 +308,20 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
313
308
  actions={actions}
314
309
  loading={tableController.dataLoading}/>
315
310
 
316
- <SimpleTable columns={columns}
317
- size={size}
318
- inlineEditing={inlineEditing}
319
- cellRenderer={cellRenderer}
320
- onEntityClick={onEntityClick}
321
- highlightedRow={useCallback((entity: Entity<M>) => selectedEntityIds?.includes(entity.id) ?? false, [selectedEntityIds])}
322
- tableController={tableController}
323
- onValueChange={onValueChange}
324
- onColumnResize={onColumnResize}
325
- hoverRow={hoverRow}
326
- filterable={filterable}
327
- emptyComponent={emptyComponent}
328
- endAdornment={endAdornment}
329
- AddColumnComponent={AddColumnComponent}/>
330
-
311
+ <SelectableTable columns={columns}
312
+ size={size}
313
+ inlineEditing={inlineEditing}
314
+ cellRenderer={cellRenderer}
315
+ onEntityClick={onEntityClick}
316
+ highlightedRow={useCallback((entity: Entity<M>) => selectedEntityIds?.includes(entity.id) ?? false, [selectedEntityIds])}
317
+ tableController={tableController}
318
+ onValueChange={onValueChange}
319
+ onColumnResize={onColumnResize}
320
+ hoverRow={hoverRow}
321
+ filterable={filterable}
322
+ emptyComponent={emptyComponent}
323
+ endAdornment={endAdornment}
324
+ AddColumnComponent={AddColumnComponent}/>
331
325
 
332
326
  </div>
333
327
  );
@@ -10,12 +10,8 @@ import {
10
10
  SelectionController,
11
11
  User
12
12
  } from "../../types";
13
- import { OnCellValueChange, UniqueFieldValidator } from "./types";
13
+ import { OnCellValueChange, OnColumnResizeParams, UniqueFieldValidator } from "../common/types";
14
14
 
15
- /**
16
- * @group Collection components
17
- */
18
- export type OnColumnResizeParams = { width: number, key: string };
19
15
 
20
16
  /**
21
17
  * @group Collection components
@@ -24,13 +24,13 @@ import { getPreviewSizeFrom } from "../../preview/util";
24
24
  import { isReadOnly } from "../../util";
25
25
 
26
26
  import { CustomFieldValidator, mapPropertyToYup } from "../../form/validation";
27
- import { useEntityCollectionTableController } from "./EntityCollectionTable";
28
27
  import { useClearRestoreValue, useFireCMSContext } from "../../hooks";
29
28
 
30
29
  import { EntityTableCell } from "./internal/EntityTableCell";
31
30
  import { EntityTableCellActions } from "./internal/EntityTableCellActions";
32
31
 
33
32
  import { getRowHeight } from "../VirtualTable/common";
33
+ import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
34
34
 
35
35
  export interface PropertyTableCellProps<T extends CMSType, M extends Record<string, any>> {
36
36
  propertyKey: string;
@@ -84,7 +84,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
84
84
  selectedCell,
85
85
  select,
86
86
  setPopupCell
87
- } = useEntityCollectionTableController();
87
+ } = useSelectableTableController();
88
88
 
89
89
  const selected = selectedCell?.propertyKey === propertyKey &&
90
90
  selectedCell?.entity.path === entity.path &&
@@ -3,7 +3,7 @@ import { getTableCellAlignment, getTablePropertyColumnWidth } from "./internal/c
3
3
  import { FilterValues, ResolvedProperties, ResolvedProperty } from "../../types";
4
4
  import { VirtualTableColumn } from "../VirtualTable";
5
5
  import { getIconForProperty, getResolvedPropertyInPath } from "../../util";
6
- import { getColumnKeysForProperty } from "../EntityCollectionView/useColumnsIds";
6
+ import { getColumnKeysForProperty } from "../common/useColumnsIds";
7
7
 
8
8
  export function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {
9
9
  return {
@@ -4,17 +4,9 @@ export {
4
4
 
5
5
  export type {
6
6
  EntityCollectionTableProps,
7
- OnColumnResizeParams
8
7
  } from "./EntityCollectionTableProps";
9
8
 
10
- export type {
11
- UniqueFieldValidator,
12
- OnCellValueChange,
13
- OnCellValueChangeParams
14
- } from "./types";
15
-
16
9
  export * from "./PropertyTableCell";
17
- export * from "./SimpleTable";
18
10
  export * from "./EntityCollectionRowActions";
19
- export * from "./useDataSourceEntityCollectionTableController";
11
+ export * from "../common/useDataSourceEntityCollectionTableController";
20
12
  export * from "./column_utils";
@@ -14,16 +14,17 @@ import {
14
14
  ResolvedProperties,
15
15
  ResolvedProperty
16
16
  } from "../../../../types";
17
- import { Form, Formik, FormikProps } from "formik";
17
+ import { Formex, useCreateFormex } from "@firecms/formex";
18
18
  import { useDraggable } from "./useDraggable";
19
19
  import { CustomFieldValidator, getYupEntitySchema } from "../../../../form/validation";
20
20
  import { useWindowSize } from "./useWindowSize";
21
21
  import { ElementResizeListener } from "./ElementResizeListener";
22
- import { ErrorView, OnCellValueChangeParams } from "../../../../components";
22
+ import { ErrorView } from "../../../ErrorView";
23
23
  import { getPropertyInPath, isReadOnly, resolveCollection } from "../../../../util";
24
24
  import { Button, ClearIcon, DialogActions, IconButton, Typography } from "@firecms/ui";
25
25
  import { PropertyFieldBinding } from "../../../../form";
26
26
  import { useCustomizationController, useFireCMSContext } from "../../../../hooks";
27
+ import { OnCellValueChangeParams } from "../../../common";
27
28
 
28
29
  interface PopupFormFieldProps<M extends Record<string, any>> {
29
30
  entity?: Entity<M>;
@@ -218,139 +219,134 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
218
219
  if (!entity)
219
220
  return <></>;
220
221
 
221
- const form = entity && (
222
+ // enableReinitialize={true}
223
+ // eslint-disable-next-line react-hooks/rules-of-hooks
224
+ const formex = useCreateFormex<M>({
225
+ initialValues: (entity?.values ?? {}) as EntityValues<M>,
226
+ validation: (values) => {
227
+ return validationSchema?.validate(values)
228
+ },
229
+ validateOnInitialRender: true,
230
+ onSubmit: (values, actions) => {
231
+ saveValue(values)
232
+ .then(() => onClose())
233
+ .finally(() => actions.setSubmitting(false));
234
+ }
235
+ });
236
+
237
+ const { values, isSubmitting, setFieldValue, handleSubmit } = formex;
238
+
239
+ // eslint-disable-next-line react-hooks/rules-of-hooks
240
+ useEffect(() => {
241
+ if (!equal(values, internalValue)) {
242
+ setInternalValue(values);
243
+ }
244
+ }, [values]);
245
+
246
+ if (!entity)
247
+ return <ErrorView
248
+ error={"PopupFormField misconfiguration"}/>;
249
+
250
+ if (!collection)
251
+ return <></>;
252
+
253
+ const disabled = isSubmitting;
254
+
255
+ const formContext: FormContext<M> = {
256
+ collection,
257
+ entityId,
258
+ values,
259
+ path,
260
+ setFieldValue,
261
+ save: saveValue
262
+ };
263
+
264
+ const property: ResolvedProperty<any> | undefined = propertyKey && getPropertyInPath(collection.properties, propertyKey as string);
265
+ const fieldProps: PropertyFieldBindingProps<any, M> | undefined = propertyKey && property
266
+ ? {
267
+ propertyKey: propertyKey as string,
268
+ disabled: isSubmitting || isReadOnly(property) || !!property.disabled,
269
+ property,
270
+ includeDescription: false,
271
+ underlyingValueHasChanged: false,
272
+ context: formContext,
273
+ tableMode: true,
274
+ partOfArray: false,
275
+ partOfBlock: false,
276
+ autoFocus: open
277
+ }
278
+ : undefined;
279
+
280
+ let internalForm = <>
222
281
  <div
223
- className={`text-gray-900 dark:text-white overflow-auto rounded rounded-md bg-white dark:bg-gray-950 ${!open ? "hidden" : ""} cursor-grab max-w-[100vw]`}>
224
- <Formik
225
- initialValues={(entity?.values ?? {}) as EntityValues<M>}
226
- enableReinitialize={true}
227
- validationSchema={validationSchema}
228
- validateOnMount={true}
229
- validate={(values) => console.debug("Validating", values)}
230
- onSubmit={(values, actions) => {
231
- saveValue(values)
232
- .then(() => onClose())
233
- .finally(() => actions.setSubmitting(false));
234
- }}
235
- >
236
- {({
237
- values,
238
- setFieldValue,
239
- handleSubmit,
240
- isSubmitting
241
- }: FormikProps<EntityValues<M>>) => {
242
-
243
- // eslint-disable-next-line react-hooks/rules-of-hooks
244
- useEffect(() => {
245
- if (!equal(values, internalValue)) {
246
- setInternalValue(values);
247
- }
248
- }, [values]);
249
-
250
- if (!entity)
251
- return <ErrorView
252
- error={"PopupFormField misconfiguration"}/>;
253
-
254
- if (!collection)
255
- return <></>;
256
-
257
- const disabled = isSubmitting;
258
-
259
- const formContext: FormContext<M> = {
260
- collection,
261
- entityId,
262
- values,
263
- path,
264
- setFieldValue,
265
- save: saveValue
266
- };
267
-
268
- const property: ResolvedProperty<any> | undefined = propertyKey && getPropertyInPath(collection.properties, propertyKey as string);
269
- const fieldProps: PropertyFieldBindingProps<any, M> | undefined = propertyKey && property
270
- ? {
271
- propertyKey: propertyKey as string,
272
- disabled: isSubmitting || isReadOnly(property) || !!property.disabled,
273
- property,
274
- includeDescription: false,
275
- underlyingValueHasChanged: false,
276
- context: formContext,
277
- tableMode: true,
278
- partOfArray: false,
279
- partOfBlock: false,
280
- autoFocus: open
281
- }
282
- : undefined;
283
-
284
- let internalForm = <>
285
- <div
286
- key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}
287
- className="w-[560px] max-w-full max-h-[85vh]">
288
- <Form
289
- onSubmit={handleSubmit}
290
- noValidate>
291
-
292
- <div
293
- className="mb-1 p-4 flex flex-col relative">
294
- <div
295
- ref={innerRef}
296
- className="cursor-auto"
297
- style={{ cursor: "auto !important" }}>
298
- {fieldProps &&
299
- <PropertyFieldBinding {...fieldProps}/>}
300
- </div>
301
- </div>
302
-
303
- <DialogActions>
304
- <Button
305
- variant="filled"
306
- color="primary"
307
- type="submit"
308
- disabled={disabled}
309
- >
310
- Save
311
- </Button>
312
- </DialogActions>
313
-
314
- </Form>
315
-
316
- </div>
317
- </>;
318
-
319
- const plugins = customizationController.plugins;
320
- if (plugins) {
321
- // const formController: FormContext<M> = {
322
- // values,
323
- // setFieldValue
324
- // }
325
- plugins.forEach((plugin: FireCMSPlugin) => {
326
- if (plugin.form?.provider) {
327
- internalForm = (
328
- <plugin.form.provider.Component
329
- status={"existing"}
330
- path={path}
331
- collection={collection}
332
- entity={entity}
333
- context={fireCMSContext}
334
- currentEntityId={entityId}
335
- formContext={formContext}
336
- {...plugin.form.provider.props}>
337
- {internalForm}
338
- </plugin.form.provider.Component>
339
- );
340
- }
341
- });
342
- }
343
- return internalForm;
344
- }}
345
- </Formik>
346
-
347
- {savingError &&
348
- <Typography color={"error"}>
349
- {savingError.message}
350
- </Typography>
351
- }
282
+ key={`popup_form_${tableKey}_${entityId}_${propertyKey}`}
283
+ className="w-[560px] max-w-full max-h-[85vh]">
284
+ <form
285
+ onSubmit={handleSubmit}
286
+ noValidate>
287
+
288
+ <div
289
+ className="mb-1 p-4 flex flex-col relative">
290
+ <div
291
+ ref={innerRef}
292
+ className="cursor-auto"
293
+ style={{ cursor: "auto !important" }}>
294
+ {fieldProps &&
295
+ <PropertyFieldBinding {...fieldProps}/>}
296
+ </div>
297
+ </div>
298
+
299
+ <DialogActions>
300
+ <Button
301
+ variant="filled"
302
+ color="primary"
303
+ type="submit"
304
+ disabled={disabled}
305
+ >
306
+ Save
307
+ </Button>
308
+ </DialogActions>
309
+
310
+ </form>
311
+
352
312
  </div>
353
- );
313
+
314
+ </>;
315
+
316
+ const plugins = customizationController.plugins;
317
+ if (plugins) {
318
+ // const formController: FormContext<M> = {
319
+ // values,
320
+ // setFieldValue
321
+ // }
322
+ plugins.forEach((plugin: FireCMSPlugin) => {
323
+ if (plugin.form?.provider) {
324
+ internalForm = (
325
+ <plugin.form.provider.Component
326
+ status={"existing"}
327
+ path={path}
328
+ collection={collection}
329
+ entity={entity}
330
+ context={fireCMSContext}
331
+ currentEntityId={entityId}
332
+ formContext={formContext}
333
+ {...plugin.form.provider.props}>
334
+ {internalForm}
335
+ </plugin.form.provider.Component>
336
+ );
337
+ }
338
+ });
339
+ }
340
+ const form = <div
341
+ className={`text-gray-900 dark:text-white overflow-auto rounded rounded-md bg-white dark:bg-gray-950 ${!open ? "hidden" : ""} cursor-grab max-w-[100vw]`}>
342
+ {internalForm}
343
+
344
+ {savingError &&
345
+ <Typography color={"error"}>
346
+ {savingError.message}
347
+ </Typography>
348
+ }
349
+ </div>;
354
350
 
355
351
  const draggable = (
356
352
  <div
@@ -393,9 +389,10 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
393
389
 
394
390
  return (
395
391
  <Portal.Root asChild
396
- container={container}
397
- >
398
- {draggable}
392
+ container={container}>
393
+ <Formex value={formex}>
394
+ {draggable}
395
+ </Formex>
399
396
  </Portal.Root>
400
397
  );
401
398