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,160 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["field", "id", "value", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses, unstable_useForkRef as useForkRef } from '@mui/utils';
import { isSpaceKey } from '../../utils/keyboardUtils';
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { jsx as _jsx } from "react/jsx-runtime";
var useUtilityClasses = function useUtilityClasses(ownerState) {
var classes = ownerState.classes;
var slots = {
root: ['checkboxInput']
};
return composeClasses(slots, getDataGridUtilityClass, classes);
};
var GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCellCheckboxRenderer(props, ref) {
var _rootProps$slotProps;
var field = props.field,
id = props.id,
isChecked = props.value,
formattedValue = props.formattedValue,
row = props.row,
rowNode = props.rowNode,
colDef = props.colDef,
isEditable = props.isEditable,
cellMode = props.cellMode,
hasFocus = props.hasFocus,
tabIndex = props.tabIndex,
api = props.api,
other = _objectWithoutProperties(props, _excluded);
var apiRef = useGridApiContext();
var rootProps = useGridRootProps();
var ownerState = {
classes: rootProps.classes
};
var classes = useUtilityClasses(ownerState);
var checkboxElement = React.useRef(null);
var rippleRef = React.useRef(null);
var handleRef = useForkRef(checkboxElement, ref);
var element = apiRef.current.getCellElement(id, field);
var handleChange = function handleChange(event) {
var params = {
value: event.target.checked,
id: id
};
apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
};
React.useLayoutEffect(function () {
if (tabIndex === 0 && element) {
element.tabIndex = -1;
}
}, [element, tabIndex]);
React.useEffect(function () {
if (hasFocus) {
var _checkboxElement$curr;
var input = (_checkboxElement$curr = checkboxElement.current) == null ? void 0 : _checkboxElement$curr.querySelector('input');
input == null || input.focus({
preventScroll: true
});
} else if (rippleRef.current) {
// Only available in @mui/material v5.4.1 or later
rippleRef.current.stop({});
}
}, [hasFocus]);
var handleKeyDown = React.useCallback(function (event) {
if (isSpaceKey(event.key)) {
// We call event.stopPropagation to avoid selecting the row and also scrolling to bottom
// TODO: Remove and add a check inside useGridKeyboardNavigation
event.stopPropagation();
}
}, []);
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
return null;
}
var isSelectable = apiRef.current.isRowSelectable(id);
var label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
ref: handleRef,
tabIndex: tabIndex,
checked: isChecked,
onChange: handleChange,
className: classes.root,
inputProps: {
'aria-label': label
},
onKeyDown: handleKeyDown,
disabled: !isSelectable,
touchRippleRef: rippleRef
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseCheckbox, other));
});
process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.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.object.isRequired,
/**
* The mode of the cell.
*/
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
/**
* The column of the row that the current cell belongs to.
*/
colDef: PropTypes.object.isRequired,
/**
* The column field of the cell that triggered the event.
*/
field: PropTypes.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.oneOfType([PropTypes.func, PropTypes.shape({
current: PropTypes.shape({
focus: PropTypes.func.isRequired
})
})]),
/**
* The cell value formatted with the column valueFormatter.
*/
formattedValue: PropTypes.any,
/**
* If true, the cell is the active element.
*/
hasFocus: PropTypes.bool.isRequired,
/**
* The grid row id.
*/
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
/**
* If true, the cell is editable.
*/
isEditable: PropTypes.bool,
/**
* The row model of the row that the current cell belongs to.
*/
row: PropTypes.any.isRequired,
/**
* The node of the row that the current cell belongs to.
*/
rowNode: PropTypes.object.isRequired,
/**
* the tabIndex value.
*/
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
/**
* The cell value.
* If the column has `valueGetter`, use `params.row` to directly access the fields.
*/
value: PropTypes.any
} : void 0;
export { GridCellCheckboxForwardRef };
export var GridCellCheckboxRenderer = GridCellCheckboxForwardRef;

View File

