neue Homepage auf react basis

This commit is contained in:
2026-08-07 21:39:30 +02:00
parent 164bdd19ad
commit ee89442c04
52191 changed files with 1230242 additions and 58 deletions
@@ -0,0 +1,5 @@
import * as React from 'react';
import type { GridRenderCellParams } from "../../models/params/gridCellParams.mjs";
declare const GridCellCheckboxForwardRef: React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>> | React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender> & React.RefAttributes<HTMLInputElement>>;
export { GridCellCheckboxForwardRef };
export declare const GridCellCheckboxRenderer: React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>> | React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender> & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,5 @@
import * as React from 'react';
import type { GridRenderCellParams } from "../../models/params/gridCellParams.js";
declare const GridCellCheckboxForwardRef: React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>> | React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender> & React.RefAttributes<HTMLInputElement>>;
export { GridCellCheckboxForwardRef };
export declare const GridCellCheckboxRenderer: React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>> | React.ForwardRefExoticComponent<GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender> & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,178 @@
"use strict";
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridCellCheckboxRenderer = exports.GridCellCheckboxForwardRef = 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 _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
var _forwardRef = require("@mui/x-internals/forwardRef");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _gridClasses = require("../../constants/gridClasses");
var _useGridSelector = require("../../hooks/utils/useGridSelector");
var _utils = require("../../hooks/features/rowSelection/utils");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["field", "id", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['checkboxInput']
};
return (0, _composeClasses.default)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
const GridCellCheckboxForwardRef = exports.GridCellCheckboxForwardRef = (0, _forwardRef.forwardRef)(function GridCellCheckboxRenderer(props, ref) {
const {
field,
id,
rowNode,
tabIndex
} = 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 {
isIndeterminate,
isChecked,
isSelectable
} = (0, _useGridSelector.useGridSelector)(apiRef, _utils.checkboxPropsSelector, {
groupId: id,
autoSelectParents: rootProps.rowSelectionPropagation?.parents ?? false
}, _useGridSelector.objectShallowCompare);
const disabled = !isSelectable;
const handleChange = event => {
if (disabled) {
return;
}
const params = {
value: event.target.checked,
id
};
apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
};
React.useLayoutEffect(() => {
if (tabIndex === 0 && !disabled) {
const element = apiRef.current.getCellElement(id, field);
if (element) {
element.tabIndex = -1;
}
}
}, [apiRef, tabIndex, id, field, disabled]);
const handleKeyDown = (0, _useEventCallback.default)(event => {
if (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 (disabled) {
return;
}
});
const handleClick = (0, _useEventCallback.default)(event => {
if (disabled) {
event.preventDefault();
return;
}
});
const handleMouseDown = (0, _useEventCallback.default)(() => {
if (disabled) {
return;
}
});
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
return null;
}
const label = apiRef.current.getLocaleText(isChecked && !isIndeterminate ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.rowCheckbox, (0, _extends2.default)({
rowId: id,
tabIndex: disabled ? -1 : tabIndex,
checked: isChecked && !isIndeterminate,
onChange: handleChange,
onClick: handleClick,
onMouseDown: handleMouseDown,
className: (0, _clsx.default)(classes.root, disabled && 'Mui-disabled'),
disabled: disabled,
slotProps: {
htmlInput: {
'aria-disabled': disabled || undefined,
'aria-label': label,
name: 'select_row'
}
},
onKeyDown: handleKeyDown,
indeterminate: isIndeterminate
}, rootProps.slotProps?.rowCheckbox, other, {
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridCellCheckboxForwardRef.displayName = "GridCellCheckboxForwardRef";
process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm 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,
/**
* 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 GridCellCheckboxRenderer = exports.GridCellCheckboxRenderer = GridCellCheckboxForwardRef;
@@ -0,0 +1,172 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["field", "id", "formattedValue", "row", "rowNode", "colDef", "isEditable", "cellMode", "hasFocus", "tabIndex", "api"];
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import useEventCallback from '@mui/utils/useEventCallback';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.mjs";
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
import { getDataGridUtilityClass } from "../../constants/gridClasses.mjs";
import { useGridSelector, objectShallowCompare } from "../../hooks/utils/useGridSelector.mjs";
import { checkboxPropsSelector } from "../../hooks/features/rowSelection/utils.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['checkboxInput']
};
return composeClasses(slots, getDataGridUtilityClass, classes);
};
const GridCellCheckboxForwardRef = forwardRef(function GridCellCheckboxRenderer(props, ref) {
const {
field,
id,
rowNode,
tabIndex
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const {
isIndeterminate,
isChecked,
isSelectable
} = useGridSelector(apiRef, checkboxPropsSelector, {
groupId: id,
autoSelectParents: rootProps.rowSelectionPropagation?.parents ?? false
}, objectShallowCompare);
const disabled = !isSelectable;
const handleChange = event => {
if (disabled) {
return;
}
const params = {
value: event.target.checked,
id
};
apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
};
React.useLayoutEffect(() => {
if (tabIndex === 0 && !disabled) {
const element = apiRef.current.getCellElement(id, field);
if (element) {
element.tabIndex = -1;
}
}
}, [apiRef, tabIndex, id, field, disabled]);
const handleKeyDown = useEventCallback(event => {
if (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 (disabled) {
return;
}
});
const handleClick = useEventCallback(event => {
if (disabled) {
event.preventDefault();
return;
}
});
const handleMouseDown = useEventCallback(() => {
if (disabled) {
return;
}
});
if (rowNode.type === 'footer' || rowNode.type === 'pinnedRow') {
return null;
}
const label = apiRef.current.getLocaleText(isChecked && !isIndeterminate ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
return /*#__PURE__*/_jsx(rootProps.slots.rowCheckbox, _extends({
rowId: id,
tabIndex: disabled ? -1 : tabIndex,
checked: isChecked && !isIndeterminate,
onChange: handleChange,
onClick: handleClick,
onMouseDown: handleMouseDown,
className: clsx(classes.root, disabled && 'Mui-disabled'),
disabled: disabled,
slotProps: {
htmlInput: {
'aria-disabled': disabled || undefined,
'aria-label': label,
name: 'select_row'
}
},
onKeyDown: handleKeyDown,
indeterminate: isIndeterminate
}, rootProps.slotProps?.rowCheckbox, other, {
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridCellCheckboxForwardRef.displayName = "GridCellCheckboxForwardRef";
process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm 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,
/**
* 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 const GridCellCheckboxRenderer = GridCellCheckboxForwardRef;
@@ -0,0 +1,4 @@
import * as React from 'react';
import type { GridColumnHeaderParams } from "../../models/params/gridColumnHeaderParams.mjs";
declare const GridHeaderCheckbox: React.ForwardRefExoticComponent<GridColumnHeaderParams<import("@mui/x-data-grid").GridValidRowModel, any, any>> | React.ForwardRefExoticComponent<GridColumnHeaderParams<import("@mui/x-data-grid").GridValidRowModel, any, any> & React.RefAttributes<HTMLButtonElement>>;
export { GridHeaderCheckbox };
@@ -0,0 +1,4 @@
import * as React from 'react';
import type { GridColumnHeaderParams } from "../../models/params/gridColumnHeaderParams.js";
declare const GridHeaderCheckbox: React.ForwardRefExoticComponent<GridColumnHeaderParams<import("@mui/x-data-grid").GridValidRowModel, any, any>> | React.ForwardRefExoticComponent<GridColumnHeaderParams<import("@mui/x-data-grid").GridValidRowModel, any, any> & React.RefAttributes<HTMLButtonElement>>;
export { GridHeaderCheckbox };
@@ -0,0 +1,184 @@
"use strict";
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridHeaderCheckbox = 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 _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
var _forwardRef = require("@mui/x-internals/forwardRef");
var _utils = require("../../hooks/features/rowSelection/utils");
var _useGridSelector = require("../../hooks/utils/useGridSelector");
var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
var _gridRowSelectionSelector = require("../../hooks/features/rowSelection/gridRowSelectionSelector");
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
var _gridClasses = require("../../constants/gridClasses");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _gridFilterSelector = require("../../hooks/features/filter/gridFilterSelector");
var _gridPaginationSelector = require("../../hooks/features/pagination/gridPaginationSelector");
var _gridRowSelectionManager = require("../../models/gridRowSelectionManager");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["field", "colDef"];
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['checkboxInput']
};
return (0, _composeClasses.default)(slots, _gridClasses.getDataGridUtilityClass, classes);
};
const GridHeaderCheckbox = exports.GridHeaderCheckbox = (0, _forwardRef.forwardRef)(function GridHeaderCheckbox(props, ref) {
const other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const [, forceUpdate] = React.useState(false);
const apiRef = (0, _useGridApiContext.useGridApiContext)();
const rootProps = (0, _useGridRootProps.useGridRootProps)();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const tabIndexState = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexColumnHeaderSelector);
const selection = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSelectionSelector.gridRowSelectionStateSelector);
const visibleRowIds = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridExpandedSortedRowIdsSelector);
const paginatedVisibleRowIds = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginatedVisibleSortedGridRowIdsSelector);
const filteredSelection = React.useMemo(() => {
const isRowSelectable = rootProps.isRowSelectable;
if (typeof isRowSelectable !== 'function') {
return selection;
}
if (selection.type === 'exclude') {
return selection;
}
// selection.type === 'include'
const selectionModel = {
type: 'include',
ids: new Set()
};
for (const id of selection.ids) {
if (rootProps.keepNonExistentRowsSelected) {
selectionModel.ids.add(id);
}
// The row might have been deleted
if (!apiRef.current.getRow(id)) {
continue;
}
if (isRowSelectable(apiRef.current.getRowParams(id))) {
selectionModel.ids.add(id);
}
}
return selectionModel;
}, [apiRef, rootProps.isRowSelectable, rootProps.keepNonExistentRowsSelected, selection]);
// All the rows that could be selected / unselected by toggling this checkbox
const selectionCandidates = React.useMemo(() => {
const rowIds = !rootProps.pagination || !rootProps.checkboxSelectionVisibleOnly || rootProps.paginationMode === 'server' ? visibleRowIds : paginatedVisibleRowIds;
// Convert to a Set to make O(1) checking if a row exists or not
const candidates = new Set();
for (let i = 0; i < rowIds.length; i += 1) {
const id = rowIds[i];
if (!apiRef.current.getRow(id)) {
// The row could have been removed
continue;
}
if (apiRef.current.isRowSelectable(id)) {
candidates.add(id);
}
}
return candidates;
}, [apiRef, rootProps.pagination, rootProps.paginationMode, rootProps.checkboxSelectionVisibleOnly, paginatedVisibleRowIds, visibleRowIds]);
// Amount of rows selected and that are visible in the current page
const currentSelectionSize = React.useMemo(() => {
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(filteredSelection);
let size = 0;
for (const id of selectionCandidates) {
if (selectionManager.has(id)) {
size += 1;
}
}
return size;
}, [filteredSelection, selectionCandidates]);
const isIndeterminate = React.useMemo(() => {
if (currentSelectionSize === 0) {
return false;
}
const selectionManager = (0, _gridRowSelectionManager.createRowSelectionManager)(filteredSelection);
for (const rowId of selectionCandidates) {
if (!selectionManager.has(rowId)) {
return true;
}
}
return false;
}, [currentSelectionSize, filteredSelection, selectionCandidates]);
const isChecked = currentSelectionSize > 0;
const handleChange = event => {
const params = {
value: event.target.checked
};
apiRef.current.publishEvent('headerSelectionCheckboxChange', params);
};
const multipleSelectionEnabled = (0, _utils.isMultipleRowSelectionEnabled)(rootProps);
const tabIndex = tabIndexState !== null && tabIndexState.field === props.field && multipleSelectionEnabled ? 0 : -1;
(0, _useEnhancedEffect.default)(() => {
const element = apiRef.current.getColumnHeaderElement(props.field);
if (tabIndex === 0 && element && multipleSelectionEnabled) {
element.tabIndex = -1;
}
}, [tabIndex, apiRef, props.field, multipleSelectionEnabled]);
const handleKeyDown = React.useCallback(event => {
if (event.key === ' ') {
// imperative toggle the checkbox because Space is disable by some preventDefault
apiRef.current.publishEvent('headerSelectionCheckboxChange', {
value: !isChecked
});
}
}, [apiRef, isChecked]);
const handleSelectionChange = React.useCallback(() => {
forceUpdate(p => !p);
}, []);
React.useEffect(() => {
return apiRef.current.subscribeEvent('rowSelectionChange', handleSelectionChange);
}, [apiRef, handleSelectionChange]);
const label = apiRef.current.getLocaleText(isChecked && !isIndeterminate ? 'checkboxSelectionUnselectAllRows' : 'checkboxSelectionSelectAllRows');
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
indeterminate: isIndeterminate,
checked: isChecked && !isIndeterminate,
onChange: handleChange,
className: classes.root,
slotProps: {
htmlInput: {
'aria-label': label,
name: 'select_all_rows'
}
},
tabIndex: tabIndex,
onKeyDown: handleKeyDown,
disabled: !multipleSelectionEnabled
}, rootProps.slotProps?.baseCheckbox, other, {
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridHeaderCheckbox.displayName = "GridHeaderCheckbox";
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* The column of the current header component.
*/
colDef: _propTypes.default.object.isRequired,
/**
* The column field of the column that triggered the event
*/
field: _propTypes.default.string.isRequired
} : void 0;
@@ -0,0 +1,178 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["field", "colDef"];
import * as React from 'react';
import PropTypes from 'prop-types';
import composeClasses from '@mui/utils/composeClasses';
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { isMultipleRowSelectionEnabled } from "../../hooks/features/rowSelection/utils.mjs";
import { useGridSelector } from "../../hooks/utils/useGridSelector.mjs";
import { gridTabIndexColumnHeaderSelector } from "../../hooks/features/focus/gridFocusStateSelector.mjs";
import { gridRowSelectionStateSelector } from "../../hooks/features/rowSelection/gridRowSelectionSelector.mjs";
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.mjs";
import { getDataGridUtilityClass } from "../../constants/gridClasses.mjs";
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
import { gridExpandedSortedRowIdsSelector } from "../../hooks/features/filter/gridFilterSelector.mjs";
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../../hooks/features/pagination/gridPaginationSelector.mjs";
import { createRowSelectionManager } from "../../models/gridRowSelectionManager.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['checkboxInput']
};
return composeClasses(slots, getDataGridUtilityClass, classes);
};
const GridHeaderCheckbox = forwardRef(function GridHeaderCheckbox(props, ref) {
const other = _objectWithoutPropertiesLoose(props, _excluded);
const [, forceUpdate] = React.useState(false);
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const ownerState = {
classes: rootProps.classes
};
const classes = useUtilityClasses(ownerState);
const tabIndexState = useGridSelector(apiRef, gridTabIndexColumnHeaderSelector);
const selection = useGridSelector(apiRef, gridRowSelectionStateSelector);
const visibleRowIds = useGridSelector(apiRef, gridExpandedSortedRowIdsSelector);
const paginatedVisibleRowIds = useGridSelector(apiRef, gridPaginatedVisibleSortedGridRowIdsSelector);
const filteredSelection = React.useMemo(() => {
const isRowSelectable = rootProps.isRowSelectable;
if (typeof isRowSelectable !== 'function') {
return selection;
}
if (selection.type === 'exclude') {
return selection;
}
// selection.type === 'include'
const selectionModel = {
type: 'include',
ids: new Set()
};
for (const id of selection.ids) {
if (rootProps.keepNonExistentRowsSelected) {
selectionModel.ids.add(id);
}
// The row might have been deleted
if (!apiRef.current.getRow(id)) {
continue;
}
if (isRowSelectable(apiRef.current.getRowParams(id))) {
selectionModel.ids.add(id);
}
}
return selectionModel;
}, [apiRef, rootProps.isRowSelectable, rootProps.keepNonExistentRowsSelected, selection]);
// All the rows that could be selected / unselected by toggling this checkbox
const selectionCandidates = React.useMemo(() => {
const rowIds = !rootProps.pagination || !rootProps.checkboxSelectionVisibleOnly || rootProps.paginationMode === 'server' ? visibleRowIds : paginatedVisibleRowIds;
// Convert to a Set to make O(1) checking if a row exists or not
const candidates = new Set();
for (let i = 0; i < rowIds.length; i += 1) {
const id = rowIds[i];
if (!apiRef.current.getRow(id)) {
// The row could have been removed
continue;
}
if (apiRef.current.isRowSelectable(id)) {
candidates.add(id);
}
}
return candidates;
}, [apiRef, rootProps.pagination, rootProps.paginationMode, rootProps.checkboxSelectionVisibleOnly, paginatedVisibleRowIds, visibleRowIds]);
// Amount of rows selected and that are visible in the current page
const currentSelectionSize = React.useMemo(() => {
const selectionManager = createRowSelectionManager(filteredSelection);
let size = 0;
for (const id of selectionCandidates) {
if (selectionManager.has(id)) {
size += 1;
}
}
return size;
}, [filteredSelection, selectionCandidates]);
const isIndeterminate = React.useMemo(() => {
if (currentSelectionSize === 0) {
return false;
}
const selectionManager = createRowSelectionManager(filteredSelection);
for (const rowId of selectionCandidates) {
if (!selectionManager.has(rowId)) {
return true;
}
}
return false;
}, [currentSelectionSize, filteredSelection, selectionCandidates]);
const isChecked = currentSelectionSize > 0;
const handleChange = event => {
const params = {
value: event.target.checked
};
apiRef.current.publishEvent('headerSelectionCheckboxChange', params);
};
const multipleSelectionEnabled = isMultipleRowSelectionEnabled(rootProps);
const tabIndex = tabIndexState !== null && tabIndexState.field === props.field && multipleSelectionEnabled ? 0 : -1;
useEnhancedEffect(() => {
const element = apiRef.current.getColumnHeaderElement(props.field);
if (tabIndex === 0 && element && multipleSelectionEnabled) {
element.tabIndex = -1;
}
}, [tabIndex, apiRef, props.field, multipleSelectionEnabled]);
const handleKeyDown = React.useCallback(event => {
if (event.key === ' ') {
// imperative toggle the checkbox because Space is disable by some preventDefault
apiRef.current.publishEvent('headerSelectionCheckboxChange', {
value: !isChecked
});
}
}, [apiRef, isChecked]);
const handleSelectionChange = React.useCallback(() => {
forceUpdate(p => !p);
}, []);
React.useEffect(() => {
return apiRef.current.subscribeEvent('rowSelectionChange', handleSelectionChange);
}, [apiRef, handleSelectionChange]);
const label = apiRef.current.getLocaleText(isChecked && !isIndeterminate ? 'checkboxSelectionUnselectAllRows' : 'checkboxSelectionSelectAllRows');
return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({
indeterminate: isIndeterminate,
checked: isChecked && !isIndeterminate,
onChange: handleChange,
className: classes.root,
slotProps: {
htmlInput: {
'aria-label': label,
name: 'select_all_rows'
}
},
tabIndex: tabIndex,
onKeyDown: handleKeyDown,
disabled: !multipleSelectionEnabled
}, rootProps.slotProps?.baseCheckbox, other, {
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridHeaderCheckbox.displayName = "GridHeaderCheckbox";
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm 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 };
@@ -0,0 +1,4 @@
import * as React from 'react';
import type { GridRowCheckboxProps } from "../../models/gridSlotsComponentsProps.mjs";
declare const GridRowCheckbox: React.ForwardRefExoticComponent<GridRowCheckboxProps> | React.ForwardRefExoticComponent<Omit<GridRowCheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
export { GridRowCheckbox };
@@ -0,0 +1,4 @@
import * as React from 'react';
import type { GridRowCheckboxProps } from "../../models/gridSlotsComponentsProps.js";
declare const GridRowCheckbox: React.ForwardRefExoticComponent<GridRowCheckboxProps> | React.ForwardRefExoticComponent<Omit<GridRowCheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
export { GridRowCheckbox };
@@ -0,0 +1,59 @@
"use strict";
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.GridRowCheckbox = 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 _forwardRef = require("@mui/x-internals/forwardRef");
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["rowId", "material"];
const GridRowCheckbox = exports.GridRowCheckbox = (0, _forwardRef.forwardRef)(function GridRowCheckbox(props, ref) {
const {
material
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const rootProps = (0, _useGridRootProps.useGridRootProps)();
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({}, rootProps.slotProps?.baseCheckbox, other, {
material: (0, _extends2.default)({
disableRipple: props.disabled
}, material),
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridRowCheckbox.displayName = "GridRowCheckbox";
process.env.NODE_ENV !== "production" ? GridRowCheckbox.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
autoFocus: _propTypes.default.bool,
checked: _propTypes.default.bool,
className: _propTypes.default.string,
density: _propTypes.default.oneOf(['compact', 'standard']),
disabled: _propTypes.default.bool,
fullWidth: _propTypes.default.bool,
id: _propTypes.default.string,
indeterminate: _propTypes.default.bool,
inputRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
current: _propTypes.default.object
})]),
label: _propTypes.default.node,
name: _propTypes.default.string,
/**
* The grid row id.
*/
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
size: _propTypes.default.oneOf(['medium', 'small']),
slotProps: _propTypes.default.object,
style: _propTypes.default.object,
tabIndex: _propTypes.default.number,
touchRippleRef: _propTypes.default.any
} : void 0;
@@ -0,0 +1,53 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["rowId", "material"];
import * as React from 'react';
import PropTypes from 'prop-types';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
const GridRowCheckbox = forwardRef(function GridRowCheckbox(props, ref) {
const {
material
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const rootProps = useGridRootProps();
return /*#__PURE__*/_jsx(rootProps.slots.baseCheckbox, _extends({}, rootProps.slotProps?.baseCheckbox, other, {
material: _extends({
disableRipple: props.disabled
}, material),
ref: ref
}));
});
if (process.env.NODE_ENV !== "production") GridRowCheckbox.displayName = "GridRowCheckbox";
process.env.NODE_ENV !== "production" ? GridRowCheckbox.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
autoFocus: PropTypes.bool,
checked: PropTypes.bool,
className: PropTypes.string,
density: PropTypes.oneOf(['compact', 'standard']),
disabled: PropTypes.bool,
fullWidth: PropTypes.bool,
id: PropTypes.string,
indeterminate: PropTypes.bool,
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
current: PropTypes.object
})]),
label: PropTypes.node,
name: PropTypes.string,
/**
* The grid row id.
*/
rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
size: PropTypes.oneOf(['medium', 'small']),
slotProps: PropTypes.object,
style: PropTypes.object,
tabIndex: PropTypes.number,
touchRippleRef: PropTypes.any
} : void 0;
export { GridRowCheckbox };
@@ -0,0 +1,3 @@
export * from "./GridCellCheckboxRenderer.mjs";
export * from "./GridHeaderCheckbox.mjs";
export * from "./GridRowCheckbox.mjs";
@@ -0,0 +1,3 @@
export * from "./GridCellCheckboxRenderer.js";
export * from "./GridHeaderCheckbox.js";
export * from "./GridRowCheckbox.js";
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _GridCellCheckboxRenderer = require("./GridCellCheckboxRenderer");
Object.keys(_GridCellCheckboxRenderer).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _GridCellCheckboxRenderer[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridCellCheckboxRenderer[key];
}
});
});
var _GridHeaderCheckbox = require("./GridHeaderCheckbox");
Object.keys(_GridHeaderCheckbox).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _GridHeaderCheckbox[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridHeaderCheckbox[key];
}
});
});
var _GridRowCheckbox = require("./GridRowCheckbox");
Object.keys(_GridRowCheckbox).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _GridRowCheckbox[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _GridRowCheckbox[key];
}
});
});
@@ -0,0 +1,3 @@
export * from "./GridCellCheckboxRenderer.mjs";
export * from "./GridHeaderCheckbox.mjs";
export * from "./GridRowCheckbox.mjs";