UNPKG

@mui/x-data-grid

Version:

The Community plan edition of the Data Grid components (MUI X).

122 lines 4.72 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["hideMenu", "options"], _excluded2 = ["hideMenu", "options"], _excluded3 = ["csvOptions", "printOptions", "excelOptions"]; import * as React from 'react'; import PropTypes from 'prop-types'; import MenuItem from '@mui/material/MenuItem'; import { forwardRef } from '@mui/x-internals/forwardRef'; import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js"; import { GridToolbarExportContainer } from "./GridToolbarExportContainer.js"; import { jsx as _jsx } from "react/jsx-runtime"; function GridCsvExportMenuItem(props) { const apiRef = useGridApiContext(); const { hideMenu, options } = props, other = _objectWithoutPropertiesLoose(props, _excluded); return /*#__PURE__*/_jsx(MenuItem, _extends({ onClick: () => { apiRef.current.exportDataAsCsv(options); hideMenu?.(); } }, other, { children: apiRef.current.getLocaleText('toolbarExportCSV') })); } process.env.NODE_ENV !== "production" ? GridCsvExportMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- hideMenu: PropTypes.func, options: PropTypes.shape({ allColumns: PropTypes.bool, delimiter: PropTypes.string, disableToolbarButton: PropTypes.bool, escapeFormulas: PropTypes.bool, fields: PropTypes.arrayOf(PropTypes.string), fileName: PropTypes.string, getRowsToExport: PropTypes.func, includeColumnGroupsHeaders: PropTypes.bool, includeHeaders: PropTypes.bool, shouldAppendQuotes: PropTypes.bool, utf8WithBom: PropTypes.bool }) } : void 0; function GridPrintExportMenuItem(props) { const apiRef = useGridApiContext(); const { hideMenu, options } = props, other = _objectWithoutPropertiesLoose(props, _excluded2); return /*#__PURE__*/_jsx(MenuItem, _extends({ onClick: () => { apiRef.current.exportDataAsPrint(options); hideMenu?.(); } }, other, { children: apiRef.current.getLocaleText('toolbarExportPrint') })); } process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- hideMenu: PropTypes.func, options: PropTypes.shape({ allColumns: PropTypes.bool, bodyClassName: PropTypes.string, copyStyles: PropTypes.bool, disableToolbarButton: PropTypes.bool, fields: PropTypes.arrayOf(PropTypes.string), fileName: PropTypes.string, getRowsToExport: PropTypes.func, hideFooter: PropTypes.bool, hideToolbar: PropTypes.bool, includeCheckboxes: PropTypes.bool, pageStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.string]) }) } : void 0; const GridToolbarExport = forwardRef(function GridToolbarExport(props, ref) { const _ref = props, { csvOptions = {}, printOptions = {}, excelOptions } = _ref, other = _objectWithoutPropertiesLoose(_ref, _excluded3); const apiRef = useGridApiContext(); const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors('exportMenu', [], { excelOptions, csvOptions, printOptions }).sort((a, b) => a.componentName > b.componentName ? 1 : -1); if (preProcessedButtons.length === 0) { return null; } return /*#__PURE__*/_jsx(GridToolbarExportContainer, _extends({}, other, { ref: ref, children: preProcessedButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button.component, { key: index })) })); }); process.env.NODE_ENV !== "production" ? GridToolbarExport.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "pnpm proptypes" | // ---------------------------------------------------------------------- csvOptions: PropTypes.object, printOptions: PropTypes.object, /** * The props used for each slot inside. * @default {} */ slotProps: PropTypes.object } : void 0; export { GridToolbarExport, GridCsvExportMenuItem, GridPrintExportMenuItem };