var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { makeStyles } from '@material-ui/core';
import clsx from 'clsx';
import React, { forwardRef, useState } from 'react';
import { AmbientTemplateGrid } from 'udp-react-stencil-component-library';
import { ExportSidesheet } from '../../../../udp/export/ExportSidesheet';
import { useUdpExport } from '../../../../udp/export/useUdpExport';
const useStyles = makeStyles((theme) => ({
    root: {}
}));
export const UdpGridTemplate = forwardRef((props, ref) => {
    const { children } = props, otherProps = __rest(props, ["children"]);
    const classes = useStyles(props);
    const { className } = props;
    const [exportSidesheetOpen, setExportSidesheetOpen] = useState(false);
    const { updateExportParameters, createExport, entity, searchObject, fileFormat, numRowsToExport, validSearch, errorList, activeExportJob, exportLoading, handleFileDownload, clearParameters } = useUdpExport();
    const exportFromGrid = (entity, searchObject) => {
        updateExportParameters(entity, searchObject);
        setExportSidesheetOpen(true);
    };
    const handleCloseExportSidesheet = () => {
        setExportSidesheetOpen(false);
        clearParameters();
    };
    return (React.createElement("div", { className: clsx(classes.root, className) }, React.createElement(AmbientTemplateGrid, Object.assign({ ref: ref }, otherProps, { exportFunction: exportFromGrid })), React.createElement(ExportSidesheet, { entity: entity, searchObject: searchObject, fileFormat: fileFormat, numRowsToExport: numRowsToExport, errorList: errorList, activeExportJob: activeExportJob, handleFileDownload: handleFileDownload, exportSidesheetOpen: exportSidesheetOpen, handleCloseExportSidesheet: handleCloseExportSidesheet, createExport: createExport, exportLoading: exportLoading, validSearch: validSearch })));
});
UdpGridTemplate.displayName = 'UdpGridTemplate';
//# sourceMappingURL=UdpGridTemplate.js.map