@mui/x-data-grid
Version:
The Community plan edition of the Data Grid components (MUI X).
82 lines • 2.94 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["render", "options", "onClick"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
import { useGridComponentRenderer } from "../../hooks/utils/useGridComponentRenderer.js";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* A button that triggers a print export.
* It renders the `baseButton` slot.
*
* Demos:
*
* - [Export](https://mui.com/x/react-data-grid/components/export/)
*
* API:
*
* - [ExportPrint API](https://mui.com/x/api/data-grid/export-print/)
*/
const ExportPrint = forwardRef(function ExportPrint(props, ref) {
const {
render,
options,
onClick
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const rootProps = useGridRootProps();
const apiRef = useGridApiContext();
const handleClick = event => {
apiRef.current.exportDataAsPrint(options);
onClick?.(event);
};
const element = useGridComponentRenderer(rootProps.slots.baseButton, render, _extends({}, rootProps.slotProps?.baseButton, {
onClick: handleClick
}, other, {
ref
}));
return /*#__PURE__*/_jsx(React.Fragment, {
children: element
});
});
process.env.NODE_ENV !== "production" ? ExportPrint.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
className: PropTypes.string,
disabled: PropTypes.bool,
id: PropTypes.string,
/**
* The options to apply on the Print export.
* @demos
* - [Print export](/x/react-data-grid/export/#print-export)
*/
options: PropTypes.shape({
allColumns: PropTypes.bool,
bodyClassName: PropTypes.string,
copyStyles: 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])
}),
/**
* A function to customize rendering of the component.
*/
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
role: PropTypes.string,
size: PropTypes.oneOf(['large', 'medium', 'small']),
startIcon: PropTypes.node,
style: PropTypes.object,
tabIndex: PropTypes.number,
title: PropTypes.string,
touchRippleRef: PropTypes.any
} : void 0;
export { ExportPrint };