wip:milestone 0 fixes
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped

This commit is contained in:
2026-03-15 12:35:42 +02:00
parent 6708cf28a7
commit cffdf8af86
61266 changed files with 4511646 additions and 1938 deletions

View File

@@ -0,0 +1,264 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridActionsCell = GridActionsCell;
exports.renderActionsCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _MenuList = _interopRequireDefault(require("@mui/material/MenuList"));
var _styles = require("@mui/material/styles");
var _utils = require("@mui/utils");
var _gridClasses = require("../../constants/gridClasses");
var _GridMenu = require("../menu/GridMenu");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["api", "colDef", "id", "hasFocus", "isEditable", "field", "value", "formattedValue", "row", "rowNode", "cellMode", "tabIndex", "position", "focusElementRef"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const hasActions = colDef => typeof colDef.getActions === 'function';
function GridActionsCell(props) {
const {
colDef,
id,
hasFocus,
tabIndex,
position = 'bottom-end',
focusElementRef
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const [focusedButtonIndex, setFocusedButtonIndex] = React.useState(-1);
const [open, setOpen] = React.useState(false);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootRef = React.useRef(null);
const buttonRef = React.useRef(null);
const ignoreCallToFocus = React.useRef(false);
const touchRippleRefs = React.useRef({});
const theme = (0, _styles.useTheme)();
const menuId = (0, _utils.unstable_useId)();
const buttonId = (0, _utils.unstable_useId)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
if (!hasActions(colDef)) {
throw new Error('MUI: Missing the `getActions` property in the `GridColDef`.');
}
const options = colDef.getActions(apiRef.current.getRowParams(id));
const iconButtons = options.filter(option => !option.props.showInMenu);
const menuButtons = options.filter(option => option.props.showInMenu);
const numberOfButtons = iconButtons.length + (menuButtons.length ? 1 : 0);
React.useLayoutEffect(() => {
if (!hasFocus) {
Object.entries(touchRippleRefs.current).forEach(([index, ref]) => {
ref?.stop({}, () => {
delete touchRippleRefs.current[index];
});
});
}
}, [hasFocus]);
React.useEffect(() => {
if (focusedButtonIndex < 0 || !rootRef.current) {
return;
}
if (focusedButtonIndex >= rootRef.current.children.length) {
return;
}
const child = rootRef.current.children[focusedButtonIndex];
child.focus({
preventScroll: true
});
}, [focusedButtonIndex]);
React.useEffect(() => {
if (!hasFocus) {
setFocusedButtonIndex(-1);
ignoreCallToFocus.current = false;
}
}, [hasFocus]);
React.useImperativeHandle(focusElementRef, () => ({
focus() {
// If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
if (!ignoreCallToFocus.current) {
// find the first focusable button and pass the index to the state
const focusableButtonIndex = options.findIndex(o => !o.props.disabled);
setFocusedButtonIndex(focusableButtonIndex);
}
}
}), [options]);
React.useEffect(() => {
if (focusedButtonIndex >= numberOfButtons) {
setFocusedButtonIndex(numberOfButtons - 1);
}
}, [focusedButtonIndex, numberOfButtons]);
const showMenu = () => {
setOpen(true);
setFocusedButtonIndex(numberOfButtons - 1);
ignoreCallToFocus.current = true;
};
const hideMenu = () => {
setOpen(false);
};
const handleTouchRippleRef = index => instance => {
touchRippleRefs.current[index] = instance;
};
const handleButtonClick = (index, onClick) => event => {
setFocusedButtonIndex(index);
ignoreCallToFocus.current = true;
if (onClick) {
onClick(event);
}
};
const handleRootKeyDown = event => {
if (numberOfButtons <= 1) {
return;
}
const getNewIndex = (index, direction) => {
if (index < 0 || index > options.length) {
return index;
}
// for rtl mode we need to reverse the direction
const rtlMod = theme.direction === 'rtl' ? -1 : 1;
const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
// if the button that should receive focus is disabled go one more step
return options[index + indexMod]?.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
};
let newIndex = focusedButtonIndex;
if (event.key === 'ArrowRight') {
newIndex = getNewIndex(focusedButtonIndex, 'right');
} else if (event.key === 'ArrowLeft') {
newIndex = getNewIndex(focusedButtonIndex, 'left');
}
if (newIndex < 0 || newIndex >= numberOfButtons) {
return; // We're already in the first or last item = do nothing and let the grid listen the event
}
if (newIndex !== focusedButtonIndex) {
event.preventDefault(); // Prevent scrolling
event.stopPropagation(); // Don't stop propagation for other keys, e.g. ArrowUp
setFocusedButtonIndex(newIndex);
}
};
const handleListKeyDown = event => {
if (event.key === 'Tab') {
event.preventDefault();
}
if (['Tab', 'Escape'].includes(event.key)) {
hideMenu();
}
};
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _extends2.default)({
role: "menu",
ref: rootRef,
tabIndex: -1,
className: _gridClasses.gridClasses.actionsCell,
onKeyDown: handleRootKeyDown
}, other, {
children: [iconButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button, {
key: index,
touchRippleRef: handleTouchRippleRef(index),
onClick: handleButtonClick(index, button.props.onClick),
tabIndex: focusedButtonIndex === index ? tabIndex : -1
})), menuButtons.length > 0 && buttonId && /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
ref: buttonRef,
id: buttonId,
"aria-label": apiRef.current.getLocaleText('actionsCellMore'),
"aria-haspopup": "menu",
"aria-expanded": open,
"aria-controls": open ? menuId : undefined,
role: "menuitem",
size: "small",
onClick: showMenu,
touchRippleRef: handleTouchRippleRef(buttonId),
tabIndex: focusedButtonIndex === iconButtons.length ? tabIndex : -1
}, rootProps.slotProps?.baseIconButton, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.moreActionsIcon, {
fontSize: "small"
})
})), menuButtons.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridMenu.GridMenu, {
open: open,
target: buttonRef.current,
position: position,
onClose: hideMenu,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuList.default, {
id: menuId,
className: _gridClasses.gridClasses.menuList,
onKeyDown: handleListKeyDown,
"aria-labelledby": buttonId,
variant: "menu",
autoFocusItem: true,
children: menuButtons.map((button, index) => /*#__PURE__*/React.cloneElement(button, {
key: index,
closeMenu: hideMenu
}))
})
})]
}));
}
process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
api: _propTypes.default.object,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* A ref allowing to set imperative focus.
* It can be passed to the element that should receive focus.
* @ignore - do not document.
*/
focusElementRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
current: _propTypes.default.shape({
focus: _propTypes.default.func.isRequired
})
})]),
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
position: _propTypes.default.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const renderActionsCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridActionsCell, (0, _extends2.default)({}, params));
exports.renderActionsCell = renderActionsCell;

