@mui/x-data-grid
Version:
The Community plan edition of the Data Grid components (MUI X).
63 lines (62 loc) • 2.72 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridColumnMenuContainer = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _clsx = _interopRequireDefault(require("clsx"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var React = _interopRequireWildcard(require("react"));
var _MenuList = _interopRequireDefault(require("@mui/material/MenuList"));
var _styles = require("@mui/material/styles");
var _forwardRef = require("@mui/x-internals/forwardRef");
var _keyboardUtils = require("../../../utils/keyboardUtils");
var _gridClasses = require("../../../constants/gridClasses");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["hideMenu", "colDef", "id", "labelledby", "className", "children", "open"];
const StyledMenuList = (0, _styles.styled)(_MenuList.default)(() => ({
minWidth: 248
}));
const GridColumnMenuContainer = exports.GridColumnMenuContainer = (0, _forwardRef.forwardRef)(function GridColumnMenuContainer(props, ref) {
const {
hideMenu,
id,
labelledby,
className,
children,
open
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const handleListKeyDown = React.useCallback(event => {
if (event.key === 'Tab') {
event.preventDefault();
}
if ((0, _keyboardUtils.isHideMenuKey)(event.key)) {
hideMenu(event);
}
}, [hideMenu]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledMenuList, (0, _extends2.default)({
id: id,
className: (0, _clsx.default)(_gridClasses.gridClasses.menuList, className),
"aria-labelledby": labelledby,
onKeyDown: handleListKeyDown,
autoFocus: open
}, other, {
ref: ref,
children: children
}));
});
process.env.NODE_ENV !== "production" ? GridColumnMenuContainer.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
colDef: _propTypes.default.object.isRequired,
hideMenu: _propTypes.default.func.isRequired,
id: _propTypes.default.string,
labelledby: _propTypes.default.string,
open: _propTypes.default.bool.isRequired
} : void 0;
;