@mui/x-data-grid
Version:
The Community plan edition of the MUI X Data Grid components.
72 lines (71 loc) • 2.9 kB
JavaScript
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["render", "onKeyDown", "onFocus", "onBlur", "disabled", "aria-disabled"],
_excluded2 = ["tabIndex"];
import * as React from 'react';
import PropTypes from 'prop-types';
import useForkRef from '@mui/utils/useForkRef';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
import { useRegisterToolbarButton } from '@mui/x-internals/ToolbarContext';
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* A button for performing actions from the toolbar.
* It renders the `baseIconButton` slot.
*
* Demos:
*
* - [Toolbar](https://mui.com/x/react-data-grid/components/toolbar/)
*
* API:
*
* - [ToolbarButton API](https://mui.com/x/api/data-grid/toolbar-button/)
*/
const ToolbarButton = forwardRef(function ToolbarButton(props, ref) {
const {
render
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const rootProps = useGridRootProps();
const buttonRef = React.useRef(null);
const handleRef = useForkRef(buttonRef, ref);
const _useRegisterToolbarBu = useRegisterToolbarButton(props, buttonRef),
{
tabIndex
} = _useRegisterToolbarBu,
toolbarButtonProps = _objectWithoutPropertiesLoose(_useRegisterToolbarBu, _excluded2);
const element = useComponentRenderer(rootProps.slots.baseIconButton, render, _extends({}, rootProps.slotProps?.baseIconButton, {
tabIndex
}, other, toolbarButtonProps, {
ref: handleRef
}));
return /*#__PURE__*/_jsx(React.Fragment, {
children: element
});
});
if (process.env.NODE_ENV !== "production") ToolbarButton.displayName = "ToolbarButton";
process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes /* remove-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,
color: PropTypes.oneOf(['default', 'inherit', 'primary']),
disabled: PropTypes.bool,
edge: PropTypes.oneOf(['end', 'start', false]),
id: PropTypes.string,
label: 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']),
style: PropTypes.object,
tabIndex: PropTypes.number,
title: PropTypes.string,
touchRippleRef: PropTypes.any
} : void 0;
export { ToolbarButton };