@@ -0,0 +1,132 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["field", "colDef"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { useGridSelector } from '../../hooks/utils/useGridSelector';
import { gridTabIndexColumnHeaderSelector } from '../../hooks/features/focus/gridFocusStateSelector';
import { gridRowSelectionStateSelector } from '../../hooks/features/rowSelection/gridRowSelectionSelector';
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { gridExpandedSortedRowIdsSelector } from '../../hooks/features/filter/gridFilterSelector';
import { gridPaginatedVisibleSortedGridRowIdsSelector } from '../../hooks/features/pagination/gridPaginationSelector';
import { jsx as _jsx } from "react/jsx-runtime";
var useUtilityClasses = function useUtilityClasses(ownerState) {
var classes = ownerState.classes;
var slots = {
root: ['checkboxInput']
};
return composeClasses(slots, getDataGridUtilityClass, classes);
};
var GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderCheckbox(props, ref) {
var _rootProps$slotProps;
var field = props.field,
colDef = props.colDef,
other = _objectWithoutProperties(props, _excluded);
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
forceUpdate = _React$useState2[1];
var apiRef = useGridApiContext();
var rootProps = useGridRootProps();
var ownerState = {
classes: rootProps.classes
};
var classes = useUtilityClasses(ownerState);
var tabIndexState = useGridSelector(apiRef, gridTabIndexColumnHeaderSelector);
var selection = useGridSelector(apiRef, gridRowSelectionStateSelector);
var visibleRowIds = useGridSelector(apiRef, gridExpandedSortedRowIdsSelector);
var paginatedVisibleRowIds = useGridSelector(apiRef, gridPaginatedVisibleSortedGridRowIdsSelector);
var filteredSelection = React.useMemo(function () {
if (typeof rootProps.isRowSelectable !== 'function') {
return selection;
}
return selection.filter(function (id) {
// The row might have been deleted
if (!apiRef.current.getRow(id)) {
return false;
}
return rootProps.isRowSelectable(apiRef.current.getRowParams(id));
});
}, [apiRef, rootProps.isRowSelectable, selection]);
// All the rows that could be selected / unselected by toggling this checkbox
var selectionCandidates = React.useMemo(function () {
var rowIds = !rootProps.pagination || !rootProps.checkboxSelectionVisibleOnly ? visibleRowIds : paginatedVisibleRowIds;
// Convert to an object to make O(1) checking if a row exists or not
// TODO create selector that returns visibleRowIds/paginatedVisibleRowIds as an object
return rowIds.reduce(function (acc, id) {
acc[id] = true;
return acc;
}, {});
}, [rootProps.pagination, rootProps.checkboxSelectionVisibleOnly, paginatedVisibleRowIds, visibleRowIds]);
// Amount of rows selected and that are visible in the current page
var currentSelectionSize = React.useMemo(function () {
return filteredSelection.filter(function (id) {
return selectionCandidates[id];
}).length;
}, [filteredSelection, selectionCandidates]);
var isIndeterminate = currentSelectionSize > 0 && currentSelectionSize < Object.keys(selectionCandidates).length;
var isChecked = currentSelectionSize > 0;
var handleChange = function handleChange(event) {
var params = {
value: event.target.checked
};
apiRef.current.publishEvent('headerSelectionCheckboxChange', params);
};
var tabIndex = tabIndexState !== null && tabIndexState.field === props.field ? 0 : -1;
React.useLayoutEffect(function () {
var element = apiRef.current.getColumnHeaderElement(props.field);
if (tabIndex === 0 && element) {
element.tabIndex = -1;
}
}, [tabIndex, apiRef, props.field]);
var handleKeyDown = React.useCallback(function (event) {
if (event.key === ' ') {
// imperative toggle the checkbox because Space is disable by some preventDefault
apiRef.current.publishEvent('headerSelectionCheckboxChange', {
value: !isChecked
});
}
}, [apiRef, isChecked]);
var handleSelectionChange = React.useCallback(function () {
forceUpdate(function (p) {
return !p;
});
}, []);
React.useEffect(function () {
return apiRef.current.subscribeEvent('rowSelectionChange', handleSelectionChange);
}, [apiRef, handleSelectionChange]);
var label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectAllRows' : 'checkboxSelectionSelectAllRows');
return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
ref: ref,
indeterminate: isIndeterminate,
checked: isChecked,
onChange: handleChange,
className: classes.root,
inputProps: {
'aria-label': label
},
tabIndex: tabIndex,
onKeyDown: handleKeyDown
}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseCheckbox, other));
});
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* The column of the current header component.
*/
colDef: PropTypes.object.isRequired,
/**
* The column field of the column that triggered the event
*/
field: PropTypes.string.isRequired
} : void 0;
export { GridHeaderCheckbox };

View File

@@ -0,0 +1,2 @@
export * from './GridCellCheckboxRenderer';
export * from './GridHeaderCheckbox';