View File

@@ -0,0 +1,80 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridActionsCellItem = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["label", "icon", "showInMenu", "onClick"],
_excluded2 = ["label", "icon", "showInMenu", "onClick", "closeMenuOnClick", "closeMenu"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const GridActionsCellItem = exports.GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
const rootProps = (0, _useGridRootProps.useGridRootProps)();
if (!props.showInMenu) {
const {
label,
icon,
onClick
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const handleClick = event => {
onClick?.(event);
};
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
ref: ref,
size: "small",
role: "menuitem",
"aria-label": label
}, other, {
onClick: handleClick
}, rootProps.slotProps?.baseIconButton, {
children: /*#__PURE__*/React.cloneElement(icon, {
fontSize: 'small'
})
}));
}
const {
label,
icon,
onClick,
closeMenuOnClick = true,
closeMenu
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded2);
const handleClick = event => {
onClick?.(event);
if (closeMenuOnClick) {
closeMenu?.();
}
};
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_MenuItem.default, (0, _extends2.default)({
ref: ref
}, other, {
onClick: handleClick,
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon.default, {
children: icon
}), label]
}));
});
process.env.NODE_ENV !== "production" ? GridActionsCellItem.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component
*/
component: _propTypes.default.elementType,
icon: _propTypes.default.element,
label: _propTypes.default.string.isRequired,
showInMenu: _propTypes.default.bool
} : void 0;

View File

@@ -0,0 +1,121 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.renderBooleanCell = exports.GridBooleanCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _utils = require("@mui/utils");
var _gridClasses = require("../../constants/gridClasses");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _gridRowsUtils = require("../../hooks/features/rows/gridRowsUtils");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "hasFocus", "tabIndex"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['booleanCell']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
function GridBooleanCellRaw(props) {
const {
value
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const Icon = React.useMemo(() => value ? rootProps.slots.booleanCellTrueIcon : rootProps.slots.booleanCellFalseIcon, [rootProps.slots.booleanCellFalseIcon, rootProps.slots.booleanCellTrueIcon, value]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, (0, _extends2.default)({
fontSize: "small",
className: classes.root,
titleAccess: apiRef.current.getLocaleText(value ? 'booleanCellTrueLabel' : 'booleanCellFalseLabel'),
"data-value": Boolean(value)
}, other));
}
process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* GridApi that let you manipulate the grid.
*/
api: _propTypes.default.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* A ref allowing to set imperative focus.
* It can be passed to the element that should receive focus.
* @ignore - do not document.
*/
focusElementRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
current: _propTypes.default.shape({
focus: _propTypes.default.func.isRequired
})
})]),
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const GridBooleanCell = exports.GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
const renderBooleanCell = params => {
if ((0, _gridRowsUtils.isAutoGeneratedRow)(params.rowNode)) {
return '';
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridBooleanCell, (0, _extends2.default)({}, params));
};
exports.renderBooleanCell = renderBooleanCell;

View File

