import * as React from "react";
import MuiPopover from "@mui/material/Popover";
import { memo, useContext } from "react";
import { inputProps } from "../interface/inputfieldProps";
import _ from "lodash";
import { JsonFormsDispatch, withJsonFormsControlProps } from "@jsonforms/react";
import { DataContext } from "../context/Context";
import { Box } from "@mui/system";
import Grid from "@mui/material/Grid2";
const Popover = memo(function (props: inputProps) {
const { enabled, uischema, path, cells, schema, renderers } = props;
const { dialog, updateDialog, theme, targetElementMap } = useContext(DataContext);
const uischemaData = uischema?.config?.main;
const handleClose = () => {
updateDialog(path);
};
const getElements = (UiSchemaElem: any, i: number) => {
const scopeArray: string[] = UiSchemaElem.scope?.split("/");
const actualElemPath: string = scopeArray
? scopeArray[scopeArray.length - 1]
: UiSchemaElem.scope;
const widget = _.cloneDeep(UiSchemaElem);
widget.config.main.additionalData = {
...widget?.config?.main?.additionalData,
tableButtonPath: actualElemPath,
};
return (
);
};
const Content = uischema?.elements?.map((e: any, i: number) => {
return getElements(e, i);
});
return (
{Content}
);
});
export default withJsonFormsControlProps(Popover);