UNPKG

@mui/x-data-grid-premium

Version:

The Premium plan edition of the MUI X Data Grid Components.

85 lines 3.06 kB
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 { useComponentRenderer } from '@mui/x-internals/useComponentRenderer'; import { forwardRef } from '@mui/x-internals/forwardRef'; import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js"; import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js"; import { jsx as _jsx } from "react/jsx-runtime"; /** * A button that triggers an Excel export. * It renders the `baseButton` slot. * * Demos: * * - [Export](https://mui.com/x/react-data-grid/components/export/) * * API: * * - [ExportExcel API](https://mui.com/x/api/data-grid/export-excel/) */ const ExportExcel = forwardRef(function ExportExcel(props, ref) { const { render, options, onClick } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const rootProps = useGridRootProps(); const apiRef = useGridApiContext(); const handleClick = event => { apiRef.current.exportDataAsExcel(options); onClick?.(event); }; const element = useComponentRenderer(rootProps.slots.baseButton, render, _extends({ onClick: handleClick }, rootProps.slotProps?.baseButton, other, { ref })); return /*#__PURE__*/_jsx(React.Fragment, { children: element }); }); if (process.env.NODE_ENV !== "production") ExportExcel.displayName = "ExportExcel"; process.env.NODE_ENV !== "production" ? ExportExcel.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 Excel export. * @demos * - [Excel export](/x/react-data-grid/export/#excel-export) */ options: PropTypes.shape({ allColumns: PropTypes.bool, columnsStyles: PropTypes.object, escapeFormulas: PropTypes.bool, exceljsPostProcess: PropTypes.func, exceljsPreProcess: PropTypes.func, fields: PropTypes.arrayOf(PropTypes.string), fileName: PropTypes.string, getRowsToExport: PropTypes.func, includeColumnGroupsHeaders: PropTypes.bool, includeHeaders: PropTypes.bool, valueOptionsSheetName: PropTypes.string, worker: PropTypes.func }), /** * 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 { ExportExcel };