@@ -0,0 +1,655 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridCellWrapper = exports.GridCellV7 = exports.GridCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _utils = require("@mui/utils");
var _fastMemo = require("../../utils/fastMemo");
var _doesSupportPreventScroll = require("../../utils/doesSupportPreventScroll");
var _gridClasses = require("../../constants/gridClasses");
var _models = require("../../models");
var _useGridSelector = require("../../hooks/utils/useGridSelector");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["changeReason", "unstable_updateValueOnRender"],
_excluded2 = ["align", "children", "editCellState", "colIndex", "column", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "style", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
_excluded3 = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "isNotVisible", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver", "style"],
_excluded4 = ["changeReason", "unstable_updateValueOnRender"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const EMPTY_CELL_PARAMS = {
id: -1,
field: '__unset__',
row: {},
rowNode: {
id: -1,
depth: 0,
type: 'leaf',
parent: -1,
groupingKey: null
},
colDef: {
type: 'string',
field: '__unset__',
computedWidth: 0
},
cellMode: _models.GridCellModes.View,
hasFocus: false,
tabIndex: -1,
value: null,
formattedValue: '__unset__',
isEditable: false,
api: {}
};
const useUtilityClasses = ownerState => {
const {
align,
showRightBorder,
isEditable,
isSelected,
isSelectionMode,
classes
} = ownerState;
const slots = {
root: ['cell', `cell--text${(0, _utils.unstable_capitalize)(align)}`, isEditable && 'cell--editable', isSelected && 'selected', showRightBorder && 'cell--withRightBorder', isSelectionMode && !isEditable && 'cell--selectionMode', 'withBorderColor'],
content: ['cellContent']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
let warnedOnce = false;
// GridCellWrapper is a compatibility layer for the V6 cell slot. If we can use the more efficient
// `GridCellV7`, we should. That component is a merge of `GridCellWrapper` and `GridCell`.
// TODO(v7): Remove the wrapper & cellV6 and use the cellV7 exclusively.
// TODO(v7): Removing the wrapper will break the docs performance visualization demo.
const GridCellWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
const {
column,
rowId,
editCellState
} = props;
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const field = column.field;
const cellParamsWithAPI = (0, _useGridSelector.useGridSelector)(apiRef, () => {
// This is required because `.getCellParams` tries to get the `state.rows.tree` entry
// associated with `rowId`/`fieldId`, but this selector runs after the state has been
// updated, while `rowId`/`fieldId` reference an entry in the old state.
try {
const cellParams = apiRef.current.getCellParams(rowId, field);
const result = cellParams;
result.api = apiRef.current;
return result;
} catch (e) {
if (e instanceof _useGridParamsApi.MissingRowIdError) {
return EMPTY_CELL_PARAMS;
}
throw e;
}
}, _useGridSelector.objectShallowCompare);
const isSelected = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
id: rowId,
field
}));
if (cellParamsWithAPI === EMPTY_CELL_PARAMS) {
return null;
}
const {
cellMode,
hasFocus,
isEditable,
value,
formattedValue
} = cellParamsWithAPI;
const managesOwnFocus = column.type === 'actions';
const tabIndex = (cellMode === 'view' || !isEditable) && !managesOwnFocus ? cellParamsWithAPI.tabIndex : -1;
const {
classes: rootClasses,
getCellClassName
} = rootProps;
const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
id: rowId,
field
});
if (column.cellClassName) {
classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
}
if (getCellClassName) {
classNames.push(getCellClassName(cellParamsWithAPI));
}
let children;
if (editCellState == null && column.renderCell) {
children = column.renderCell(cellParamsWithAPI);
classNames.push(_gridClasses.gridClasses['cell--withRenderer']);
classNames.push(rootClasses?.['cell--withRenderer']);
}
if (editCellState != null && column.renderEditCell) {
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
// eslint-disable-next-line @typescript-eslint/naming-convention
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded);
const params = (0, _extends2.default)({}, cellParamsWithAPI, {
row: updatedRow
}, editCellStateRest);
children = column.renderEditCell(params);
classNames.push(_gridClasses.gridClasses['cell--editing']);
classNames.push(rootClasses?.['cell--editing']);
}
const {
slots
} = rootProps;
const CellComponent = slots.cell;
const cellProps = (0, _extends2.default)({}, props, {
ref,
field,
formattedValue,
hasFocus,
isEditable,
isSelected,
value,
cellMode,
children,
tabIndex,
className: (0, _clsx.default)(classNames)
});
return /*#__PURE__*/React.createElement(CellComponent, cellProps);
});
const GridCell = exports.GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
const {
align,
children: childrenProp,
colIndex,
column,
cellMode,
field,
formattedValue,
hasFocus,
height,
isEditable,
isSelected,
rowId,
tabIndex,
style: styleProp,
value,
width,
className,
showRightBorder,
colSpan,
disableDragEvents,
isNotVisible,
onClick,
onDoubleClick,
onMouseDown,
onMouseUp,
onMouseOver,
onKeyDown,
onKeyUp,
onDragEnter,
onDragOver
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded2);
const valueToRender = formattedValue == null ? value : formattedValue;
const cellRef = React.useRef(null);
const handleRef = (0, _utils.unstable_useForkRef)(ref, cellRef);
const focusElementRef = React.useRef(null);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
align,
showRightBorder,
isEditable,
classes: rootProps.classes,
isSelected
};
const classes = useUtilityClasses(ownerState);
const publishMouseUp = React.useCallback(eventName => event => {
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (onMouseUp) {
onMouseUp(event);
}
}, [apiRef, field, onMouseUp, rowId]);
const publishMouseDown = React.useCallback(eventName => event => {
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (onMouseDown) {
onMouseDown(event);
}
}, [apiRef, field, onMouseDown, rowId]);
const publish = React.useCallback((eventName, propHandler) => event => {
// The row might have been deleted during the click
if (!apiRef.current.getRow(rowId)) {
return;
}
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (propHandler) {
propHandler(event);
}
}, [apiRef, field, rowId]);
const style = React.useMemo(() => {
if (isNotVisible) {
return {
padding: 0,
opacity: 0,
width: 0,
border: 0
};
}
const cellStyle = (0, _extends2.default)({
minWidth: width,
maxWidth: width,
minHeight: height,
maxHeight: height === 'auto' ? 'none' : height
}, styleProp);
return cellStyle;
}, [width, height, isNotVisible, styleProp]);
React.useEffect(() => {
if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
return;
}
const doc = (0, _utils.unstable_ownerDocument)(apiRef.current.rootElementRef.current);
if (cellRef.current && !cellRef.current.contains(doc.activeElement)) {
const focusableElement = cellRef.current.querySelector('[tabindex="0"]');
const elementToFocus = focusElementRef.current || focusableElement || cellRef.current;
if ((0, _doesSupportPreventScroll.doesSupportPreventScroll)()) {
elementToFocus.focus({
preventScroll: true
});
} else {
const scrollPosition = apiRef.current.getScrollPosition();
elementToFocus.focus();
apiRef.current.scroll(scrollPosition);
}
}
}, [hasFocus, cellMode, apiRef]);
let handleFocus = other.onFocus;
if (process.env.NODE_ENV === 'test' && rootProps.experimentalFeatures?.warnIfFocusStateIsNotSynced) {
handleFocus = event => {
const focusedCell = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
if (focusedCell?.id === rowId && focusedCell.field === field) {
if (typeof other.onFocus === 'function') {
other.onFocus(event);
}
return;
}
if (!warnedOnce) {
console.warn([`MUI: The cell with id=${rowId} and field=${field} received focus.`, `According to the state, the focus should be at id=${focusedCell?.id}, field=${focusedCell?.field}.`, "Not syncing the state may cause unwanted behaviors since the `cellFocusIn` event won't be fired.", 'Call `fireEvent.mouseUp` before the `fireEvent.click` to sync the focus with the state.'].join('\n'));
warnedOnce = true;
}
};
}
const managesOwnFocus = column.type === 'actions';
let children = childrenProp;
if (children === undefined) {
const valueString = valueToRender?.toString();
children = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: classes.content,
title: valueString,
role: "presentation",
children: valueString
});
}
if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
children = /*#__PURE__*/React.cloneElement(children, {
focusElementRef
});
}
const draggableEventHandlers = disableDragEvents ? null : {
onDragEnter: publish('cellDragEnter', onDragEnter),
onDragOver: publish('cellDragOver', onDragOver)
};
const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
return (
/*#__PURE__*/
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
ref: handleRef,
className: (0, _clsx.default)(className, classes.root),
role: ariaV7 ? 'gridcell' : 'cell',
"data-field": field,
"data-colindex": colIndex,
"aria-colindex": colIndex + 1,
"aria-colspan": colSpan,
style: style,
tabIndex: tabIndex,
onClick: publish('cellClick', onClick),
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
onMouseOver: publish('cellMouseOver', onMouseOver),
onMouseDown: publishMouseDown('cellMouseDown'),
onMouseUp: publishMouseUp('cellMouseUp'),
onKeyDown: publish('cellKeyDown', onKeyDown),
onKeyUp: publish('cellKeyUp', onKeyUp)
}, draggableEventHandlers, other, {
onFocus: handleFocus,
children: children
}))
);
});
const MemoizedCellWrapper = exports.GridCellWrapper = (0, _fastMemo.fastMemo)(GridCellWrapper);
process.env.NODE_ENV !== "production" ? GridCellWrapper.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
align: _propTypes.default.oneOf(['center', 'left', 'right']),
className: _propTypes.default.string,
colIndex: _propTypes.default.number,
colSpan: _propTypes.default.number,
column: _propTypes.default.object,
disableDragEvents: _propTypes.default.bool,
height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
onClick: _propTypes.default.func,
onDoubleClick: _propTypes.default.func,
onDragEnter: _propTypes.default.func,
onDragOver: _propTypes.default.func,
onKeyDown: _propTypes.default.func,
onMouseDown: _propTypes.default.func,
onMouseUp: _propTypes.default.func,
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
showRightBorder: _propTypes.default.bool,
width: _propTypes.default.number
} : void 0;
process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
align: _propTypes.default.oneOf(['center', 'left', 'right']),
cellMode: _propTypes.default.oneOf(['edit', 'view']),
children: _propTypes.default.node,
className: _propTypes.default.string,
colIndex: _propTypes.default.number,
colSpan: _propTypes.default.number,
column: _propTypes.default.object,
disableDragEvents: _propTypes.default.bool,
editCellState: _propTypes.default.shape({
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
value: _propTypes.default.any
}),
isNotVisible: _propTypes.default.bool,
height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
onClick: _propTypes.default.func,
onDoubleClick: _propTypes.default.func,
onDragEnter: _propTypes.default.func,
onDragOver: _propTypes.default.func,
onKeyDown: _propTypes.default.func,
onMouseDown: _propTypes.default.func,
onMouseUp: _propTypes.default.func,
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
showRightBorder: _propTypes.default.bool,
width: _propTypes.default.number
} : void 0;
const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
const {
column,
rowId,
editCellState,
align,
colIndex,
height,
width,
className,
showRightBorder,
colSpan,
disableDragEvents,
isNotVisible,
onClick,
onDoubleClick,
onMouseDown,
onMouseUp,
onMouseOver,
onKeyDown,
onKeyUp,
onDragEnter,
onDragOver,
style: styleProp
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded3);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const field = column.field;
const cellParamsWithAPI = (0, _useGridSelector.useGridSelector)(apiRef, () => {
// This is required because `.getCellParams` tries to get the `state.rows.tree` entry
// associated with `rowId`/`fieldId`, but this selector runs after the state has been
// updated, while `rowId`/`fieldId` reference an entry in the old state.
try {
const cellParams = apiRef.current.getCellParams(rowId, field);
const result = cellParams;
result.api = apiRef.current;
return result;
} catch (e) {
if (e instanceof _useGridParamsApi.MissingRowIdError) {
return EMPTY_CELL_PARAMS;
}
throw e;
}
}, _useGridSelector.objectShallowCompare);
const isSelected = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
id: rowId,
field
}));
const {
cellMode,
hasFocus,
isEditable,
value,
formattedValue
} = cellParamsWithAPI;
const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
const {
classes: rootClasses,
getCellClassName
} = rootProps;
const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
id: rowId,
field
});
if (column.cellClassName) {
classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
}
if (getCellClassName) {
classNames.push(getCellClassName(cellParamsWithAPI));
}
const valueToRender = formattedValue == null ? value : formattedValue;
const cellRef = React.useRef(null);
const handleRef = (0, _utils.unstable_useForkRef)(ref, cellRef);
const focusElementRef = React.useRef(null);
// @ts-expect-error To access `unstable_cellSelection` flag as it's a `premium` feature
const isSelectionMode = rootProps.unstable_cellSelection ?? false;
const ownerState = {
align,
showRightBorder,
isEditable,
classes: rootProps.classes,
isSelected,
isSelectionMode
};
const classes = useUtilityClasses(ownerState);
const publishMouseUp = React.useCallback(eventName => event => {
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (onMouseUp) {
onMouseUp(event);
}
}, [apiRef, field, onMouseUp, rowId]);
const publishMouseDown = React.useCallback(eventName => event => {
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (onMouseDown) {
onMouseDown(event);
}
}, [apiRef, field, onMouseDown, rowId]);
const publish = React.useCallback((eventName, propHandler) => event => {
// The row might have been deleted during the click
if (!apiRef.current.getRow(rowId)) {
return;
}
const params = apiRef.current.getCellParams(rowId, field || '');
apiRef.current.publishEvent(eventName, params, event);
if (propHandler) {
propHandler(event);
}
}, [apiRef, field, rowId]);
const style = React.useMemo(() => {
if (isNotVisible) {
return (0, _extends2.default)({
padding: 0,
opacity: 0,
width: 0,
border: 0
}, styleProp);
}
const cellStyle = (0, _extends2.default)({
minWidth: width,
maxWidth: width,
minHeight: height,
maxHeight: height === 'auto' ? 'none' : height
}, styleProp);
return cellStyle;
}, [width, height, isNotVisible, styleProp]);
React.useEffect(() => {
if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
return;
}
const doc = (0, _utils.unstable_ownerDocument)(apiRef.current.rootElementRef.current);
if (cellRef.current && !cellRef.current.contains(doc.activeElement)) {
const focusableElement = cellRef.current.querySelector('[tabindex="0"]');
const elementToFocus = focusElementRef.current || focusableElement || cellRef.current;
if ((0, _doesSupportPreventScroll.doesSupportPreventScroll)()) {
elementToFocus.focus({
preventScroll: true
});
} else {
const scrollPosition = apiRef.current.getScrollPosition();
elementToFocus.focus();
apiRef.current.scroll(scrollPosition);
}
}
}, [hasFocus, cellMode, apiRef]);
if (cellParamsWithAPI === EMPTY_CELL_PARAMS) {
return null;
}
let handleFocus = other.onFocus;
if (process.env.NODE_ENV === 'test' && rootProps.experimentalFeatures?.warnIfFocusStateIsNotSynced) {
handleFocus = event => {
const focusedCell = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
if (focusedCell?.id === rowId && focusedCell.field === field) {
if (typeof other.onFocus === 'function') {
other.onFocus(event);
}
return;
}
if (!warnedOnce) {
console.warn([`MUI: The cell with id=${rowId} and field=${field} received focus.`, `According to the state, the focus should be at id=${focusedCell?.id}, field=${focusedCell?.field}.`, "Not syncing the state may cause unwanted behaviors since the `cellFocusIn` event won't be fired.", 'Call `fireEvent.mouseUp` before the `fireEvent.click` to sync the focus with the state.'].join('\n'));
warnedOnce = true;
}
};
}
let children;
if (editCellState == null && column.renderCell) {
children = column.renderCell(cellParamsWithAPI);
classNames.push(_gridClasses.gridClasses['cell--withRenderer']);
classNames.push(rootClasses?.['cell--withRenderer']);
}
if (editCellState != null && column.renderEditCell) {
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
// eslint-disable-next-line @typescript-eslint/naming-convention
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded4);
const params = (0, _extends2.default)({}, cellParamsWithAPI, {
row: updatedRow
}, editCellStateRest);
children = column.renderEditCell(params);
classNames.push(_gridClasses.gridClasses['cell--editing']);
classNames.push(rootClasses?.['cell--editing']);
}
if (children === undefined) {
const valueString = valueToRender?.toString();
children = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: classes.content,
title: valueString,
role: "presentation",
children: valueString
});
}
if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
children = /*#__PURE__*/React.cloneElement(children, {
focusElementRef
});
}
const draggableEventHandlers = disableDragEvents ? null : {
onDragEnter: publish('cellDragEnter', onDragEnter),
onDragOver: publish('cellDragOver', onDragOver)
};
const ariaV7 = rootProps.experimentalFeatures?.ariaV7;
return (
/*#__PURE__*/
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
ref: handleRef,
className: (0, _clsx.default)(className, classNames, classes.root),
role: ariaV7 ? 'gridcell' : 'cell',
"data-field": field,
"data-colindex": colIndex,
"aria-colindex": colIndex + 1,
"aria-colspan": colSpan,
style: style,
tabIndex: tabIndex,
onClick: publish('cellClick', onClick),
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
onMouseOver: publish('cellMouseOver', onMouseOver),
onMouseDown: publishMouseDown('cellMouseDown'),
onMouseUp: publishMouseUp('cellMouseUp'),
onKeyDown: publish('cellKeyDown', onKeyDown),
onKeyUp: publish('cellKeyUp', onKeyUp)
}, draggableEventHandlers, other, {
onFocus: handleFocus,
children: children
}))
);
});
process.env.NODE_ENV !== "production" ? GridCellV7.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
align: _propTypes.default.oneOf(['center', 'left', 'right']).isRequired,
className: _propTypes.default.string,
colIndex: _propTypes.default.number.isRequired,
colSpan: _propTypes.default.number,
column: _propTypes.default.object.isRequired,
disableDragEvents: _propTypes.default.bool,
editCellState: _propTypes.default.shape({
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
value: _propTypes.default.any
}),
height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
isNotVisible: _propTypes.default.bool,
onClick: _propTypes.default.func,
onDoubleClick: _propTypes.default.func,
onDragEnter: _propTypes.default.func,
onDragOver: _propTypes.default.func,
onKeyDown: _propTypes.default.func,
onMouseDown: _propTypes.default.func,
onMouseUp: _propTypes.default.func,
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
showRightBorder: _propTypes.default.bool,
width: _propTypes.default.number.isRequired
} : void 0;
const MemoizedGridCellV7 = exports.GridCellV7 = (0, _fastMemo.fastMemo)(GridCellV7);

