85 lines
2.9 KiB
JavaScript
85 lines
2.9 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
const _excluded = ["render", "className"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { styled } from '@mui/material/styles';
|
|
import composeClasses from '@mui/utils/composeClasses';
|
|
import clsx from 'clsx';
|
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
import { ToolbarContextProvider } from '@mui/x-internals/ToolbarContext';
|
|
import { vars } from "../../constants/cssVariables.mjs";
|
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.mjs";
|
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
const useUtilityClasses = ownerState => {
|
|
const {
|
|
classes
|
|
} = ownerState;
|
|
const slots = {
|
|
root: ['toolbar']
|
|
};
|
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
};
|
|
const ToolbarRoot = styled('div', {
|
|
name: 'MuiDataGrid',
|
|
slot: 'Toolbar'
|
|
})({
|
|
flex: '0 1 1px',
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'end',
|
|
gap: vars.spacing(0.25),
|
|
padding: vars.spacing(0.75),
|
|
minHeight: 52,
|
|
boxSizing: 'border-box',
|
|
borderBottom: `1px solid ${vars.colors.border.base}`
|
|
});
|
|
|
|
/**
|
|
* The top level Toolbar component that provides context to child components.
|
|
* It renders a styled `<div />` element.
|
|
*
|
|
* Demos:
|
|
*
|
|
* - [Toolbar](https://mui.com/x/react-data-grid/components/toolbar/)
|
|
*
|
|
* API:
|
|
*
|
|
* - [Toolbar API](https://mui.com/x/api/data-grid/toolbar/)
|
|
*/
|
|
const Toolbar = forwardRef(function Toolbar(props, ref) {
|
|
const {
|
|
render,
|
|
className
|
|
} = props,
|
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
const rootProps = useGridRootProps();
|
|
const classes = useUtilityClasses(rootProps);
|
|
const element = useComponentRenderer(ToolbarRoot, render, _extends({
|
|
role: 'toolbar',
|
|
'aria-orientation': 'horizontal',
|
|
'aria-label': rootProps.label || undefined,
|
|
className: clsx(classes.root, className)
|
|
}, other, {
|
|
ref
|
|
}));
|
|
return /*#__PURE__*/_jsx(ToolbarContextProvider, {
|
|
children: element
|
|
});
|
|
});
|
|
if (process.env.NODE_ENV !== "production") Toolbar.displayName = "Toolbar";
|
|
process.env.NODE_ENV !== "production" ? Toolbar.propTypes /* remove-proptypes */ = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
/**
|
|
* A function to customize rendering of the component.
|
|
*/
|
|
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
} : void 0;
|
|
export { Toolbar }; |