@mui/x-data-grid-premium
Version:
The Premium plan edition of the MUI X Data Grid Components.
61 lines • 3.1 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["excelOptions"];
import * as React from 'react';
import { GridToolbar } from '@mui/x-data-grid-pro/internals';
import { ToolbarButton } from '@mui/x-data-grid-pro';
import { ExportExcel } from "./export/index.js";
import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
import { PivotPanelTrigger } from "./pivotPanel/PivotPanelTrigger.js";
import { AiAssistantPanelTrigger } from "./aiAssistantPanel/index.js";
import { ChartsPanelTrigger } from "./chartsPanel/ChartsPanelTrigger.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function GridPremiumToolbar(props) {
const rootProps = useGridRootProps();
const apiRef = useGridApiContext();
const other = _objectWithoutPropertiesLoose(props, _excluded);
const additionalItems = /*#__PURE__*/_jsxs(React.Fragment, {
children: [!rootProps.disablePivoting && /*#__PURE__*/_jsx(PivotPanelTrigger, {
render: (triggerProps, state) => /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
title: apiRef.current.getLocaleText('toolbarPivot'),
children: /*#__PURE__*/_jsx(ToolbarButton, _extends({}, triggerProps, {
color: state.active ? 'primary' : 'default',
children: /*#__PURE__*/_jsx(rootProps.slots.pivotIcon, {
fontSize: "small"
})
}))
})
}), rootProps.experimentalFeatures?.charts && rootProps.chartsIntegration && /*#__PURE__*/_jsx(ChartsPanelTrigger, {
render: triggerProps => /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
title: apiRef.current.getLocaleText('toolbarCharts'),
children: /*#__PURE__*/_jsx(ToolbarButton, _extends({}, triggerProps, {
color: "default",
children: /*#__PURE__*/_jsx(rootProps.slots.chartsIcon, {
fontSize: "small"
})
}))
})
}), rootProps.aiAssistant && /*#__PURE__*/_jsx(AiAssistantPanelTrigger, {
render: triggerProps => /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
title: apiRef.current.getLocaleText('toolbarAssistant'),
children: /*#__PURE__*/_jsx(ToolbarButton, _extends({}, triggerProps, {
color: "default",
children: /*#__PURE__*/_jsx(rootProps.slots.aiAssistantIcon, {
fontSize: "small"
})
}))
})
})]
});
const additionalExportMenuItems = !props.excelOptions?.disableToolbarButton ? onMenuItemClick => /*#__PURE__*/_jsx(ExportExcel, {
render: /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, _extends({}, rootProps.slotProps?.baseMenuItem)),
options: props.excelOptions,
onClick: onMenuItemClick,
children: apiRef.current.getLocaleText('toolbarExportExcel')
}) : undefined;
return /*#__PURE__*/_jsx(GridToolbar, _extends({}, other, {
additionalItems: additionalItems,
additionalExportMenuItems: additionalExportMenuItems
}));
}