View File

@@ -0,0 +1,149 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridEditBooleanCell = GridEditBooleanCell;
exports.renderEditBooleanCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _utils = require("@mui/utils");
var _gridClasses = require("../../constants/gridClasses");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['editBooleanCell']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
function GridEditBooleanCell(props) {
const {
id: idProp,
value,
field,
className,
hasFocus,
onValueChange
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const inputRef = React.useRef(null);
const id = (0, _utils.unstable_useId)();
const [valueState, setValueState] = React.useState(value);
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const handleChange = React.useCallback(async event => {
const newValue = event.target.checked;
if (onValueChange) {
await onValueChange(event, newValue);
}
setValueState(newValue);
await apiRef.current.setEditCellValue({
id: idProp,
field,
value: newValue
}, event);
}, [apiRef, field, idProp, onValueChange]);
React.useEffect(() => {
setValueState(value);
}, [value]);
(0, _utils.unstable_useEnhancedEffect)(() => {
if (hasFocus) {
inputRef.current.focus();
}
}, [hasFocus]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)("label", (0, _extends2.default)({
htmlFor: id,
className: (0, _clsx.default)(classes.root, className)
}, other, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
id: id,
inputRef: inputRef,
checked: Boolean(valueState),
onChange: handleChange,
size: "small"
}, rootProps.slotProps?.baseCheckbox))
}));
}
process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* GridApi that let you manipulate the grid.
*/
api: _propTypes.default.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
/**
* Callback called when the value is changed by the user.
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
* @param {boolean} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
*/
onValueChange: _propTypes.default.func,
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const renderEditBooleanCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditBooleanCell, (0, _extends2.default)({}, params));
exports.renderEditBooleanCell = renderEditBooleanCell;

