@firecms/core 3.0.0-canary.166 → 3.0.0-canary.168

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.
@@ -12,7 +12,7 @@ export interface DialogsController {
12
12
  * Open a dialog
13
13
  * @param props
14
14
  */
15
- open: (props: DialogControllerEntryProps) => {
15
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
16
16
  closeDialog: () => void;
17
17
  };
18
18
  }
@@ -20,7 +20,7 @@ export interface DialogsController {
20
20
  * Props used to open a side dialog
21
21
  * @group Hooks and utilities
22
22
  */
23
- export interface DialogControllerEntryProps {
23
+ export interface DialogControllerEntryProps<T extends object = object> {
24
24
  key: string;
25
25
  /**
26
26
  * The component type that will be rendered
@@ -28,5 +28,9 @@ export interface DialogControllerEntryProps {
28
28
  Component: React.ComponentType<{
29
29
  open: boolean;
30
30
  closeDialog: () => void;
31
- }>;
31
+ } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
32
36
  }
@@ -4,6 +4,7 @@ import { Entity } from "./entities";
4
4
  import { EntityCollection, SelectionController } from "./collections";
5
5
  import { User } from "./user";
6
6
  import { SideEntityController } from "./side_entity_controller";
7
+ import { FormContext } from "./fields";
7
8
  /**
8
9
  * An entity action is a custom action that can be performed on an entity.
9
10
  * They are displayed in the entity view and in the collection view.
@@ -55,4 +56,9 @@ export type EntityActionClickProps<M extends object, USER extends User = User> =
55
56
  * If this actions is being called from a side dialog
56
57
  */
57
58
  sideEntityController?: SideEntityController;
59
+ /**
60
+ * You can use the form context to manage the state of the form.
61
+ * This is only available if this action in being triggered from a form context.
62
+ */
63
+ formContext?: FormContext<M>;
58
64
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.166",
4
+ "version": "3.0.0-canary.168",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -50,9 +50,9 @@
50
50
  "./package.json": "./package.json"
51
51
  },
52
52
  "dependencies": {
53
- "@firecms/editor": "^3.0.0-canary.166",
54
- "@firecms/formex": "^3.0.0-canary.166",
55
- "@firecms/ui": "^3.0.0-canary.166",
53
+ "@firecms/editor": "^3.0.0-canary.168",
54
+ "@firecms/formex": "^3.0.0-canary.168",
55
+ "@firecms/ui": "^3.0.0-canary.168",
56
56
  "@hello-pangea/dnd": "^17.0.0",
57
57
  "@radix-ui/react-portal": "^1.1.2",
58
58
  "clsx": "^2.1.1",
@@ -106,7 +106,7 @@
106
106
  "dist",
107
107
  "src"
108
108
  ],
109
- "gitHead": "c01f9b33c2738db9c1ffe8079f85ea70894ead41",
109
+ "gitHead": "81a6eef43477c31b82713fc044e4836838ed74bb",
110
110
  "publishConfig": {
111
111
  "access": "public"
112
112
  },
@@ -8,7 +8,7 @@ export const DialogsProvider: React.FC<PropsWithChildren<{}>> = ({ children }) =
8
8
  const [dialogEntries, setDialogEntries] = useState<DialogControllerEntryProps[]>([]);
9
9
  const dialogEntriesRef = useRef<DialogControllerEntryProps[]>(dialogEntries);
10
10
 
11
- const updateDialogEntries = (newPanels: DialogControllerEntryProps[]) => {
11
+ const updateDialogEntries = (newPanels: DialogControllerEntryProps<any>[]) => {
12
12
  dialogEntriesRef.current = newPanels;
13
13
  setDialogEntries(newPanels);
14
14
  };
@@ -23,7 +23,7 @@ export const DialogsProvider: React.FC<PropsWithChildren<{}>> = ({ children }) =
23
23
 
24
24
  }, [dialogEntries]);
25
25
 
26
- const open = useCallback((dialogEntry: DialogControllerEntryProps) => {
26
+ const open = useCallback(<T extends object = object>(dialogEntry: DialogControllerEntryProps<T>) => {
27
27
 
28
28
  const updatedPanels = [...dialogEntriesRef.current, dialogEntry];
29
29
  updateDialogEntries(updatedPanels);
@@ -46,6 +46,7 @@ export const DialogsProvider: React.FC<PropsWithChildren<{}>> = ({ children }) =
46
46
  key={`dialog_${i}`}
47
47
  open={true}
48
48
  closeDialog={close}
49
+ {...entry.props}
49
50
  />)}
50
51
  </DialogsControllerContext.Provider>
51
52
  );
@@ -842,14 +842,17 @@ export function EntityEditViewInner<M extends Record<string, any>>({
842
842
  fullPath: resolvedCollection.path,
843
843
  collection: resolvedCollection,
844
844
  context,
845
- sideEntityController
845
+ sideEntityController,
846
+ formContext
846
847
  });
847
848
  }}>
848
849
  {action.icon}
849
850
  </IconButton>
850
851
  ))}
851
852
  </div>}
853
+
852
854
  {formex.isSubmitting && <CircularProgress size={"small"}/>}
855
+
853
856
  <Button
854
857
  variant="text"
855
858
  disabled={disabled || formex.isSubmitting}
@@ -15,19 +15,23 @@ export interface DialogsController {
15
15
  * Open a dialog
16
16
  * @param props
17
17
  */
18
- open: (props: DialogControllerEntryProps) => { closeDialog: () => void };
18
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => { closeDialog: () => void };
19
19
  }
20
20
 
21
21
  /**
22
22
  * Props used to open a side dialog
23
23
  * @group Hooks and utilities
24
24
  */
25
- export interface DialogControllerEntryProps {
25
+ export interface DialogControllerEntryProps<T extends object = object> {
26
26
 
27
27
  key: string;
28
28
  /**
29
29
  * The component type that will be rendered
30
30
  */
31
- Component: React.ComponentType<{ open: boolean, closeDialog: () => void }>;
31
+ Component: React.ComponentType<{ open: boolean, closeDialog: () => void } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
32
36
 
33
37
  }
@@ -4,6 +4,8 @@ import { Entity } from "./entities";
4
4
  import { EntityCollection, SelectionController } from "./collections";
5
5
  import { User } from "./user";
6
6
  import { SideEntityController } from "./side_entity_controller";
7
+ import { FormexController } from "@firecms/formex";
8
+ import { FormContext } from "./fields";
7
9
 
8
10
  /**
9
11
  * An entity action is a custom action that can be performed on an entity.
@@ -63,4 +65,10 @@ export type EntityActionClickProps<M extends object, USER extends User = User> =
63
65
  * If this actions is being called from a side dialog
64
66
  */
65
67
  sideEntityController?: SideEntityController;
68
+
69
+ /**
70
+ * You can use the form context to manage the state of the form.
71
+ * This is only available if this action in being triggered from a form context.
72
+ */
73
+ formContext?: FormContext<M>;
66
74
  };