import { useRef, forwardRef } from "react"; import { Dialog, DialogFooter, Panel, PanelType } from '@fluentui/react'; import React from "react"; import { Form, FormBuilderListEditorType, IDynamicSchemaConfig, IFormBuilderListEditorConfig, IFormItem, IFormListProps } from "@wiberg/formbuilder"; import { FluentDialogContentWrapper } from "./components/FluentDialogContentWrapper"; export interface IFluentDialogProps { item: T; editorConfig?: IFormBuilderListEditorConfig; newItemMode: boolean; keyPrefix: string; show: (show: boolean) => void; onRenderFooterContent: () => JSX.Element; formListProps: IFormListProps; } export const FluentDialog = forwardRef((props : IFluentDialogProps, ref: FormRef) => { return ( props.editorConfig?.containerOptions.type == FormBuilderListEditorType.Dialog ? : props.show(false) } isLightDismiss={false} type={ (props.editorConfig?.containerOptions.panelSize as any) as PanelType ?? PanelType.medium } customWidth={props.editorConfig?.containerOptions.customWidth} className="formbuilder-panel formbuilder-panel-editor" headerText={props.editorConfig?.title(props.item, props.newItemMode)} layerProps={{}} overlayProps={{}} focusTrapZoneProps={{}} isBlocking={true} onOuterClick={ (e: any) => {e.preventDefault(); e.stopPropagation(); return false; }} onRenderFooterContent={props.onRenderFooterContent} isFooterAtBottom={true} styles={{ header: { paddingBottom: "30px" }, footerInner: { borderTop: "1px solid rgb(237, 235, 233)" } }} > } validationResult={undefined} // reset to avoid saving "old" validation results when cancelling item={props.editorConfig?.dynamicForm?.useEmptyItem ? {} : props.item ?? {}} dynamicSchema={ props.editorConfig?.dynamicForm == null ? undefined : { // semi-override dynamickey function, due to item reset, if using 'useEmptyItem' dynamicKey: (item: T) => props.editorConfig?.dynamicForm?.dynamicKey(item != null && Object.keys(item).length ? item : props.item), schemaConfig: props.editorConfig?.dynamicForm?.schemaConfig } as IDynamicSchemaConfig } /> ) })