View File

@@ -0,0 +1,198 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridEditDateCell = GridEditDateCell;
exports.renderEditDateCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _utils = require("@mui/utils");
var _InputBase = _interopRequireDefault(require("@mui/material/InputBase"));
var _styles = require("@mui/material/styles");
var _gridClasses = require("../../constants/gridClasses");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "hasFocus", "inputProps", "isValidating", "isProcessingProps", "onValueChange"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const StyledInputBase = (0, _styles.styled)(_InputBase.default)({
fontSize: 'inherit'
});
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['editInputCell']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
function GridEditDateCell(props) {
const {
id,
value: valueProp,
field,
colDef,
hasFocus,
inputProps,
onValueChange
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const isDateTime = colDef.type === 'dateTime';
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const inputRef = React.useRef();
const valueTransformed = React.useMemo(() => {
let parsedDate;
if (valueProp == null) {
parsedDate = null;
} else if (valueProp instanceof Date) {
parsedDate = valueProp;
} else {
parsedDate = new Date((valueProp ?? '').toString());
}
let formattedDate;
if (parsedDate == null || Number.isNaN(parsedDate.getTime())) {
formattedDate = '';
} else {
const localDate = new Date(parsedDate.getTime() - parsedDate.getTimezoneOffset() * 60 * 1000);
formattedDate = localDate.toISOString().substr(0, isDateTime ? 16 : 10);
}
return {
parsed: parsedDate,
formatted: formattedDate
};
}, [valueProp, isDateTime]);
const [valueState, setValueState] = React.useState(valueTransformed);
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const parseValueToDate = React.useCallback(value => {
if (value === '') {
return null;
}
const [date, time] = value.split('T');
const [year, month, day] = date.split('-');
const parsedDate = new Date();
parsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
parsedDate.setHours(0, 0, 0, 0);
if (time) {
const [hours, minutes] = time.split(':');
parsedDate.setHours(Number(hours), Number(minutes), 0, 0);
}
return parsedDate;
}, []);
const handleChange = React.useCallback(async event => {
const newFormattedDate = event.target.value;
const newParsedDate = parseValueToDate(newFormattedDate);
if (onValueChange) {
await onValueChange(event, newParsedDate);
}
setValueState({
parsed: newParsedDate,
formatted: newFormattedDate
});
apiRef.current.setEditCellValue({
id,
field,
value: newParsedDate
}, event);
}, [apiRef, field, id, onValueChange, parseValueToDate]);
React.useEffect(() => {
setValueState(state => {
if (valueTransformed.parsed !== state.parsed && valueTransformed.parsed?.getTime() !== state.parsed?.getTime()) {
return valueTransformed;
}
return state;
});
}, [valueTransformed]);
(0, _utils.unstable_useEnhancedEffect)(() => {
if (hasFocus) {
inputRef.current.focus();
}
}, [hasFocus]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledInputBase, (0, _extends2.default)({
inputRef: inputRef,
fullWidth: true,
className: classes.root,
type: isDateTime ? 'datetime-local' : 'date',
inputProps: (0, _extends2.default)({
max: isDateTime ? '9999-12-31T23:59' : '9999-12-31'
}, inputProps),
value: valueState.formatted,
onChange: handleChange
}, other));
}
process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* GridApi that let you manipulate the grid.
*/
api: _propTypes.default.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
/**
* Callback called when the value is changed by the user.
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
* @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
*/
onValueChange: _propTypes.default.func,
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const renderEditDateCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditDateCell, (0, _extends2.default)({}, params));
exports.renderEditDateCell = renderEditDateCell;

View File

@@ -0,0 +1,173 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.renderEditInputCell = exports.GridEditInputCell = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _utils = require("@mui/utils");
var _styles = require("@mui/material/styles");
var _InputBase = _interopRequireDefault(require("@mui/material/InputBase"));
var _gridClasses = require("../../constants/gridClasses");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "hasFocus", "isValidating", "debounceMs", "isProcessingProps", "onValueChange"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['editInputCell']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
const GridEditInputCellRoot = (0, _styles.styled)(_InputBase.default, {
name: 'MuiDataGrid',
slot: 'EditInputCell',
overridesResolver: (props, styles) => styles.editInputCell
})(({
theme
}) => (0, _extends2.default)({}, theme.typography.body2, {
padding: '1px 0',
'& input': {
padding: '0 16px',
height: '100%'
}
}));
const GridEditInputCell = exports.GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const {
id,
value,
field,
colDef,
hasFocus,
debounceMs = 200,
isProcessingProps,
onValueChange
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const inputRef = React.useRef();
const [valueState, setValueState] = React.useState(value);
const classes = useUtilityClasses(rootProps);
const handleChange = React.useCallback(async event => {
const newValue = event.target.value;
if (onValueChange) {
await onValueChange(event, newValue);
}
const column = apiRef.current.getColumn(field);
let parsedValue = newValue;
if (column.valueParser) {
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
}
setValueState(parsedValue);
apiRef.current.setEditCellValue({
id,
field,
value: parsedValue,
debounceMs,
unstable_skipValueParser: true
}, event);
}, [apiRef, debounceMs, field, id, onValueChange]);
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
React.useEffect(() => {
if (meta?.changeReason !== 'debouncedSetEditCellValue') {
setValueState(value);
}
}, [meta, value]);
(0, _utils.unstable_useEnhancedEffect)(() => {
if (hasFocus) {
inputRef.current.focus();
}
}, [hasFocus]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditInputCellRoot, (0, _extends2.default)({
ref: ref,
inputRef: inputRef,
className: classes.root,
ownerState: rootProps,
fullWidth: true,
type: colDef.type === 'number' ? colDef.type : 'text',
value: valueState ?? '',
onChange: handleChange,
endAdornment: isProcessingProps ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.loadIcon, {
fontSize: "small",
color: "action"
}) : undefined
}, other));
});
process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* GridApi that let you manipulate the grid.
*/
api: _propTypes.default.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
debounceMs: _propTypes.default.number,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
/**
* Callback called when the value is changed by the user.
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
* @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
*/
onValueChange: _propTypes.default.func,
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const renderEditInputCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditInputCell, (0, _extends2.default)({}, params));
exports.renderEditInputCell = renderEditInputCell;

View File

@@ -0,0 +1,223 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridEditSingleSelectCell = GridEditSingleSelectCell;
exports.renderEditSingleSelectCell = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _utils = require("@mui/utils");
var _gridEditCellParams = require("../../models/params/gridEditCellParams");
var _keyboardUtils = require("../../utils/keyboardUtils");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _gridEditRowModel = require("../../models/gridEditRowModel");
var _filterPanelUtils = require("../panel/filterPanel/filterPanelUtils");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen", "getOptionLabel", "getOptionValue"],
_excluded2 = ["MenuProps"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function isKeyboardEvent(event) {
return !!event.key;
}
function GridEditSingleSelectCell(props) {
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const {
id,
value: valueProp,
field,
row,
colDef,
hasFocus,
error,
onValueChange,
initialOpen = rootProps.editMode === _gridEditRowModel.GridEditModes.Cell,
getOptionLabel: getOptionLabelProp,
getOptionValue: getOptionValueProp
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const ref = React.useRef();
const inputRef = React.useRef();
const [open, setOpen] = React.useState(initialOpen);
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
const isSelectNative = baseSelectProps.native ?? false;
const _ref = rootProps.slotProps?.baseSelect || {},
{
MenuProps
} = _ref,
otherBaseSelectProps = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
(0, _utils.unstable_useEnhancedEffect)(() => {
if (hasFocus) {
inputRef.current?.focus();
}
}, [hasFocus]);
if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef)) {
return null;
}
let valueOptions;
if (typeof colDef?.valueOptions === 'function') {
valueOptions = colDef?.valueOptions({
id,
row,
field
});
} else {
valueOptions = colDef?.valueOptions;
}
if (!valueOptions) {
return null;
}
const getOptionValue = getOptionValueProp || colDef.getOptionValue;
const getOptionLabel = getOptionLabelProp || colDef.getOptionLabel;
const handleChange = async event => {
if (!(0, _filterPanelUtils.isSingleSelectColDef)(colDef) || !valueOptions) {
return;
}
setOpen(false);
const target = event.target;
// NativeSelect casts the value to a string.
const formattedTargetValue = (0, _filterPanelUtils.getValueFromValueOptions)(target.value, valueOptions, getOptionValue);
if (onValueChange) {
await onValueChange(event, formattedTargetValue);
}
await apiRef.current.setEditCellValue({
id,
field,
value: formattedTargetValue
}, event);
};
const handleClose = (event, reason) => {
if (rootProps.editMode === _gridEditRowModel.GridEditModes.Row) {
setOpen(false);
return;
}
if (reason === 'backdropClick' || (0, _keyboardUtils.isEscapeKey)(event.key)) {
const params = apiRef.current.getCellParams(id, field);
apiRef.current.publishEvent('cellEditStop', (0, _extends2.default)({}, params, {
reason: (0, _keyboardUtils.isEscapeKey)(event.key) ? _gridEditCellParams.GridCellEditStopReasons.escapeKeyDown : _gridEditCellParams.GridCellEditStopReasons.cellFocusOut
}));
}
};
const handleOpen = event => {
if (isKeyboardEvent(event) && event.key === 'Enter') {
return;
}
setOpen(true);
};
if (!valueOptions || !colDef) {
return null;
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelect, (0, _extends2.default)({
ref: ref,
inputRef: inputRef,
value: valueProp,
onChange: handleChange,
open: open,
onOpen: handleOpen,
MenuProps: (0, _extends2.default)({
onClose: handleClose
}, MenuProps),
error: error,
native: isSelectNative,
fullWidth: true
}, other, otherBaseSelectProps, {
children: valueOptions.map(valueOption => {
const value = getOptionValue(valueOption);
return /*#__PURE__*/(0, _react.createElement)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, rootProps.slotProps?.baseSelectOption || {}, {
native: isSelectNative,
key: value,
value: value
}), getOptionLabel(valueOption));
})
}));
}
process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* GridApi that let you manipulate the grid.
*/
api: _propTypes.default.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
/**
* The column of the row that the current cell belongs to.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: _propTypes.default.string.isRequired,
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: _propTypes.default.any,
/**
* Used to determine the label displayed for a given value option.
* @param {ValueOptions} value The current value option.
* @returns {string} The text to be displayed.
*/
getOptionLabel: _propTypes.default.func,
/**
* Used to determine the value used for a value option.
* @param {ValueOptions} value The current value option.
* @returns {string} The value to be used.
*/
getOptionValue: _propTypes.default.func,
/**
* If true, the cell is the active element.
*/
hasFocus: _propTypes.default.bool.isRequired,
/**
* The grid row id.
*/
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
/**
* If true, the select opens by default.
*/
initialOpen: _propTypes.default.bool,
/**
* If true, the cell is editable.
*/
isEditable: _propTypes.default.bool,
isProcessingProps: _propTypes.default.bool,
isValidating: _propTypes.default.bool,
/**
* Callback called when the value is changed by the user.
* @param {SelectChangeEvent<any>} event The event source of the callback.
* @param {any} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
*/
onValueChange: _propTypes.default.func,
/**
* The row model of the row that the current cell belongs to.
*/
row: _propTypes.default.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: _propTypes.default.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: _propTypes.default.any
} : void 0;
const renderEditSingleSelectCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditSingleSelectCell, (0, _extends2.default)({}, params));
exports.renderEditSingleSelectCell = renderEditSingleSelectCell;

View File

@@ -0,0 +1,63 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridSkeletonCell = GridSkeletonCell;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _Skeleton = _interopRequireDefault(require("@mui/material/Skeleton"));
var _utils = require("@mui/utils");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _gridClasses = require("../../constants/gridClasses");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["field", "align", "width", "contentWidth"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const useUtilityClasses = ownerState => {
const {
align,
classes
} = ownerState;
const slots = {
root: ['cell', 'cellSkeleton', `cell--text${(0, _utils.unstable_capitalize)(align)}`, 'withBorderColor']
};
return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
function GridSkeletonCell(props) {
const {
align,
width,
contentWidth
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
classes: rootProps.classes,
align
};
const classes = useUtilityClasses(ownerState);
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
className: classes.root,
style: {
width
}
}, other, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
width: `${contentWidth}%`
})
}));
}
process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
align: _propTypes.default.string.isRequired,
contentWidth: _propTypes.default.number.isRequired,
field: _propTypes.default.string.isRequired,
width: _propTypes.default.number.isRequired
} : void 0;

View File

@@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
GridCell: true
};
Object.defineProperty(exports, "GridCell", {
enumerable: true,
get: function () {
return _GridCell.GridCell;
}
});
var _GridCell = require("./GridCell");
var _GridBooleanCell = require("./GridBooleanCell");
Object.keys(_GridBooleanCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridBooleanCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridBooleanCell[key];
}
});
});
var _GridEditBooleanCell = require("./GridEditBooleanCell");
Object.keys(_GridEditBooleanCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridEditBooleanCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridEditBooleanCell[key];
}
});
});
var _GridEditDateCell = require("./GridEditDateCell");
Object.keys(_GridEditDateCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridEditDateCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridEditDateCell[key];
}
});
});
var _GridEditInputCell = require("./GridEditInputCell");
Object.keys(_GridEditInputCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridEditInputCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridEditInputCell[key];
}
});
});
var _GridEditSingleSelectCell = require("./GridEditSingleSelectCell");
Object.keys(_GridEditSingleSelectCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridEditSingleSelectCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridEditSingleSelectCell[key];
}
});
});
var _GridActionsCell = require("./GridActionsCell");
Object.keys(_GridActionsCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridActionsCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridActionsCell[key];
}
});
});
var _GridActionsCellItem = require("./GridActionsCellItem");
Object.keys(_GridActionsCellItem).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridActionsCellItem[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridActionsCellItem[key];
}
});
});
var _GridSkeletonCell = require("./GridSkeletonCell");
Object.keys(_GridSkeletonCell).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _GridSkeletonCell[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridSkeletonCell[key];
}
});
});